def test_get_by_filter(self): db_acc = self.fake_accelerator db_pf = self.fake_physical_function db_vf = self.fake_virtual_function acc = objects.Accelerator(context=self.context, **db_acc) acc.create(self.context) acc_get = objects.Accelerator.get(self.context, acc.uuid) pf = objects.PhysicalFunction(context=self.context, **db_pf) pf.accelerator_id = acc_get.id pf.create(self.context) pf_get = objects.PhysicalFunction.get(self.context, pf.uuid) vf = objects.VirtualFunction(context=self.context, **db_vf) vf.accelerator_id = pf_get.accelerator_id vf.create(self.context) vf_get = objects.VirtualFunction.get(self.context, vf.uuid) pf_get.add_vf(vf_get) pf_get.save(self.context) query = {"vendor": pf_get['vendor']} vf_get_list = objects.VirtualFunction.get_by_filter( self.context, query) self.assertEqual(len(vf_get_list), 1) self.assertEqual(vf_get_list[0].uuid, vf.uuid) self.assertEqual(objects.VirtualFunction, type(vf_get_list[0])) self.assertEqual(1, 1)
def test_get(self): db_pf = self.fake_physical_function db_acc = self.fake_accelerator acc = objects.Accelerator(context=self.context, **db_acc) acc.create(self.context) acc_get = objects.Accelerator.get(self.context, acc.uuid) pf = objects.PhysicalFunction(context=self.context, **db_pf) pf.accelerator_id = acc_get.id pf.create(self.context) pf_get = objects.PhysicalFunction.get(self.context, pf.uuid) self.assertEqual(pf_get.uuid, pf.uuid)
def test_destroy(self): db_pf = self.fake_physical_function db_acc = self.fake_accelerator acc = objects.Accelerator(context=self.context, **db_acc) acc.create(self.context) acc_get = objects.Accelerator.get(self.context, acc.uuid) pf = objects.PhysicalFunction(context=self.context, **db_pf) pf.accelerator_id = acc_get.id pf.create(self.context) pf_get = objects.PhysicalFunction.get(self.context, pf.uuid) self.assertEqual(db_pf['uuid'], pf_get.uuid) pf_get.destroy(self.context) self.assertRaises(exception.DeployableNotFound, objects.PhysicalFunction.get, self.context, pf_get['uuid'])
def test_add_vf(self): db_pf = self.fake_physical_function db_vf = self.fake_virtual_function db_acc = self.fake_accelerator acc = objects.Accelerator(context=self.context, **db_acc) acc.create(self.context) acc_get = objects.Accelerator.get(self.context, acc.uuid) pf = objects.PhysicalFunction(context=self.context, **db_pf) pf.accelerator_id = acc_get.id pf.create(self.context) pf_get = objects.PhysicalFunction.get(self.context, pf.uuid) vf = objects.VirtualFunction(context=self.context, **db_vf) vf.accelerator_id = pf_get.accelerator_id vf.create(self.context) vf_get = objects.VirtualFunction.get(self.context, vf.uuid) pf_get.add_vf(vf_get) pf_get.save(self.context) pf_get_2 = objects.PhysicalFunction.get(self.context, pf.uuid) self.assertEqual(db_vf['uuid'], pf_get_2.virtual_function_list[0].uuid)