Merge "Do not try to return mock as JSON in unit tests"
This commit is contained in:
commit
5edf4f3fda
@ -1856,20 +1856,24 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
self.assertTrue(ret.json['error_message'])
|
||||
mock_gsbd.assert_called_once_with(mock.ANY, node.uuid, 'test-topic')
|
||||
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces')
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces',
|
||||
autospec=True, return_value={})
|
||||
def test_validate_by_uuid_using_deprecated_interface(self, mock_vdi):
|
||||
# Note(mrda): The 'node_uuid' interface is deprecated in favour
|
||||
# of the 'node' interface
|
||||
node = obj_utils.create_test_node(self.context)
|
||||
self.get_json('/nodes/validate?node_uuid=%s' % node.uuid)
|
||||
mock_vdi.assert_called_once_with(mock.ANY, node.uuid, 'test-topic')
|
||||
mock_vdi.assert_called_once_with(mock.ANY, mock.ANY,
|
||||
node.uuid, 'test-topic')
|
||||
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces')
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces',
|
||||
autospec=True, return_value={})
|
||||
def test_validate_by_uuid(self, mock_vdi):
|
||||
node = obj_utils.create_test_node(self.context)
|
||||
self.get_json('/nodes/validate?node=%s' % node.uuid,
|
||||
headers={api_base.Version.string: "1.5"})
|
||||
mock_vdi.assert_called_once_with(mock.ANY, node.uuid, 'test-topic')
|
||||
mock_vdi.assert_called_once_with(mock.ANY, mock.ANY,
|
||||
node.uuid, 'test-topic')
|
||||
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces')
|
||||
def test_validate_by_name_unsupported(self, mock_vdi):
|
||||
@ -1879,14 +1883,16 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
self.assertEqual(http_client.NOT_ACCEPTABLE, ret.status_code)
|
||||
self.assertFalse(mock_vdi.called)
|
||||
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces')
|
||||
@mock.patch.object(rpcapi.ConductorAPI, 'validate_driver_interfaces',
|
||||
autospec=True, return_value={})
|
||||
def test_validate_by_name(self, mock_vdi):
|
||||
node = obj_utils.create_test_node(self.context, name='spam')
|
||||
self.get_json('/nodes/validate?node=%s' % node.name,
|
||||
headers={api_base.Version.string: "1.5"})
|
||||
# note that this should be node.uuid here as we get that from the
|
||||
# rpc_node lookup and pass that downwards
|
||||
mock_vdi.assert_called_once_with(mock.ANY, node.uuid, 'test-topic')
|
||||
mock_vdi.assert_called_once_with(mock.ANY, mock.ANY,
|
||||
node.uuid, 'test-topic')
|
||||
|
||||
def test_ssh_creds_masked(self):
|
||||
driver_info = {"ssh_password": "password", "ssh_key_contents": "key"}
|
||||
|
@ -836,15 +836,17 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(http_client.FORBIDDEN, response.status_int)
|
||||
|
||||
@mock.patch.object(api_port.PortsController, '_get_ports_collection')
|
||||
@mock.patch.object(api_port.PortsController, '_get_ports_collection',
|
||||
autospec=True)
|
||||
def test_detail_with_incorrect_api_usage(self, mock_gpc):
|
||||
mock_gpc.return_value = api_port.PortCollection.convert_with_links(
|
||||
[], 0)
|
||||
# GET /v1/ports/detail specifying node and node_uuid. In this case
|
||||
# we expect the node_uuid interface to be used.
|
||||
self.get_json('/ports/detail?node=%s&node_uuid=%s' %
|
||||
('test-node', self.node.uuid))
|
||||
mock_gpc.assert_called_once_with(self.node.uuid, mock.ANY, mock.ANY,
|
||||
mock.ANY, mock.ANY, mock.ANY,
|
||||
mock.ANY, mock.ANY)
|
||||
self.assertEqual(1, mock_gpc.call_count)
|
||||
self.assertEqual(self.node.uuid, mock_gpc.call_args[0][1])
|
||||
|
||||
def test_portgroups_subresource_node_not_found(self):
|
||||
non_existent_uuid = 'eeeeeeee-cccc-aaaa-bbbb-cccccccccccc'
|
||||
|
Loading…
Reference in New Issue
Block a user