diff --git a/tests/fixtures/parquet/datacontract_invalid.yaml b/tests/fixtures/parquet/datacontract_invalid.yaml new file mode 100644 index 00000000..4f82ad83 --- /dev/null +++ b/tests/fixtures/parquet/datacontract_invalid.yaml @@ -0,0 +1,21 @@ +dataContractSpecification: 0.9.2 +id: orders-unit-test +info: + title: Orders Unit Test + version: 1.0.0 +servers: + production: + type: local + path: ./fixtures/parquet/data/orders.parquet + format: parquet + dataProductId: orders + outputPortId: parquet +models: + orders: + fields: + order_id: + type: date # this is not true + unique: true + required: true + some_extra_field: #does not exist + type: long diff --git a/tests/test_test_parquet.py b/tests/test_test_parquet.py index dc55d291..09ef9afc 100644 --- a/tests/test_test_parquet.py +++ b/tests/test_test_parquet.py @@ -27,3 +27,15 @@ def test_valid(): assert run.result == "passed" assert len(run.checks) == 4 assert all(check.result == "passed" for check in run.checks) + + +def test_invalid(): + data_contract = DataContract( + data_contract_file="fixtures/parquet/datacontract_invalid.yaml", + ) + run = data_contract.test() + print(run.pretty()) + assert run.result == "failed" + assert len(run.checks) == 6 + assert any(check.result == "failed" for check in run.checks) + assert any(check.reason == "Type Mismatch, Expected Type: date; Actual Type: varchar" for check in run.checks)