def test_exists_ofc_item(self): o, q, n = self.get_ofc_item_random_params() self.assertFalse(ndb.exists_ofc_item(self.session, 'ofc_tenant', q)) ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) self.assertTrue(ndb.exists_ofc_item(self.session, 'ofc_tenant', q)) ndb.del_ofc_item(self.session, 'ofc_tenant', q) self.assertFalse(ndb.exists_ofc_item(self.session, 'ofc_tenant', q))
def testc_del_ofc_item(self): """test delete OFC item.""" o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) ndb.del_ofc_item(self.session, 'ofc_tenant', q) tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', q) self.assertEqual(None, tenant_none) tenant_none = ndb.find_ofc_item(self.session, 'ofc_tenant', o) self.assertEqual(None, tenant_none)
def _check_exists_ofc_item(self, mode, exp_new, exp_old): o, q, n = self.get_ofc_item_random_params() self._check_new_old_item(ndb.exists_ofc_item, q, False, False) self.assertFalse(ndb.exists_ofc_item_lookup_both( self.session, 'ofc_tenant', q)) ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, mode) self._check_new_old_item(ndb.exists_ofc_item, q, exp_new, exp_old) self.assertTrue(ndb.exists_ofc_item_lookup_both( self.session, 'ofc_tenant', q)) ndb.del_ofc_item(self.session, 'ofc_tenant', q, mode) self._check_new_old_item(ndb.exists_ofc_item, q, False, False) self.assertFalse(ndb.exists_ofc_item_lookup_both( self.session, 'ofc_tenant', q))
def _check_exists_ofc_item(self, mode, exp_new, exp_old): o, q, n = self.get_ofc_item_random_params() self._check_new_old_item(ndb.exists_ofc_item, q, False, False) self.assertFalse( ndb.exists_ofc_item_lookup_both(self.session, 'ofc_tenant', q)) ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, mode) self._check_new_old_item(ndb.exists_ofc_item, q, exp_new, exp_old) self.assertTrue( ndb.exists_ofc_item_lookup_both(self.session, 'ofc_tenant', q)) ndb.del_ofc_item(self.session, 'ofc_tenant', q, mode) self._check_new_old_item(ndb.exists_ofc_item, q, False, False) self.assertFalse( ndb.exists_ofc_item_lookup_both(self.session, 'ofc_tenant', q))
def test_del_ofc_item(self): o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) self.assertTrue(ndb.del_ofc_item(self.session, 'ofc_tenant', q)) self.assertIsNone(ndb.get_ofc_item(self.session, 'ofc_tenant', q)) self.assertIsNone(ndb.find_ofc_item(self.session, 'ofc_tenant', o))
def _check_delete_ofc_item(self, mode, detect_mode=False): o, q, n = self.get_ofc_item_random_params() ret = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, mode) ofc_id = ret.ofc_id if mode == self.NEW else ret.id self.assertEqual(ofc_id, o) self.assertEqual(ret.quantum_id, q) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, mode) ofc_id = ret.ofc_id if mode == self.NEW else ret.id self.assertEqual(ofc_id, o) self.assertEqual(ret.quantum_id, q) if detect_mode: ndb.del_ofc_item_lookup_both(self.session, 'ofc_tenant', q) else: ndb.del_ofc_item(self.session, 'ofc_tenant', q, mode) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW) self.assertEqual(ret, None) ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD) self.assertEqual(ret, None)
def test_del_ofc_item_for_nonexisting_entry(self): self.assertFalse( ndb.del_ofc_item(self.session, 'ofc_tenant', 'non-existi-id'))
def _del_ofc_item(self, context, resource, neutron_id): ndb.del_ofc_item(context.session, resource, neutron_id)