Ejemplo n.º 1
0
    def test_set_hierarchies(self):

        test_hierarchy_id = [["0", "*"], ["1", "*"]]
        test_hierarchy_name = [["Viktor", "*"], ["Jerry", "*"]]

        dataset = Dataset(self.test_data)
        dataset._set_attribute_type("id", AttributeType.QUASIIDENTIFYING)
        dataset._set_attribute_type("name", AttributeType.QUASIIDENTIFYING)
        dataset.set_hierarchies({
            "id": test_hierarchy_id,
            "name": test_hierarchy_name
        })
        self.assertEqual(dataset._attributes[0].hierarchy, test_hierarchy_id)
        self.assertEqual(dataset._attributes[1].hierarchy, test_hierarchy_name)
Ejemplo n.º 2
0
    def test__payload__with_hierarchies(self):

        test_hierarchy_id = [["0", "*"], ["1", "*"]]
        test_hierarchy_name = [["Viktor", "NAME"], ["Jerry", "NAME"]]

        dataset = Dataset(self.test_data)
        dataset._set_attribute_type("id", AttributeType.QUASIIDENTIFYING)
        dataset._set_attribute_type("name", AttributeType.QUASIIDENTIFYING)
        dataset.set_hierarchies({
            "id": test_hierarchy_id,
            "name": test_hierarchy_name
        })
        payload = dataset._payload()
        self.assertEqual(test_hierarchy_id,
                         payload["attributes"][0]["hierarchy"])
        self.assertEqual(test_hierarchy_name,
                         payload["attributes"][1]["hierarchy"])