2015-07-24 03:56:21 +03:00
|
|
|
import pytest
|
2015-07-25 03:22:05 +03:00
|
|
|
from tests.functional.plots import with_confirmation, without_confirmation, \
|
2015-09-06 13:29:42 +03:00
|
|
|
refuse_with_confirmation, history_changed, history_not_changed, \
|
|
|
|
select_command_with_arrows, how_to_configure
|
2015-07-24 03:56:21 +03:00
|
|
|
|
2017-09-01 07:10:16 +02:00
|
|
|
|
|
|
|
python_3 = ('thefuck/python3-zsh',
|
|
|
|
u'''FROM python:3
|
|
|
|
RUN apt-get update
|
|
|
|
RUN apt-get install -yy zsh''',
|
|
|
|
u'sh')
|
|
|
|
|
|
|
|
python_2 = ('thefuck/python2-zsh',
|
|
|
|
u'''FROM python:2
|
|
|
|
RUN apt-get update
|
|
|
|
RUN apt-get install -yy zsh''',
|
|
|
|
u'sh')
|
|
|
|
|
|
|
|
|
|
|
|
init_zshrc = u'''echo '
|
|
|
|
export SHELL=/usr/bin/zsh
|
|
|
|
export HISTFILE=~/.zsh_history
|
|
|
|
echo > $HISTFILE
|
|
|
|
export SAVEHIST=100
|
|
|
|
export HISTSIZE=100
|
|
|
|
eval $(thefuck --alias {})
|
|
|
|
setopt INC_APPEND_HISTORY
|
2017-10-08 17:16:15 +02:00
|
|
|
echo "instant mode ready: $THEFUCK_INSTANT_MODE"
|
2017-09-01 07:10:16 +02:00
|
|
|
' > ~/.zshrc'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=[(python_3, False),
|
|
|
|
(python_3, True),
|
|
|
|
(python_2, False)])
|
2016-08-13 14:50:21 +03:00
|
|
|
def proc(request, spawnu, TIMEOUT):
|
2017-09-01 07:10:16 +02:00
|
|
|
container, instant_mode = request.param
|
|
|
|
proc = spawnu(*container)
|
2016-08-13 14:11:18 +03:00
|
|
|
proc.sendline(u'pip install /src')
|
2016-08-13 14:50:21 +03:00
|
|
|
assert proc.expect([TIMEOUT, u'Successfully installed'])
|
2017-09-01 07:10:16 +02:00
|
|
|
proc.sendline(init_zshrc.format(
|
|
|
|
u'--enable-experimental-instant-mode' if instant_mode else ''))
|
|
|
|
proc.sendline(u"zsh")
|
2017-10-08 17:16:15 +02:00
|
|
|
if instant_mode:
|
|
|
|
assert proc.expect([TIMEOUT, u'instant mode ready: True'])
|
2015-07-29 16:30:32 +03:00
|
|
|
return proc
|
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2015-09-06 00:56:18 +03:00
|
|
|
def test_with_confirmation(proc, TIMEOUT):
|
|
|
|
with_confirmation(proc, TIMEOUT)
|
|
|
|
history_changed(proc, TIMEOUT, u'echo test')
|
2015-07-30 18:28:20 +03:00
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2015-09-06 00:56:18 +03:00
|
|
|
def test_select_command_with_arrows(proc, TIMEOUT):
|
|
|
|
select_command_with_arrows(proc, TIMEOUT)
|
2015-09-06 01:24:29 +03:00
|
|
|
history_changed(proc, TIMEOUT, u'git help')
|
2015-07-24 03:56:21 +03:00
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2015-09-06 00:56:18 +03:00
|
|
|
def test_refuse_with_confirmation(proc, TIMEOUT):
|
|
|
|
refuse_with_confirmation(proc, TIMEOUT)
|
|
|
|
history_not_changed(proc, TIMEOUT)
|
2015-07-24 23:14:58 +03:00
|
|
|
|
|
|
|
|
2015-09-06 01:13:44 +03:00
|
|
|
@pytest.mark.functional
|
2015-09-06 00:56:18 +03:00
|
|
|
def test_without_confirmation(proc, TIMEOUT):
|
|
|
|
without_confirmation(proc, TIMEOUT)
|
|
|
|
history_changed(proc, TIMEOUT, u'echo test')
|
2015-09-06 13:29:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.functional
|
|
|
|
def test_how_to_configure_alias(proc, TIMEOUT):
|
2017-03-28 12:28:34 +02:00
|
|
|
proc.sendline(u'unfunction fuck')
|
2015-09-06 13:29:42 +03:00
|
|
|
how_to_configure(proc, TIMEOUT)
|