1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 10:51:11 +01:00
thefuck/tests/rules/test_composer_not_command.py

57 lines
1.9 KiB
Python
Raw Normal View History

2015-04-23 16:34:34 +01:00
import pytest
from thefuck.rules.composer_not_command import match, get_new_command
from tests.utils import Command
2015-04-23 16:34:34 +01:00
@pytest.fixture
def composer_not_command():
# that weird spacing is part of the actual command output
return (
'\n'
'\n'
' \n'
' [InvalidArgumentException] \n'
' Command "udpate" is not defined. \n'
' Did you mean this? \n'
' update \n'
' \n'
'\n'
'\n'
)
2015-04-23 16:34:34 +01:00
@pytest.fixture
def composer_not_command_one_of_this():
# that weird spacing is part of the actual command output
return (
'\n'
'\n'
' \n'
' [InvalidArgumentException] \n'
' Command "pdate" is not defined. \n'
' Did you mean one of these? \n'
' selfupdate \n'
' self-update \n'
' update \n'
' \n'
'\n'
'\n'
)
2015-04-23 16:34:34 +01:00
2015-04-23 20:47:46 +01:00
2015-04-23 16:34:34 +01:00
def test_match(composer_not_command, composer_not_command_one_of_this):
assert match(Command('composer udpate',
stderr=composer_not_command))
assert match(Command('composer pdate',
stderr=composer_not_command_one_of_this))
assert not match(Command('ls update', stderr=composer_not_command))
2015-04-23 16:34:34 +01:00
def test_get_new_command(composer_not_command, composer_not_command_one_of_this):
assert get_new_command(Command('composer udpate',
stderr=composer_not_command)) \
2015-04-23 20:47:46 +01:00
== 'composer update'
2015-04-23 16:34:34 +01:00
assert get_new_command(
Command('composer pdate', stderr=composer_not_command_one_of_this)) \
== 'composer selfupdate'