2016-08-13 16:10:12 +03:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.fab_command_not_found import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2016-08-13 16:10:12 +03:00
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
output = '''
|
2016-08-13 16:10:12 +03:00
|
|
|
Warning: Command(s) not found:
|
|
|
|
extenson
|
|
|
|
deloyp
|
2017-08-31 17:58:56 +02:00
|
|
|
|
2016-08-13 16:10:12 +03:00
|
|
|
Available commands:
|
|
|
|
|
|
|
|
update_config
|
|
|
|
prepare_extension
|
|
|
|
Template A string class for supporting $-substitutions.
|
|
|
|
deploy
|
|
|
|
glob Return a list of paths matching a pathname pattern.
|
|
|
|
install_web
|
|
|
|
set_version
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('fab extenson', output),
|
|
|
|
Command('fab deloyp', output),
|
|
|
|
Command('fab extenson deloyp', output)])
|
2016-08-13 16:10:12 +03:00
|
|
|
def test_match(command):
|
|
|
|
assert match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('gulp extenson', output),
|
|
|
|
Command('fab deloyp', '')])
|
2016-08-13 16:10:12 +03:00
|
|
|
def test_not_match(command):
|
|
|
|
assert not match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, result', [
|
|
|
|
('fab extenson', 'fab prepare_extension'),
|
|
|
|
('fab extenson:version=2016',
|
|
|
|
'fab prepare_extension:version=2016'),
|
|
|
|
('fab extenson:version=2016 install_web set_version:val=0.5.0',
|
|
|
|
'fab prepare_extension:version=2016 install_web set_version:val=0.5.0'),
|
|
|
|
('fab extenson:version=2016 deloyp:beta=true -H the.fuck',
|
|
|
|
'fab prepare_extension:version=2016 deploy:beta=true -H the.fuck'),
|
|
|
|
])
|
|
|
|
def test_get_new_command(script, result):
|
2017-08-31 17:58:56 +02:00
|
|
|
command = Command(script, output)
|
2016-08-13 16:10:12 +03:00
|
|
|
assert get_new_command(command) == result
|