Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])