Example #1
0
 def test_compat_version_1_1(self):
     network = network_obj.Network._from_db_object(self.context,
                                                   network_obj.Network(),
                                                   fake_network)
     primitive = network.obj_to_primitive(target_version='1.1')
     self.assertNotIn('mtu', primitive)
     self.assertNotIn('enable_dhcp', primitive)
     self.assertNotIn('dhcp_server', primitive)
     self.assertNotIn('share_address', primitive)
Example #2
0
 def test_save_with_host(self, get, set_host, update):
     result = dict(fake_network, injected=True)
     network = network_obj.Network._from_db_object(self.context,
                                                   network_obj.Network(),
                                                   fake_network)
     network.obj_reset_changes()
     network.host = 'foo'
     get.return_value = result
     network.save()
     set_host.assert_called_once_with(self.context, network.id, 'foo')
     self.assertFalse(update.called)
     self._compare(network, result)
Example #3
0
 def test_save(self, set_host, update):
     result = dict(fake_network, injected=True)
     network = network_obj.Network._from_db_object(self.context,
                                                   network_obj.Network(),
                                                   fake_network)
     network.obj_reset_changes()
     network.save()
     network.label = 'bar'
     update.return_value = result
     network.save()
     update.assert_called_once_with(self.context, network.id,
                                    {'label': 'bar'})
     self.assertFalse(set_host.called)
     self._compare(network, result)
Example #4
0
 def test_destroy(self, delete):
     network = network_obj.Network(context=self.context, id=123)
     network.destroy()
     delete.assert_called_once_with(self.context, 123)
     self.assertTrue(network.deleted)
     self.assertNotIn('deleted', network.obj_what_changed())
Example #5
0
 def test_create(self, create):
     create.return_value = fake_network
     network = network_obj.Network(context=self.context, label='foo')
     network.create()
     create.assert_called_once_with(self.context, {'label': 'foo'})
     self._compare(network, fake_network)