2015-08-13 13:09:19 +01:00
|
|
|
import pytest
|
2015-08-14 09:38:42 +01:00
|
|
|
from thefuck.rules.unknown_command import match, get_new_command
|
2015-08-13 13:09:19 +01:00
|
|
|
from tests.utils import Command
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command(script='./bin/hdfs dfs ls', stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'),
|
|
|
|
Command(script='hdfs dfs ls',
|
|
|
|
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'),
|
|
|
|
Command(script='hdfs dfs ls /foo/bar', stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.')])
|
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-08-13 13:09:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command(script='./bin/hdfs dfs -ls', stderr=''),
|
2015-11-15 18:02:37 +01:00
|
|
|
Command(script='./bin/hdfs dfs -ls /foo/bar', stderr=''),
|
|
|
|
Command(script='hdfs dfs -ls -R /foo/bar', stderr=''),
|
2015-08-13 13:09:19 +01:00
|
|
|
Command()])
|
|
|
|
def test_not_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(command)
|
2015-08-13 13:09:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2015-08-13 17:19:16 +01:00
|
|
|
(Command('hdfs dfs ls',
|
|
|
|
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'), ['hdfs dfs -ls']),
|
|
|
|
(Command('hdfs dfs rm /foo/bar',
|
|
|
|
stderr='rm: Unknown command\nDid you mean -rm? This command begins with a dash.'), ['hdfs dfs -rm /foo/bar']),
|
|
|
|
(Command('./bin/hdfs dfs ls -R /foo/bar',
|
|
|
|
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'), ['./bin/hdfs dfs -ls -R /foo/bar']),
|
|
|
|
(Command('./bin/hdfs dfs -Dtest=fred ls -R /foo/bar',
|
|
|
|
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'), ['./bin/hdfs dfs -Dtest=fred -ls -R /foo/bar'])])
|
2015-08-13 13:09:19 +01:00
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == new_command
|