2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2015-04-08 18:15:49 +02:00
|
|
|
from thefuck.rules.sudo import match, get_new_command
|
2015-04-25 02:35:26 +02:00
|
|
|
from tests.utils import Command
|
2015-04-08 18:15:49 +02:00
|
|
|
|
|
|
|
|
2015-04-29 05:01:30 +02:00
|
|
|
@pytest.mark.parametrize('stderr, stdout', [
|
|
|
|
('Permission denied', ''),
|
|
|
|
('permission denied', ''),
|
|
|
|
("npm ERR! Error: EACCES, unlink", ''),
|
|
|
|
('requested operation requires superuser privilege', ''),
|
2015-06-15 17:08:08 -07:00
|
|
|
('need to be root', ''),
|
|
|
|
('need root', ''),
|
|
|
|
('must be root', ''),
|
2015-07-21 06:49:56 +00:00
|
|
|
('You don\'t have access to the history DB.', ''),
|
2015-04-29 05:01:30 +02:00
|
|
|
('', "error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/ipaddr.py'")])
|
|
|
|
def test_match(stderr, stdout):
|
|
|
|
assert match(Command(stderr=stderr, stdout=stdout), None)
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_not_match():
|
2015-04-25 02:35:26 +02:00
|
|
|
assert not match(Command(), None)
|
2015-04-08 18:15:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command():
|
2015-04-25 02:35:26 +02:00
|
|
|
assert get_new_command(Command('ls'), None) == 'sudo ls'
|