2015-04-21 06:26:15 +02:00
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
import pytest
|
2019-10-19 22:03:21 +09:00
|
|
|
|
2015-04-21 06:26:15 +02:00
|
|
|
from thefuck.rules import switch_lang
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-04-21 06:26:15 +02:00
|
|
|
|
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command(u'фзе-пуе', 'command not found: фзе-пуе'),
|
2018-01-29 09:46:18 +02:00
|
|
|
Command(u'λσ', 'command not found: λσ'),
|
|
|
|
Command(u'שפא-עקא', 'command not found: שפא-עקא'),
|
2019-10-19 22:03:21 +09:00
|
|
|
Command(u'ךד', 'command not found: ךד'),
|
|
|
|
Command(u'녀애 ㅣㄴ', 'command not found: 녀애 ㅣㄴ')])
|
2015-04-25 02:54:39 +02:00
|
|
|
def test_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert switch_lang.match(command)
|
2015-04-21 22:09:48 +02:00
|
|
|
|
2015-04-21 06:26:15 +02:00
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
@pytest.mark.parametrize('command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
Command(u'pat-get', 'command not found: pat-get'),
|
|
|
|
Command(u'ls', 'command not found: ls'),
|
|
|
|
Command(u'агсл', 'command not found: агсл'),
|
2018-01-29 09:46:18 +02:00
|
|
|
Command(u'фзе-пуе', 'some info'),
|
2019-10-19 22:03:21 +09:00
|
|
|
Command(u'שפא-עקא', 'some info'),
|
|
|
|
Command(u'녀애 ㅣㄴ', 'some info')])
|
2015-04-25 02:54:39 +02:00
|
|
|
def test_not_match(command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not switch_lang.match(command)
|
2015-04-21 06:26:15 +02:00
|
|
|
|
2015-04-25 02:54:39 +02:00
|
|
|
|
|
|
|
@pytest.mark.parametrize('command, new_command', [
|
2017-08-31 17:58:56 +02:00
|
|
|
(Command(u'фзе-пуе штыефдд мшь', ''), 'apt-get install vim'),
|
2018-01-29 09:46:18 +02:00
|
|
|
(Command(u'λσ -λα', ''), 'ls -la'),
|
|
|
|
(Command(u'שפא-עקא ןמדאשךך הןצ', ''), 'apt-get install vim'),
|
2019-10-19 22:03:21 +09:00
|
|
|
(Command(u'ךד -ךש', ''), 'ls -la'),
|
|
|
|
(Command(u'멧-ㅎㄷㅅ ㅑㅜㄴㅅ미ㅣ 퍄ㅡ', ''), 'apt-get install vim'),
|
|
|
|
(Command(u'ㅣㄴ -ㅣㅁ', ''), 'ls -la'),
|
|
|
|
(Command(u'ㅔㅁㅅ촤', ''), 'patchk'), ])
|
2015-04-25 02:54:39 +02:00
|
|
|
def test_get_new_command(command, new_command):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert switch_lang.get_new_command(command) == new_command
|