2015-09-09 10:53:56 +03:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.touch import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-09-09 10:53:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2017-08-31 17:58:56 +02:00
|
|
|
def output():
|
2015-09-09 10:53:56 +03:00
|
|
|
return "touch: cannot touch '/a/b/c':" \
|
|
|
|
" No such file or directory"
|
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_match(output):
|
|
|
|
command = Command('touch /a/b/c', output)
|
2015-09-09 10:53:56 +03:00
|
|
|
assert match(command)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command('touch /a/b/c', ''),
|
|
|
|
Command('ls /a/b/c', output())])
|
2015-09-09 10:53:56 +03:00
|
|
|
def test_not_match(command):
|
|
|
|
assert not match(command)
|
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
def test_get_new_command(output):
|
|
|
|
command = Command('touch /a/b/c', output)
|
2015-09-09 10:53:56 +03:00
|
|
|
fixed_command = get_new_command(command)
|
|
|
|
assert fixed_command == 'mkdir -p /a/b && touch /a/b/c'
|