File: test_unknown_command.py

package info (click to toggle)
thefuck 3.32-0.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: python: 12,011; makefile: 5; sh: 2
file content (34 lines) | stat: -rw-r--r-- 1,612 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from thefuck.rules.unknown_command import match, get_new_command
from thefuck.types import Command


@pytest.mark.parametrize('command', [
    Command('./bin/hdfs dfs ls', 'ls: Unknown command\nDid you mean -ls?  This command begins with a dash.'),
    Command('hdfs dfs ls',
            'ls: Unknown command\nDid you mean -ls?  This command begins with a dash.'),
    Command('hdfs dfs ls /foo/bar', 'ls: Unknown command\nDid you mean -ls?  This command begins with a dash.')])
def test_match(command):
    assert match(command)


@pytest.mark.parametrize('command', [
    Command('./bin/hdfs dfs -ls', ''),
    Command('./bin/hdfs dfs -ls /foo/bar', ''),
    Command('hdfs dfs -ls -R /foo/bar', ''),
    Command('', '')])
def test_not_match(command):
    assert not match(command)


@pytest.mark.parametrize('command, new_command', [
    (Command('hdfs dfs ls',
             'ls: Unknown command\nDid you mean -ls?  This command begins with a dash.'), ['hdfs dfs -ls']),
    (Command('hdfs dfs rm /foo/bar',
             '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',
             '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',
             'ls: Unknown command\nDid you mean -ls?  This command begins with a dash.'), ['./bin/hdfs dfs -Dtest=fred -ls -R /foo/bar'])])
def test_get_new_command(command, new_command):
    assert get_new_command(command) == new_command