Пример #1
0
 def test_set_network_host_network_object_to_primitive(self):
     # Tests that the network object is converted to a primitive if it
     # can't send version 1.15.
     ctxt = context.RequestContext('fake_user', 'fake_project')
     network = fake_network.fake_network_obj(ctxt)
     network_dict = objects_base.obj_to_primitive(network)
     rpcapi = network_rpcapi.NetworkAPI()
     call_mock = mock.Mock()
     cctxt_mock = mock.Mock(call=call_mock)
     with test.nested(
         mock.patch.object(rpcapi.client, 'can_send_version',
                           return_value=False),
         mock.patch.object(rpcapi.client, 'prepare',
                           return_value=cctxt_mock)
     ) as (
         can_send_mock, prepare_mock
     ):
         rpcapi.set_network_host(ctxt, network)
     # assert our mocks were called as expected
     can_send_mock.assert_called_once_with('1.15')
     prepare_mock.assert_called_once_with(version='1.0')
     call_mock.assert_called_once_with(ctxt, 'set_network_host',
                                       network_ref=network_dict)
Пример #2
0
 def test_set_network_host_network_object_to_primitive(self):
     # Tests that the network object is converted to a primitive if it
     # can't send version 1.15.
     ctxt = context.RequestContext('fake_user', 'fake_project')
     network = fake_network.fake_network_obj(ctxt)
     network_dict = objects_base.obj_to_primitive(network)
     rpcapi = network_rpcapi.NetworkAPI()
     call_mock = mock.Mock()
     cctxt_mock = mock.Mock(call=call_mock)
     with test.nested(
         mock.patch.object(rpcapi.client, 'can_send_version',
                           return_value=False),
         mock.patch.object(rpcapi.client, 'prepare',
                           return_value=cctxt_mock)
     ) as (
         can_send_mock, prepare_mock
     ):
         rpcapi.set_network_host(ctxt, network)
     # assert our mocks were called as expected
     can_send_mock.assert_called_once_with('1.15')
     prepare_mock.assert_called_once_with(version='1.0')
     call_mock.assert_called_once_with(ctxt, 'set_network_host',
                                       network_ref=network_dict)
Пример #3
0
 def test_set_network_host(self):
     network = fake_network.fake_network_obj(context.get_admin_context())
     self._test_network_api('set_network_host',
                            rpc_method='call',
                            network_ref=network,
                            version='1.15')
Пример #4
0
 def test_set_network_host(self):
     network = fake_network.fake_network_obj(context.get_admin_context())
     self._test_network_api('set_network_host', rpc_method='call',
                            network_ref=network, version='1.15')