2015-10-28 16:43:24 +01:00
|
|
|
from mock import patch
|
2015-04-22 23:04:22 +02:00
|
|
|
from thefuck.rules.has_exists_script import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-20 15:46:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_match():
|
|
|
|
with patch('os.path.exists', return_value=True):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert match(Command('main', 'main: command not found'))
|
|
|
|
assert match(Command('main --help',
|
|
|
|
'main: command not found'))
|
|
|
|
assert not match(Command('main', ''))
|
2015-04-20 15:46:02 +02:00
|
|
|
|
|
|
|
with patch('os.path.exists', return_value=False):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert not match(Command('main', 'main: command not found'))
|
2015-04-20 15:46:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command():
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command('main --help', '')) == './main --help'
|