blob: b0eae3166b4fe483c41095931dda1134132a4a29 (
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
45
46
47
48
49
50
51
52
53
|
from collections.abc import Callable
from generalresearch.managers.thl.profiling.schema import (
UpkSchemaManager,
)
from generalresearch.models.thl.profiling.upk_property import PropertyType
class TestUpkSchemaManager:
def test_get_props_info(
self, upk_schema_manager: UpkSchemaManager, upk_data: Callable[..., None]
):
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 = next(
x
for x in props
if x.country_iso == "us" and x.property_label == "household_auto_type"
)
assert not cars.gold_standard
assert cars.categories[0].label == "Autos & Vehicles"
|