1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00
thefuck/tests/functional/plots.py

88 lines
2.5 KiB
Python
Raw Normal View History

2015-07-29 14:30:32 +01:00
def _set_confirmation(proc, require):
proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline(
u'echo "require_confirmation = {}" > ~/.thefuck/settings.py'.format(
require))
def with_confirmation(proc, TIMEOUT):
2015-07-24 06:04:49 +01:00
"""Ensures that command can be fixed when confirmation enabled."""
2015-07-29 14:30:32 +01:00
_set_confirmation(proc, True)
2015-07-25 01:22:05 +01:00
proc.sendline(u'ehco test')
2015-07-24 06:04:49 +01:00
2015-07-25 01:22:05 +01:00
proc.sendline(u'fuck')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'enter'])
assert proc.expect_exact([TIMEOUT, u'ctrl+c'])
2015-07-24 06:04:49 +01:00
proc.send('\n')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'test'])
2015-07-24 06:04:49 +01:00
def history_changed(proc, TIMEOUT, *to):
"""Ensures that history changed."""
proc.send('\033[A')
pattern = [TIMEOUT]
pattern.extend(to)
assert proc.expect(pattern)
def history_not_changed(proc, TIMEOUT):
"""Ensures that history not changed."""
proc.send('\033[A')
2015-07-27 15:51:33 +01:00
assert proc.expect([TIMEOUT, u'fuck'])
def select_command_with_arrows(proc, TIMEOUT):
2015-07-30 16:28:20 +01:00
"""Ensures that command can be selected with arrow keys."""
_set_confirmation(proc, True)
proc.sendline(u'git h')
assert proc.expect([TIMEOUT, u"git: 'h' is not a git command."])
proc.sendline(u'fuck')
assert proc.expect([TIMEOUT, u'git show'])
proc.send('\033[B')
assert proc.expect([TIMEOUT, u'git push'])
proc.send('\033[B')
assert proc.expect([TIMEOUT, u'git help', u'git hook'])
2015-07-30 16:28:20 +01:00
proc.send('\033[A')
assert proc.expect([TIMEOUT, u'git push'])
proc.send('\033[B')
assert proc.expect([TIMEOUT, u'git help', u'git hook'])
2015-07-30 16:28:20 +01:00
proc.send('\n')
assert proc.expect([TIMEOUT, u'usage', u'fatal: not a git repository'])
2015-07-30 16:28:20 +01:00
def refuse_with_confirmation(proc, TIMEOUT):
2015-07-24 21:14:58 +01:00
"""Ensures that fix can be refused when confirmation enabled."""
2015-07-29 14:30:32 +01:00
_set_confirmation(proc, True)
2015-07-25 01:22:05 +01:00
proc.sendline(u'ehco test')
2015-07-24 21:14:58 +01:00
2015-07-25 01:22:05 +01:00
proc.sendline(u'fuck')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'enter'])
assert proc.expect_exact([TIMEOUT, u'ctrl+c'])
2015-07-24 21:14:58 +01:00
proc.send('\003')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'Aborted'])
2015-07-24 21:14:58 +01:00
def without_confirmation(proc, TIMEOUT):
2015-07-24 06:04:49 +01:00
"""Ensures that command can be fixed when confirmation disabled."""
2015-07-29 14:30:32 +01:00
_set_confirmation(proc, False)
2015-07-25 01:22:05 +01:00
proc.sendline(u'ehco test')
2015-07-24 06:04:49 +01:00
2015-07-25 01:22:05 +01:00
proc.sendline(u'fuck')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'test'])
def how_to_configure(proc, TIMEOUT):
proc.sendline(u'fuck')
2015-09-06 11:40:29 +01:00
assert proc.expect([TIMEOUT, u"alias isn't configured"])