def test_del_ofn_tenant(self):
     tenant_id = "tenant_del"
     ofn_tenant_id = "ofn_tenant_del"
     ret = ndb.add_ofn_tenant(ofn_tenant_id, tenant_id)
     ret = ndb.get_ofn_tenant(tenant_id)
     self.assertTrue(ret.tenant_id == tenant_id)
     self.assertTrue(ret.ofn_tenant_id == ofn_tenant_id)
     ndb.del_ofn_tenant(tenant_id)
     ret = ndb.get_ofn_tenant(tenant_id)
     self.assertTrue(ret == None)
 def _create_ofn_tenant(self, tenant_id):
     ofn_tenant = ndb.get_ofn_tenant(tenant_id)
     if ofn_tenant:
         ofn_tenant_id = ofn_tenant.ofn_tenant_id
     else:
         if self.conf.auto_id_tenant:
             """get ofn_tenant_id from OFN."""
             res = self.ofn.ofn_create_tenant(tenant_id)
             ofn_tenant_id = res['id']
             LOG.debug("_create_ofn_tenant(): "
                       "ofn_create_tenant() return '%s'" % res)
         else:
             ofn_tenant_id = tenant_id
             """
             Don't POST it to OFC, because Sliceable DO NOT handle tenant.
             """
         LOG.debug("_create_ofn_tenant(): create new ofn_tenant %s"
                   "for tenant %s." % (tenant_id, ofn_tenant_id))
         ndb.add_ofn_tenant(ofn_tenant_id, tenant_id)
     return ofn_tenant_id