2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2015-04-20 12:32:32 +02:00
|
|
|
from thefuck.rules.rm_dir import match, get_new_command
|
2015-04-25 02:35:26 +02:00
|
|
|
from tests.utils import Command
|
2015-04-20 12:32:32 +02:00
|
|
|
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command('rm foo', stderr='rm: foo: is a directory'),
|
2015-08-21 15:48:54 +01:00
|
|
|
Command('rm foo', stderr='rm: foo: Is a directory'),
|
|
|
|
Command('hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
|
2015-11-15 18:02:37 +01:00
|
|
|
Command('./bin/hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
|
|
|
|
])
|
2015-04-25 02:54:39 +02:00
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2015-11-15 18:02:37 +01:00
|
|
|
Command('rm foo'),
|
2015-08-21 15:48:54 +01:00
|
|
|
Command('hdfs dfs -rm foo'),
|
2015-11-15 18:02:37 +01:00
|
|
|
Command('./bin/hdfs dfs -rm foo'),
|
|
|
|
Command(),
|
|
|
|
])
|
2015-04-25 02:54:39 +02:00
|
|
|
def test_not_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(command)
|
2015-04-20 12:32:32 +02:00
|
|
|
|
|
|
|
|
2015-08-21 15:48:54 +01:00
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
|
|
|
(Command('rm foo'), 'rm -rf foo'),
|
2015-11-15 18:02:37 +01:00
|
|
|
(Command('hdfs dfs -rm foo'), 'hdfs dfs -rm -r foo'),
|
|
|
|
])
|
2015-08-21 15:48:54 +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
|