Skip to content

Commit

Permalink
Add an invalid check
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenchrist committed May 4, 2024
1 parent 4b43220 commit b4ccb00
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/fixtures/parquet/datacontract_invalid.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/test_test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b4ccb00

Please sign in to comment.