2015-07-10 17:58:41 +03:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.history import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-07-10 17:58:41 +03:00
|
|
|
|
|
|
|
|
2016-03-13 15:10:37 +03:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def history_without_current(mocker):
|
|
|
|
return mocker.patch(
|
|
|
|
'thefuck.rules.history.get_valid_history_without_current',
|
|
|
|
return_value=['ls cat', 'diff x'])
|
2015-07-20 01:53:32 +03:00
|
|
|
|
|
|
|
|
2015-07-10 17:58:41 +03:00
|
|
|
@pytest.mark.parametrize('script', ['ls cet', 'daff x'])
|
|
|
|
def test_match(script):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert match(Command(script, ''))
|
2015-07-10 17:58:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script', ['apt-get', 'nocommand y'])
|
|
|
|
def test_not_match(script):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert not match(Command(script, ''))
|
2015-07-10 17:58:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, result', [
|
|
|
|
('ls cet', 'ls cat'),
|
|
|
|
('daff x', 'diff x')])
|
|
|
|
def test_get_new_command(script, result):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command(script, '')) == result
|