def test_basic_usage_absolute_path(self): """ Basic execution. """ mock = self.ssh_cli # script to execute sd = "/root/random_script.sh" # Connect behavior mock.connect() mock_cli = mock.client # The actual mocked object: SSHClient expected_conn = {'username': '******', 'key_filename': '~/.ssh/ubuntu_ssh', 'allow_agent': False, 'hostname': 'dummy.host.org', 'look_for_keys': False, 'timeout': '600', 'port': 8822} mock_cli.connect.assert_called_once_with(**expected_conn) mock.put(sd, sd, mirror_local_mode=False) mock_cli.open_sftp().put.assert_called_once_with(sd, sd) mock.run(sd) # Make assertions over 'run' method mock_cli.get_transport().open_session().exec_command \ .assert_called_once_with(sd) mock.close()
def test_basic_usage_absolute_path(self): """ Basic execution. """ mock = self.ssh_cli # script to execute sd = "/root/random_script.sh" # Connect behavior mock.connect() mock_cli = mock.client # The actual mocked object: SSHClient expected_conn = { "username": "******", "key_filename": "~/.ssh/ubuntu_ssh", "allow_agent": False, "hostname": "dummy.host.org", "look_for_keys": False, "timeout": 28, "port": 8822, } mock_cli.connect.assert_called_once_with(**expected_conn) mock.put(sd, sd, mirror_local_mode=False) mock_cli.open_sftp().put.assert_called_once_with(sd, sd) mock.run(sd) # Make assertions over 'run' method mock_cli.get_transport().open_session( ).exec_command.assert_called_once_with(sd) mock.close()
def test_basic_usage_absolute_path(self): """ Basic execution. """ mock = self.ssh_cli # script to execute sd = "/root/random_script.sh" # Connect behavior mock.connect() mock_cli = mock.client # The actual mocked object: SSHClient expected_conn = {'username': '******', 'key_filename': '~/.ssh/ubuntu_ssh', 'allow_agent': False, 'hostname': 'dummy.host.org', 'look_for_keys': False, 'timeout': '600', 'port': 8822} mock_cli.connect.assert_called_once_with(**expected_conn) mock.put(sd, sd, mirror_local_mode=False) mock_cli.open_sftp().put.assert_called_once_with(sd, sd) mock.run(sd) # Make assertions over 'run' method mock_cli.get_transport().open_session().exec_command \ .assert_called_once_with(sd) mock.close()
def test_put(self, mock): put_data = {"role": "Manager"} response_data = {"name": "John Doe", "role": "Manager"} mock.put('{0}/endpoint/1/'.format(self.host), status_code=200, json=response_data) response = self.service.remote_call(method='PUT', api='endpoint/1/', data=put_data) self.assertEqual(response.status_code, 200) self.assertDictContainsSubset(put_data, json.loads(response.content))