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 testb_exists_ofc_item(self): """test get OFC d.""" o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) ret = ndb.exists_ofc_item(self.session, 'ofc_tenant', q) self.assertTrue(ret) tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n) self.assertEqual(None, tenant_none)
def test_exists_ofc_port(self): t, n, p, f, none = self.get_random_params() ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params() self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p)) session = self.ctx.session ndb.add_ofc_item(session, 'ofc_port', p, ofc_p, old_style=True) self.assertTrue(self.ofc.exists_ofc_port(self.ctx, p))
def testb_get_ofc_id(self): """test get OFC d.""" o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) tenant_id = ndb.get_ofc_id(self.session, 'ofc_tenant', q) self.assertEqual(tenant_id, o) tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n) self.assertEqual(None, tenant_none)
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_find_ofc_item(self): """test find OFC item.""" o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) tenant = ndb.find_ofc_item(self.session, 'ofc_tenant', o) self.assertEqual(tenant.ofc_id, o) self.assertEqual(tenant.quantum_id, q) tenant_none = ndb.find_ofc_item(self.session, 'ofc_tenant', n) self.assertEqual(None, tenant_none)
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 test_delete_ofc_port(self): t, n, p, f, none = self.get_random_params() ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params() self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p)) session = self.ctx.session ndb.add_ofc_item(session, 'ofc_port', p, ofc_p, old_style=True) self.assertTrue(self.ofc.exists_ofc_port(self.ctx, p)) port = {'tenant_id': t, 'network_id': n} self.ofc.delete_ofc_port(self.ctx, p, port) self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p))
def test_delete_ofc_packet_filter(self): t, n, p, f, none = self.get_random_params() ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params() self.assertFalse(self.ofc.exists_ofc_packet_filter(self.ctx, f)) session = self.ctx.session ndb.add_ofc_item(session, 'ofc_packet_filter', f, ofc_f, old_style=True) self.assertTrue(self.ofc.exists_ofc_packet_filter(self.ctx, f)) self.ofc.delete_ofc_packet_filter(self.ctx, f) self.assertFalse(self.ofc.exists_ofc_packet_filter(self.ctx, f))
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 testa_add_ofc_item(self): """test add OFC item.""" o, q, n = self.get_ofc_item_random_params() tenant = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) self.assertEqual(tenant.ofc_id, o) self.assertEqual(tenant.quantum_id, q) self.assertRaises(nexc.NECDBException, ndb.add_ofc_item, self.session, 'ofc_tenant', q, o)
def test_add_ofc_item_old(self): o, q, n = self.get_ofc_item_random_params() ret = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, self.OLD) self.assertEqual(ret.id, o) self.assertEqual(ret.quantum_id, q) 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.id, o) self.assertEqual(ret.quantum_id, q)
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_add_ofc_item_duplicate_entry(self): o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) self.assertRaises(nexc.NECDBException, ndb.add_ofc_item, self.session, 'ofc_tenant', q, o)
def test_add_ofc_item(self): """test add OFC item.""" o, q, n = self.get_ofc_item_random_params() tenant = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) self.assertEqual(tenant.ofc_id, o) self.assertEqual(tenant.quantum_id, q)
def test_add_ofc_item(self): """test add OFC item.""" o, q, n = self.get_ofc_item_random_params() tenant = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) self.assertEqual(tenant.ofc_id, o) self.assertEqual(tenant.neutron_id, q)
def test_find_ofc_item(self): o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) tenant = ndb.find_ofc_item(self.session, 'ofc_tenant', o) self.assertEqual(tenant.ofc_id, o) self.assertEqual(tenant.quantum_id, q)
def _add_ofc_item(self, context, resource, neutron_id, ofc_id): # Ensure a new item is added to the new mapping table ndb.add_ofc_item(context.session, resource, neutron_id, ofc_id)
def test_find_ofc_item(self): o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) tenant = ndb.find_ofc_item(self.session, 'ofc_tenant', o) self.assertEqual(tenant.ofc_id, o) self.assertEqual(tenant.neutron_id, q)
def test_get_ofc_id(self): o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o) tenant_id = ndb.get_ofc_id(self.session, 'ofc_tenant', q) self.assertEqual(tenant_id, o)
def test_get_ofc_id_old(self): o, q, n = self.get_ofc_item_random_params() ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, self.OLD) self._check_new_old_item(ndb.get_ofc_id, q, None, o) ret = ndb.get_ofc_id_lookup_both(self.session, 'ofc_tenant', q) self.assertEqual(ret, o)