Skip to content

Commit 2741ec0

Browse files
committed
Add GX DQ tests for tenancies data load
1 parent 342495e commit 2741ec0

File tree

3 files changed

+102
-4
lines changed

3 files changed

+102
-4
lines changed
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
sql_config = {"properties": {"id_field": "LPRO_PROPREF"}}
1+
sql_config = {
2+
"properties": {"id_field": "LPRO_PROPREF"},
3+
"tenancies": {"id_field": "LTCY_ALT_REF"},
4+
}
25

3-
data_load_list = ["properties"]
6+
data_load_list = ["properties", "tenancies"]
47

58
table_list = {
69
"properties": [
@@ -11,8 +14,10 @@
1114
"properties_1e",
1215
"properties_2a",
1316
"properties_4a",
14-
"properties_4c",
15-
]
17+
"properties_4b",
18+
"properties_4c"
19+
],
20+
"tenancies": ["tenancies_1a"],
1621
}
1722

1823
partition_keys = ["import_date"]

scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
table_list,
1717
)
1818
import scripts.jobs.housing.housing_nec_migration_properties_data_load_gx_suite
19+
import scripts.jobs.housing.housing_nec_migration_properties_data_load_gx_suite
20+
1921

2022
logging.basicConfig(level=logging.INFO)
2123
logger = logging.getLogger(__name__)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# flake8: noqa: F821
2+
3+
import sys
4+
5+
from awsglue.utils import getResolvedOptions
6+
import great_expectations as gx
7+
import great_expectations.expectations as gxe
8+
9+
10+
class ExpectTagRefColumnValuesToBeUnique(gxe.ExpectColumnValuesToBeUnique):
11+
column: str = "LTCY_ALT_REF"
12+
description: str = "Expect LTCY_ALT_REF (tenancy ref) values to be unique"
13+
14+
15+
class ExpectTenancyTypeCodeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
16+
column: str = "LTCY_TTY_CODE"
17+
value_set: list = [
18+
"ASH",
19+
"ASY",
20+
"Demoted",
21+
"FRS",
22+
"HAL",
23+
"INT",
24+
"LEA",
25+
"LTA",
26+
"LHS",
27+
"MPA",
28+
"PVG",
29+
"SPS",
30+
"RTM",
31+
"SEC",
32+
"SSE",
33+
"SHO",
34+
"SLL",
35+
"TLA",
36+
"TBB",
37+
"TBBFam",
38+
"DEC",
39+
"THGF",
40+
"THO",
41+
"THL",
42+
"TPL",
43+
"TRA",
44+
"TACCFLAT",
45+
"TGA",
46+
"UNDER18",
47+
"NONSECTA",
48+
"NONSECHR",
49+
"OFFICESE",
50+
"LIVINGRT",
51+
"FRE",
52+
]
53+
description: str = "Expect tenancy type code to contain one of the set"
54+
55+
56+
class ExpectTenureTypeCodeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
57+
column: str = "LTCY_HRV_TTYP_CODE"
58+
value_set: list = [
59+
"Secure",
60+
"NonSec",
61+
"NonRes",
62+
"Leasehold",
63+
"Temporary",
64+
"Freehold",
65+
"Commercial",
66+
"LivingRent"
67+
]
68+
description: str = "Expect tenure type code to be one of the set"
69+
70+
71+
class ExpectTenancyStatusCodeToBeInSet(gxe.ExpectColumnValuesToBeInSet):
72+
column: str = "LTCY_HRV_TST_CODE"
73+
value_set: list = ["Notice", "Decant", "UnautOcc"]
74+
description: str = "Expect tenancy status code to be one of the set"
75+
76+
77+
78+
arg_key = ["s3_target_location"]
79+
args = getResolvedOptions(sys.argv, arg_key)
80+
locals().update(args)
81+
82+
# add to GX context
83+
context = gx.get_context(mode="file", project_root_dir=s3_target_location)
84+
85+
suite = gx.ExpectationSuite(name="tenancies_data_load_suite")
86+
87+
suite.add_expectation(ExpectTagRefColumnValuesToBeUnique())
88+
suite.add_expectation(ExpectTenancyTypeCodeToBeInSet())
89+
suite.add_expectation(ExpectTenureTypeCodeToBeInSet())
90+
suite.add_expectation(ExpectTenancyStatusCodeToBeInSet())
91+
suite = context.suites.add(suite)

0 commit comments

Comments
 (0)