2015-07-26 00:59:18 +01:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.tsuru_login import match, get_new_command
|
2017-08-31 16:58:56 +01:00
|
|
|
from thefuck.types import Command
|
2015-07-26 00:59:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
error_msg = (
|
|
|
|
"Error: you're not authenticated or your session has expired.",
|
|
|
|
("You're not authenticated or your session has expired. "
|
|
|
|
"Please use \"login\" command for authentication."),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 16:58:56 +01:00
|
|
|
Command('tsuru app-shell', error_msg[0]),
|
|
|
|
Command('tsuru app-log -f', error_msg[1]),
|
2015-07-26 00:59:18 +01:00
|
|
|
])
|
|
|
|
def test_match(command):
|
2015-09-07 11:00:29 +01:00
|
|
|
assert match(command)
|
2015-07-26 00:59:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 16:58:56 +01:00
|
|
|
Command('tsuru', ''),
|
|
|
|
Command('tsuru app-restart', 'Error: unauthorized'),
|
|
|
|
Command('tsuru app-log -f', 'Error: unparseable data'),
|
2015-07-26 00:59:18 +01:00
|
|
|
])
|
|
|
|
def test_not_match(command):
|
2015-09-07 11:00:29 +01:00
|
|
|
assert not match(command)
|
2015-07-26 00:59:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2017-08-31 16:58:56 +01:00
|
|
|
(Command('tsuru app-shell', error_msg[0]),
|
2015-07-26 00:59:18 +01:00
|
|
|
'tsuru login && tsuru app-shell'),
|
2017-08-31 16:58:56 +01:00
|
|
|
(Command('tsuru app-log -f', error_msg[1]),
|
2015-07-26 00:59:18 +01:00
|
|
|
'tsuru login && tsuru app-log -f'),
|
|
|
|
])
|
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 11:00:29 +01:00
|
|
|
assert get_new_command(command) == new_command
|