Beispiel #1
0
 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)
Beispiel #2
0
 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))
Beispiel #3
0
 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)
Beispiel #4
0
 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))
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
    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)
Beispiel #8
0
    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))
Beispiel #9
0
    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)
Beispiel #10
0
 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])
Beispiel #11
0
 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])
Beispiel #12
0
    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])
Beispiel #13
0
 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])
Beispiel #14
0
 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])
Beispiel #15
0
    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])