def test_interface_update(self): interface = dbapi.net_interfaces_create(self.context, net_interface1) res = dbapi.net_interfaces_get_by_id(self.context, interface.id) self.assertEqual(res.name, 'eth1') new_name = 'eth2' res = dbapi.net_interfaces_update(self.context, interface.id, {'name': 'eth2'}) self.assertEqual(res.name, new_name)
def test_interface_delete(self): interface = dbapi.net_interfaces_create(self.context, net_interface1) # First make sure we have the interface created res = dbapi.net_interfaces_get_by_id(self.context, interface.id) self.assertEqual(res.id, interface.id) # Delete the device dbapi.net_interfaces_delete(self.context, res.id) self.assertRaises(exceptions.NotFound, dbapi.net_interfaces_get_by_id, self.context, res.id)
def test_interface_get_by_id(self): interface = dbapi.net_interfaces_create(self.context, net_interface1) res = dbapi.net_interfaces_get_by_id(self.context, interface.id) self.assertEqual(res.name, 'eth1')
def test_interface_get_all(self): dbapi.net_interfaces_create(self.context, net_interface1) filters = {} res = dbapi.net_interfaces_get_by_device(self.context, 1, filters) self.assertEqual(len(res), 1) self.assertEqual(res[0]['name'], 'eth1')
def test_interface_create(self): try: dbapi.net_interfaces_create(self.context, net_interface1) except Exception: self.fail("Network interface create raised unexpected exception")