def test_add2(self): with mock.patch('sshx.utils.read_password', return_value=PASSWORD1) as m_read_password: with mock.patch('sshx.sshx.handle_add') as m: sshx.invoke([ 'add', NAME1, '-l', '%s@%s:%s' % (USER1, HOST1, PORT1), '-p', '-i', IDENTITY1 ]) m_read_password.assert_called_once() m.assert_called_with(NAME1, HOST1, port=PORT1, user=USER1, password=PASSWORD1, identity=IDENTITY1, via='') with mock.patch('sshx.utils.read_password', return_value=PASSWORD1) as m_read_password: with mock.patch('sshx.sshx.handle_add') as m: sshx.invoke([ 'add', NAME1, '-l', '%s@%s' % (USER1, HOST1), '-p', '-i', IDENTITY1 ]) m_read_password.assert_called_once() m.assert_called_with(NAME1, HOST1, port=c.DEFAULT_PORT, user=USER1, password=PASSWORD1, identity=IDENTITY1, via='')
def test_init(self): with mock.patch('sshx.sshx.handle_init') as m: sshx.invoke([ 'init', ]) m.assert_called_with(force=False) sshx.invoke(['init', '--force']) m.assert_called_with(force=True)
def test_update(self): with mock.patch('sshx.utils.read_password', return_value=PASSWORD2) as m_read_password: with mock.patch('sshx.sshx.handle_update') as m: sshx.invoke(['update', NAME1, '-H', HOST1]) m.assert_called_with(NAME1, update_fields={ 'host': HOST1, }) sshx.invoke([ 'update', NAME1, '-H', HOST1, '-P', PORT1, '-u', USER1, '-p', '-i', IDENTITY1, '-v', NAME2 ]) m_read_password.assert_called_once() m.assert_called_with(NAME1, update_fields={ 'host': HOST1, 'port': PORT1, 'user': USER1, 'password': PASSWORD2, 'identity': IDENTITY1, 'via': NAME2, })
def test_connect(self): with mock.patch('sshx.sshx.handle_connect') as m: sshx.invoke(['connect', NAME1]) m.assert_called_with(NAME1, via=None)
def test_del(self): with mock.patch('sshx.sshx.handle_del') as m: sshx.invoke(['del', NAME1]) m.assert_called_with(NAME1)