def test_get_entity_miss_entity_no_default(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' entity = _ACLEntity(TYPE, ID) acl = self._makeOne() self.assertEqual(acl.get_entity(entity), None)
def test_has_entity_miss_entity(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' entity = _ACLEntity(TYPE, ID) acl = self._makeOne() self.assertFalse(acl.has_entity(entity))
def test_get_entity_miss_entity_w_default(self): from gcloud.storage.acl import _ACLEntity DEFAULT = object() TYPE = 'type' ID = 'id' entity = _ACLEntity(TYPE, ID) acl = self._makeOne() self.assertTrue(acl.get_entity(entity, DEFAULT) is DEFAULT)
def test_has_entity_miss_entity(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' entity = _ACLEntity(TYPE, ID) acl = self._makeOne() acl.loaded = True self.assertFalse(acl.has_entity(entity))
def test_get_entity_miss_entity_no_default(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' entity = _ACLEntity(TYPE, ID) acl = self._makeOne() acl.loaded = True self.assertEqual(acl.get_entity(entity), None)
def test_get_entity_miss_entity_w_default(self): from gcloud.storage.acl import _ACLEntity DEFAULT = object() TYPE = 'type' ID = 'id' entity = _ACLEntity(TYPE, ID) acl = self._makeOne() acl.loaded = True self.assertTrue(acl.get_entity(entity, DEFAULT) is DEFAULT)
def test_get_entity_miss_entity_no_default(self): from gcloud.storage.acl import _ACLEntity TYPE = "type" ID = "id" entity = _ACLEntity(TYPE, ID) acl = self._makeOne() acl.loaded = True self.assertEqual(acl.get_entity(entity), None)
def test_has_entity_miss_entity(self): from gcloud.storage.acl import _ACLEntity TYPE = "type" ID = "id" entity = _ACLEntity(TYPE, ID) acl = self._makeOne() acl.loaded = True self.assertFalse(acl.has_entity(entity))
def test_get_entity_miss_entity_w_default(self): from gcloud.storage.acl import _ACLEntity DEFAULT = object() TYPE = "type" ID = "id" entity = _ACLEntity(TYPE, ID) acl = self._makeOne() acl.loaded = True self.assertTrue(acl.get_entity(entity, DEFAULT) is DEFAULT)
def test_add_entity_miss(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' ROLE = 'role' entity = _ACLEntity(TYPE, ID) entity.grant(ROLE) acl = self._makeOne() acl.add_entity(entity) self.assertEqual(list(acl), [{'entity': 'type-id', 'role': ROLE}]) self.assertEqual(list(acl.get_entities()), [entity])
def test_add_entity_miss_eager(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' ROLE = 'role' entity = _ACLEntity(TYPE, ID) entity.grant(ROLE) acl = self._makeOne() acl.loaded = True acl.add_entity(entity) self.assertTrue(acl.loaded) self.assertEqual(list(acl), [{'entity': 'type-id', 'role': ROLE}]) self.assertEqual(list(acl.get_entities()), [entity])
def test_add_entity_miss_eager(self): from gcloud.storage.acl import _ACLEntity TYPE = "type" ID = "id" ROLE = "role" entity = _ACLEntity(TYPE, ID) entity.grant(ROLE) acl = self._makeOne() acl.loaded = True acl.add_entity(entity) self.assertTrue(acl.loaded) self.assertEqual(list(acl), [{"entity": "type-id", "role": ROLE}]) self.assertEqual(list(acl.get_entities()), [entity])
def test_add_entity_hit(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' KEY = '%s-%s' % (TYPE, ID) ROLE = 'role' entity = _ACLEntity(TYPE, ID) entity.grant(ROLE) acl = self._makeOne() before = acl.entity(TYPE, ID) acl.add_entity(entity) self.assertFalse(acl.get_entity(KEY) is before) self.assertTrue(acl.get_entity(KEY) is entity) self.assertEqual(list(acl), [{'entity': 'type-id', 'role': ROLE}]) self.assertEqual(list(acl.get_entities()), [entity])
def test_add_entity_hit(self): from gcloud.storage.acl import _ACLEntity TYPE = 'type' ID = 'id' KEY = '%s-%s' % (TYPE, ID) ROLE = 'role' entity = _ACLEntity(TYPE, ID) entity.grant(ROLE) acl = self._makeOne() acl.loaded = True before = acl.entity(TYPE, ID) acl.add_entity(entity) self.assertTrue(acl.loaded) self.assertFalse(acl.get_entity(KEY) is before) self.assertTrue(acl.get_entity(KEY) is entity) self.assertEqual(list(acl), [{'entity': 'type-id', 'role': ROLE}]) self.assertEqual(list(acl.get_entities()), [entity])
def test_add_entity_hit(self): from gcloud.storage.acl import _ACLEntity TYPE = "type" ID = "id" ENTITY_VAL = "%s-%s" % (TYPE, ID) ROLE = "role" entity = _ACLEntity(TYPE, ID) entity.grant(ROLE) acl = self._makeOne() acl.loaded = True before = acl.entity(TYPE, ID) acl.add_entity(entity) self.assertTrue(acl.loaded) self.assertFalse(acl.get_entity(ENTITY_VAL) is before) self.assertTrue(acl.get_entity(ENTITY_VAL) is entity) self.assertEqual(list(acl), [{"entity": "type-id", "role": ROLE}]) self.assertEqual(list(acl.get_entities()), [entity])