|
| 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