1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-31 07:04:12 +00:00

#102 Use side_effect in ssh_known_host rule

This commit is contained in:
nvbn
2015-05-01 04:41:33 +02:00
parent b985dfbffc
commit 5eeb9d704c
2 changed files with 8 additions and 13 deletions

View File

@@ -2,7 +2,7 @@ import os
import pytest
from mock import Mock
from thefuck.rules.ssh_known_hosts import match, get_new_command,\
remove_offending_keys
side_effect
from tests.utils import Command
@@ -53,18 +53,14 @@ def test_match(ssh_error):
assert not match(Command('ssh'), None)
def test_remove_offending_keys(ssh_error):
def test_side_effect(ssh_error):
errormsg, path, reset, known_hosts = ssh_error
command = Command('ssh user@host', stderr=errormsg)
remove_offending_keys(command, None)
side_effect(command, None)
expected = ['123.234.567.890 asdjkasjdakjsd\n', '111.222.333.444 qwepoiwqepoiss\n']
assert known_hosts(path) == expected
def test_get_new_command(ssh_error, monkeypatch):
errormsg, _, _, _ = ssh_error
method = Mock()
monkeypatch.setattr('thefuck.rules.ssh_known_hosts.remove_offending_keys', method)
assert get_new_command(Command('ssh user@host', stderr=errormsg), None) == 'ssh user@host'
assert method.call_count