def test_validate_failure(self):
        map = DomainGroupMap()

        map.permissions = -1
        with self.assertRaises(ValueError) as cm1:
            map.validate()

        map.permissions = 8
        with self.assertRaises(ValueError) as cm2:
            map.validate()
    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())