aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl/test_profiling/test_schema.py
blob: ae61527bd6c37f1c0c5011c4ec816eae5ee529b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from generalresearch.models.thl.profiling.upk_property import PropertyType


class TestUpkSchemaManager:

    def test_get_props_info(self, upk_schema_manager, upk_data):
        props = upk_schema_manager.get_props_info()
        assert (
            len(props) == 16955
        )  # ~ 70 properties x each country they are available in

        gender = [
            x
            for x in props
            if x.country_iso == "us"
            and x.property_id == "73175402104741549f21de2071556cd7"
        ]
        assert len(gender) == 1
        gender = gender[0]
        assert len(gender.allowed_items) == 3
        assert gender.allowed_items[0].label == "female"
        assert gender.allowed_items[1].label == "male"
        assert gender.prop_type == PropertyType.UPK_ITEM
        assert gender.categories[0].label == "Demographic"

        age = [
            x
            for x in props
            if x.country_iso == "us"
            and x.property_id == "94f7379437874076b345d76642d4ce6d"
        ]
        assert len(age) == 1
        age = age[0]
        assert age.allowed_items is None
        assert age.prop_type == PropertyType.UPK_NUMERICAL
        assert age.gold_standard

        cars = [
            x
            for x in props
            if x.country_iso == "us" and x.property_label == "household_auto_type"
        ][0]
        assert not cars.gold_standard
        assert cars.categories[0].label == "Autos & Vehicles"