2015-04-17 16:24:03 +02:00
|
|
|
from mock import patch, Mock
|
2015-04-17 17:01:30 +02:00
|
|
|
from thefuck.rules.no_command import match, get_new_command
|
2015-04-08 19:00:03 +02:00
|
|
|
|
|
|
|
|
2015-04-21 06:55:47 +02:00
|
|
|
def test_match():
|
2015-05-20 16:58:05 +03:00
|
|
|
with patch('thefuck.rules.no_command._get_all_callables',
|
2015-04-21 06:55:47 +02:00
|
|
|
return_value=['vim', 'apt-get']):
|
|
|
|
assert match(Mock(stderr='vom: not found', script='vom file.py'), None)
|
|
|
|
assert not match(Mock(stderr='qweqwe: not found', script='qweqwe'), None)
|
|
|
|
assert not match(Mock(stderr='some text', script='vom file.py'), None)
|
2015-04-08 19:00:03 +02:00
|
|
|
|
|
|
|
|
2015-04-21 06:55:47 +02:00
|
|
|
def test_get_new_command():
|
2015-05-20 16:58:05 +03:00
|
|
|
with patch('thefuck.rules.no_command._get_all_callables',
|
2015-04-21 06:55:47 +02:00
|
|
|
return_value=['vim', 'apt-get']):
|
|
|
|
assert get_new_command(
|
|
|
|
Mock(stderr='vom: not found',
|
|
|
|
script='vom file.py'),
|
|
|
|
None) == 'vim file.py'
|