Esempio n. 1
0
def test_get_new_command(command_found):
    with patch('thefix.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'
Esempio n. 2
0
def test_match(command_found, command_not_found, settings):
    with patch('thefix.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('thefix.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)
Esempio n. 3
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)
Esempio n. 4
0
def test_get_new_command():
    assert get_new_command(Command('ls', '', ''), None) == 'sudo ls'
Esempio n. 5
0
def test_get_new_command(stderr):
    assert get_new_command(Command('', '', stderr), None)\
        == "git push --set-upstream origin master"
Esempio n. 6
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)
Esempio n. 7
0
def test_get_new_command(git_not_command):
    assert get_new_command(Command('git brnch', '', git_not_command), None)\
        == 'git branch'
Esempio n. 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)