def test_set_auth_variable(self): ssh_host = HostSSH( address='fake_addres', username='******', password='******', private_key='' ) self.assertDictEqual( { 'username': '******', 'password': '******' }, ssh_host.auth ) ssh_host = HostSSH( address='fake_addres', username='******', password='', private_key='fake_pkey' ) self.assertDictEqual( { 'username': '******', 'pkey': 'fake_pkey' }, ssh_host.auth )
def test_raise_exception_if_dont_have_pass_and_pkey(self): with self.assertRaises(PassAndPkeyEmptyException): HostSSH( address='fake_addres', username='******', password='', private_key='' )
def setUp(self): self.host_ssh = HostSSH(address='fake_address', username='******', password='******') self.host_ssh.connect = MagicMock() self.fake_client = PropertyMock() self.fake_client.exec_command.side_effect = ( make_fake_exec_command_output) self.host_ssh.client = self.fake_client
def setUp(self): self.host_ssh = HostSSH(address='fake_address', username='******', password='******') self.fake_func = MagicMock( return_value={ 'stdout': 'fake_stdout', 'stdin': 'fake_stdin', 'stderr': 'fake_stderr', 'exception': '', }) self.decorated = connect_host(self.fake_func)