コード例 #1
0
def test_match():
    assert match(
        Command('mkdir foo/bar/baz', '',
                'mkdir: foo/bar: No such file or directory'), None)
    assert not match(Command('mkdir foo/bar/baz', '', ''), None)
    assert not match(Command('mkdir foo/bar/baz', '', 'foo bar baz'), None)
    assert not match(Command('', '', ''), None)
コード例 #2
0
def test_get_new_command(command_found):
    with patch('thefuck.rules.no_command._get_output',
               return_value=command_found.decode()):
        assert get_new_command(Command('aptget install vim', '', ''), settings)\
            == 'apt-get install vim'
        assert get_new_command(Command('sudo aptget install vim', '', ''), settings) \
            == 'sudo apt-get install vim'
コード例 #3
0
def test_match(command_found, command_not_found, settings):
    with patch('thefuck.rules.no_command.Popen') as Popen:
        Popen.return_value.stderr.read.return_value = command_found
        assert match(Command('aptget install vim', '', ''), settings)
        Popen.assert_called_once_with('/usr/lib/command-not-found aptget',
                                      shell=True,
                                      stderr=PIPE)
        Popen.return_value.stderr.read.return_value = command_not_found
        assert not match(Command('ls', '', ''), settings)

    with patch('thefuck.rules.no_command.Popen') as Popen:
        Popen.return_value.stderr.read.return_value = command_found
        assert match(Command('sudo aptget install vim', '', ''),
                     Mock(command_not_found='test'))
        Popen.assert_called_once_with('test aptget', shell=True, stderr=PIPE)
コード例 #4
0
def test_remove_offending_keys(ssh_error):
    errormsg, path, reset, known_hosts = ssh_error
    command = Command('ssh user@host', '', errormsg)
    remove_offending_keys(command, None)
    expected = [
        '123.234.567.890 asdjkasjdakjsd\n', '111.222.333.444 qwepoiwqepoiss\n'
    ]
    assert known_hosts(path) == expected
コード例 #5
0
def test_get_new_command(ssh_error, monkeypatch):
    errormsg, _, _, _ = ssh_error

    method = Mock()
    monkeypatch.setattr('thefuck.rules.ssh_known_hosts.remove_offending_keys',
                        method)
    assert get_new_command(Command('ssh user@host', '', errormsg),
                           None) == 'ssh user@host'
    assert method.call_count
コード例 #6
0
def test_match(ssh_error):
    errormsg, _, _, _ = ssh_error
    assert match(Command('ssh', '', errormsg), None)
    assert match(Command('ssh', '', errormsg), None)
    assert match(Command('scp something something', '', errormsg), None)
    assert match(Command('scp something something', '', errormsg), None)
    assert not match(Command('', '', errormsg), None)
    assert not match(Command('notssh', '', errormsg), None)
    assert not match(Command('ssh', '', ''), None)
コード例 #7
0
def test_get_new_command(git_not_command):
    assert get_new_command(Command('git brnch', '', git_not_command), None)\
        == 'git branch'
コード例 #8
0
def test_match(git_not_command, git_command):
    assert match(Command('git brnch', '', git_not_command), None)
    assert not match(Command('ls brnch', '', git_not_command), None)
    assert not match(Command('git branch', '', git_command), None)
コード例 #9
0
def test_match():
    assert match(Command('cd..', '', 'cd..: command not found'), None)
    assert not match(Command('', '', ''), None)
コード例 #10
0
def test_get_new_command():
    assert get_new_command(Command('cd..', '', ''), None) == 'cd ..'
コード例 #11
0
def test_match():
    assert match(Command('', '', 'Permission denied'), None)
    assert match(Command('', '', 'permission denied'), None)
    assert match(Command('', '', "npm ERR! Error: EACCES, unlink"), None)
    assert not match(Command('', '', ''), None)
コード例 #12
0
def test_get_new_command():
    assert get_new_command(Command('ls', '', ''), None) == 'sudo ls'
コード例 #13
0
def test_get_new_command(git_not_command, git_not_command_one_of_this):
    assert get_new_command(Command('git brnch', '', git_not_command), None)\
        == 'git branch'
    assert get_new_command(
        Command('git st', '', git_not_command_one_of_this), None) == 'git status'
コード例 #14
0
def test_match(git_not_command, git_command, git_not_command_one_of_this):
    assert match(Command('git brnch', '', git_not_command), None)
    assert match(Command('git st', '', git_not_command_one_of_this), None)
    assert not match(Command('ls brnch', '', git_not_command), None)
    assert not match(Command('git branch', '', git_command), None)
コード例 #15
0
def test_match(stderr):
    assert match(Command('git push master', '', stderr), None)
    assert not match(Command('git push master', '', ''), None)
    assert not match(Command('ls', '', stderr), None)
コード例 #16
0
ファイル: test_rm_dir.py プロジェクト: ashleygwilliams/oops
def test_get_new_command():
    assert get_new_command(Command('rm foo', '', ''), None) == 'rm -rf foo'
コード例 #17
0
def test_get_new_command():
    assert get_new_command(Command('./test_sudo.py', '', ''),
                           None) == 'python ./test_sudo.py'
コード例 #18
0
def test_match():
    assert match(Command('temp.py', '', 'Permission denied'), None)
    assert not match(Command('', '', ''), None)
コード例 #19
0
def test_get_new_command(stderr):
    assert get_new_command(Command('', '', stderr), None)\
        == "git push --set-upstream origin master"
コード例 #20
0
ファイル: test_rm_dir.py プロジェクト: ashleygwilliams/oops
def test_match():
    assert match(Command('rm foo', '', 'rm: foo: is a directory'), None)
    assert not match(Command('rm foo', '', ''), None)
    assert not match(Command('rm foo', '', 'foo bar baz'), None)
    assert not match(Command('', '', ''), None)
コード例 #21
0
def test_get_new_command():
    assert get_new_command(Command('mkdir foo/bar/baz', '', ''),
                           None) == 'mkdir -p foo/bar/baz'