2015-05-16 15:36:27 +02:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.whois import match, get_new_command
|
|
|
|
from tests.utils import Command
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('command', [
|
|
|
|
Command(script='whois https://en.wikipedia.org/wiki/Main_Page'),
|
|
|
|
Command(script='whois https://en.wikipedia.org/'),
|
2015-07-31 22:12:10 +02:00
|
|
|
Command(script='whois meta.unix.stackexchange.com')])
|
2015-05-16 15:36:27 +02:00
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(command)
|
2015-05-16 15:36:27 +02:00
|
|
|
|
|
|
|
|
2015-05-20 13:35:31 -03:00
|
|
|
def test_not_match():
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(Command(script='whois'))
|
2015-05-20 13:35:31 -03:00
|
|
|
|
|
|
|
|
2015-07-31 22:12:10 +02:00
|
|
|
# `whois com` actually makes sense
|
2015-05-16 15:36:27 +02:00
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
|
|
|
(Command('whois https://en.wikipedia.org/wiki/Main_Page'), 'whois en.wikipedia.org'),
|
|
|
|
(Command('whois https://en.wikipedia.org/'), 'whois en.wikipedia.org'),
|
2015-07-31 22:12:10 +02:00
|
|
|
(Command('whois meta.unix.stackexchange.com'), ['whois unix.stackexchange.com',
|
|
|
|
'whois stackexchange.com',
|
|
|
|
'whois com'])])
|
2015-05-16 15:36:27 +02:00
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == new_command
|