Skip to content

Commit 431334c

Browse files
committed
Add more data quality tests for properties data load.
Add two more tables for testing.
1 parent ba0e93b commit 431334c

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

scripts/helpers/housing_nec_migration_gx_dq_inputs.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44
FROM "housing_nec_migration"."properties_1a" """,
55
"id_field": "LPRO_PROPREF",
66
},
7+
"properties_1b": {
8+
"sql": """ SELECT *
9+
FROM "housing_nec_migration"."properties_1b" """,
10+
"id_field": "LPRO_PROPREF",
11+
},
12+
"properties_1c": {
13+
"sql": """ SELECT *
14+
FROM "housing_nec_migration"."properties_1c" """,
15+
"id_field": "LPRO_PROPREF",
16+
}
717
}
818

919

10-
table_list = ['properties_1a']
20+
table_list = ['properties_1a', 'properties_1b', 'properties_1c']
1121

1222
partition_keys = ['import_date']

scripts/jobs/housing/housing_nec_migration_properties_data_load_gx_suite.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,112 @@ class ExpectPropTypeCodeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
3434
description: str = "Expect property type codes to contain one of the set"
3535

3636

37+
class ExpectOccStatusCodeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
38+
column: str = "LPRO_SCO_CODE"
39+
value_set: list = ["OCC", "VOI", "CLO"]
40+
description: str = "Expect status codes to be one of the set"
41+
42+
43+
class ExpectOrgIndicatorToBeInSet(gxe.ExpectColumnValuesToBeInSet):
44+
column: str = "LPRO_ORGANISATION_IND"
45+
value_set: list = ["Y", "N"]
46+
description: str = "Expect organisation indicator to be one of the set"
47+
48+
49+
class ExpectOwnTypeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
50+
column: str = "LPRO_HOU_HRV_HOT_CODE"
51+
value_set: list = [
52+
"ASSOC",
53+
"COUN",
54+
"LEASH",
55+
"LEASL",
56+
"LEASHOUT",
57+
"LEASLOUT",
58+
"PRIVATE",
59+
]
60+
description: str = "Expect ownership type code to be one of the set"
61+
62+
63+
class ExpectPropSourceToBeInSet(gxe.ExpectColumnValuesToBeInSet):
64+
column: str = "LPRO_HOU_HRV_HRS_CODE"
65+
value_set: list = [
66+
"LEASED",
67+
"NEWBUILD",
68+
"PURCHASE",
69+
"STOCKTRANS",
70+
"BUYBACK",
71+
"ACQUIRED",
72+
]
73+
description: str = "Expect property source code to be one of the set"
74+
75+
76+
class ExpectResIndicatorToBeInSet(gxe.ExpectColumnValuesToBeInSet):
77+
column: str = "LPRO_HOU_RESIDENTIAL_IND"
78+
value_set: list = ["Y", "N"]
79+
description: str = "Expect resdidential indicator to be one of the set"
80+
81+
82+
class ExpectPropTypeValuesToBeInSet(gxe.ExpectColumnValuesToBeInSet):
83+
column: str = "LPRO_HOU_PTV_CODE"
84+
value_set: list = [
85+
"CMC",
86+
"CMC",
87+
"GAR",
88+
"FLT",
89+
"HOU",
90+
"MAI",
91+
"BUN",
92+
"TRV",
93+
"STD",
94+
"ROM",
95+
"COM",
96+
"PSP",
97+
"PRA",
98+
"CYC",
99+
"DUP",
100+
]
101+
description: str = "Expect property type values to be one of the set"
102+
103+
104+
class ExpectPropColumnsToMatchOrderedList(gxe.ExpectTableColumnsToMatchOrderedList):
105+
column_list = [
106+
"LPRO_PROPREF",
107+
"LPRO_HOU_FRB",
108+
"LPRO_SCO_CODE",
109+
"LPRO_ORGANISATION_IND",
110+
"LPRO_HOU_HRV_HOT_CODE",
111+
"LPRO_HOU_HRV_HRS_CODE",
112+
"LPRO_HOU_HRV_HBU_CODE",
113+
"LPRO_HOU_HRV_HLT_CODE",
114+
"LPRO_PARENT_PROPREF",
115+
"LPRO_HOU_SALE_DATE",
116+
"LPRO_SERVICE_PROP_IND",
117+
"LPRO_HOU_ACQUIRED_DATE",
118+
"LPRO_HOU_DEFECTS_IND",
119+
"LPRO_HOU_RESIDENTIAL_IND",
120+
"LPRO_HOU_ALT_REF",
121+
"LPRO_HOU_LEASE_START_DATE",
122+
"LPRO_HOU_LEASE_REVIEW_DATE",
123+
"LPRO_HOU_CONSTRUCTION_DATE",
124+
"LPRO_HOU_PTV_CODE",
125+
"LPRO_HOU_HRV_PST_CODE",
126+
"LPRO_HOU_HRV_HMT_CODE",
127+
"LPRO_HOU_MANAGEMENT_END_DATE",
128+
"LPRO_FREE_PCODE",
129+
"LPRO_FREE_NAME",
130+
"LPRO_PROP_STATUS",
131+
"LPRO_STATUS_START",
132+
"LPRO_HOU_ALLOW_PLACEMENT_IND",
133+
"LPRO_HOU_DEBIT_TO_DATE",
134+
"LPRO_ON_DEBIT_START_DATE",
135+
"LPRO_PHONE",
136+
"LPRO_AGENT_PAR_REFNO",
137+
"LPRO_PLD_COMMENTS",
138+
"LPRO_REFNO",
139+
]
140+
description: str = "Expect columns to match ordered list exactly"
141+
142+
37143
arg_key = ["s3_target_location"]
38144
args = getResolvedOptions(sys.argv, arg_key)
39145
locals().update(args)
@@ -45,4 +151,11 @@ class ExpectPropTypeCodeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
45151

46152
suite.add_expectation(ExpectPropRefColumnValuesToBeUnique())
47153
suite.add_expectation(ExpectPropTypeCodeToBeInSet())
154+
suite.add_expectation(ExpectOccStatusCodeToBeInSet())
155+
suite.add_expectation(ExpectOrgIndicatorToBeInSet())
156+
suite.add_expectation(ExpectOwnTypeToBeInSet())
157+
suite.add_expectation(ExpectPropSourceToBeInSet())
158+
suite.add_expectation(ExpectResIndicatorToBeInSet())
159+
suite.add_expectation(ExpectPropTypeValuesToBeInSet())
160+
suite.add_expectation(ExpectPropColumnsToMatchOrderedList())
48161
suite = context.suites.add(suite)

0 commit comments

Comments
 (0)