Example #1
0
    def create_map(self, domain_id, group_id, can_read, can_write, can_delete):
        map = ModelMap()
        map.domain_id = domain_id
        map.group_id = group_id
        map.set_perm(map.READ_PERM, can_read)
        map.set_perm(map.WRITE_PERM, can_write)
        map.set_perm(map.DELETE_PERM, can_delete)
        map.save()

        return map
Example #2
0
    def create_map(self, domain_id, group_id, can_read, can_write, can_delete):
        map = ModelMap()
        map.domain_id = domain_id
        map.group_id = group_id
        map.set_perm(map.READ_PERM, can_read)
        map.set_perm(map.WRITE_PERM, can_write)
        map.set_perm(map.DELETE_PERM, can_delete)
        map.save()

        return map
    def test_format_map(self):
        domain = Domain()
        domain.domain_id = 252
        domain.domain = "example.com"

        group = Group()
        group.group_id = 252
        group.name = "Test Group 1"

        map = DomainGroupMap()
        map.map_id = 1
        map.group_id = group
        map.domain_id = domain
        map.permissions = 7

        formatted = map.format_map(map)
        self.assertTrue(formatted["can_read"])
        self.assertTrue(formatted["can_write"])
        self.assertTrue(formatted["can_delete"])
        self.assertEquals(formatted["map_id"], map.map_id)
        self.assertEquals(formatted["group"], map.group_id.to_clean_dict())
        self.assertEquals(formatted["domain"], map.domain_id.to_clean_dict())