Adapt Canonical Party to the domain platform; add unit tests
Makes the blog-generated product run on the digital-core domain built from
semprini-data-domain, with the same changes the canonical template received:
- flink/job.sql connects to ods:5432/ods as postgres with ${ODS_PASSWORD},
substituted by data-domain at submission, instead of the blog's credentials
- lakehouse/010_replication.sql uses the platform's `ods` sync group and grants
the lake tables to ducklake_reader and ducklake_writer
- product.yaml sync group, odps.yaml access URLs (domain ports 20000-20003,
management zone Apicurio on 8081), CLI names in comments
Adds tests/: the canonical template's generic unit tests and this product's
expectations.yaml (seed rows, 24 constraint rejections, 5 relationship
traversals, one inbound-to-tombstone round trip).
Verified on digital-core on 2026-09-18: 65 of 65 smoke checks, 100 unit tests
passing, and registered in OpenMetadata under the digital-core domain.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cfb32d2d1b
commit
dd096ee4dc
18 files changed
+590
-93
No files matched your search
@@ -0,0 +1,193 @@
|
||||
# Canonical Party: unit test expectations, generated with ods/040_seed.sql and kept in step with it.
|
||||
# Read by the generic tests beside this file (test_*.py, copied from the canonical template).
|
||||
# Run from the domain repository: uv run data-domain unit <path to canonical-party>
|
||||
|
||||
tables:
|
||||
# rows: how many rows the seed inserts
|
||||
# samples: seed rows checked by value in the ODS, through GraphQL and in the lake (the key
|
||||
# column is required; the first sample is also the row the reject updates target)
|
||||
# rejects: updates to the first sample the ODS must refuse, with the constraint named in the
|
||||
# error ("not-null" for NOT NULL)
|
||||
party:
|
||||
rows: 4
|
||||
samples:
|
||||
- party_id: 7d1e5a2c-0001-4a7b-9c11-000000000003
|
||||
party_type: Company
|
||||
legal_name: Kowhai Trading Limited
|
||||
also_known_as: "Kowhai Trading; KTL"
|
||||
party_status: Active
|
||||
rejects:
|
||||
- set: {party_type: Robot}
|
||||
violates: party_party_type_check
|
||||
- set: {party_status: Dormant}
|
||||
violates: party_party_status_check
|
||||
- set: {legal_name: null}
|
||||
violates: not-null
|
||||
|
||||
address:
|
||||
rows: 3
|
||||
samples:
|
||||
- address_id: 7d1e5a2c-0002-4a7b-9c11-000000000001
|
||||
address_type: Street Address
|
||||
address_line_1: 1 Queen Street
|
||||
suburb: Auckland Central
|
||||
city: Auckland
|
||||
postcode: "1010"
|
||||
country: NZ
|
||||
rejects:
|
||||
- set: {address_line_1: null}
|
||||
violates: street_address_requires_address_line_1
|
||||
- set: {address_type: Castle}
|
||||
violates: address_address_type_check
|
||||
- set: {country: null}
|
||||
violates: not-null
|
||||
|
||||
person:
|
||||
rows: 2
|
||||
samples:
|
||||
- person_id: 7d1e5a2c-0001-4a7b-9c11-000000000001
|
||||
date_of_birth: 1985-03-14
|
||||
preferred_name: Alice
|
||||
country_of_residence: NZ
|
||||
rejects:
|
||||
- set: {date_of_birth: "2999-01-01"}
|
||||
violates: date_of_birth_not_in_future
|
||||
- set: {person_id: 7d1e5a2c-0001-4a7b-9c11-00000000ffff}
|
||||
violates: person_person_id_fkey
|
||||
|
||||
company:
|
||||
rows: 2
|
||||
samples:
|
||||
- company_id: 7d1e5a2c-0001-4a7b-9c11-000000000004
|
||||
company_registration_number: "123456789"
|
||||
incorporation_country: AU
|
||||
incorporation_date: 2005-03-15
|
||||
legal_structure: Private Company
|
||||
rejects:
|
||||
- set: {legal_structure: Guild}
|
||||
violates: company_legal_structure_check
|
||||
|
||||
party_role:
|
||||
rows: 3
|
||||
samples:
|
||||
- party_role_id: 7d1e5a2c-0003-4a7b-9c11-000000000003
|
||||
party_role_type: Customer
|
||||
role_status: Closed
|
||||
role_start_date: 2021-03-01
|
||||
role_end_date: 2024-08-31
|
||||
party_id: 7d1e5a2c-0001-4a7b-9c11-000000000002
|
||||
rejects:
|
||||
- set: {role_end_date: null}
|
||||
violates: closed_role_requires_end_date
|
||||
- set: {role_end_date: "2020-01-01"}
|
||||
violates: role_end_after_start
|
||||
- set: {party_role_type: Merchant}
|
||||
violates: party_role_party_role_type_check
|
||||
- set: {party_id: 7d1e5a2c-0001-4a7b-9c11-00000000ffff}
|
||||
violates: party_role_party_id_fkey
|
||||
|
||||
customer:
|
||||
rows: 3
|
||||
samples:
|
||||
- customer_id: 7d1e5a2c-0003-4a7b-9c11-000000000002
|
||||
customer_number: CUST-000002
|
||||
onboarding_date: 2018-06-01
|
||||
relationship_start_date: 2015-06-01
|
||||
rejects:
|
||||
- set: {customer_number: CUST-000001}
|
||||
violates: customer_customer_number_key
|
||||
- set: {customer_number: null}
|
||||
violates: not-null
|
||||
|
||||
contact_address:
|
||||
rows: 3
|
||||
samples:
|
||||
- contact_address_id: 7d1e5a2c-0004-4a7b-9c11-000000000001
|
||||
address_purpose: Home
|
||||
is_primary: true
|
||||
verification_status: Verified
|
||||
verification_date: 2024-02-10
|
||||
verification_method: Documentary
|
||||
valid_from: 2019-12-01
|
||||
party_id: 7d1e5a2c-0001-4a7b-9c11-000000000001
|
||||
address_id: 7d1e5a2c-0002-4a7b-9c11-000000000001
|
||||
rejects:
|
||||
- set: {verification_date: null}
|
||||
violates: verification_date_required_when_verified
|
||||
- set: {valid_to: "2019-01-01"}
|
||||
violates: valid_to_after_valid_from
|
||||
- set: {verification_method: Telepathy}
|
||||
violates: contact_address_verification_method_check
|
||||
- set: {address_id: 7d1e5a2c-0002-4a7b-9c11-00000000ffff}
|
||||
violates: contact_address_address_id_fkey
|
||||
|
||||
party_role_contact_address:
|
||||
rows: 3
|
||||
samples:
|
||||
- party_role_contact_address_id: 7d1e5a2c-0005-4a7b-9c11-000000000003
|
||||
party_role_id: 7d1e5a2c-0003-4a7b-9c11-000000000002
|
||||
contact_address_id: 7d1e5a2c-0004-4a7b-9c11-000000000003
|
||||
rejects:
|
||||
- set: {party_role_id: 7d1e5a2c-0003-4a7b-9c11-00000000ffff}
|
||||
violates: party_role_contact_address_party_role_id_fkey
|
||||
|
||||
party_association:
|
||||
rows: 3
|
||||
samples:
|
||||
- party_association_id: 7d1e5a2c-0006-4a7b-9c11-000000000003
|
||||
source_party_id: 7d1e5a2c-0001-4a7b-9c11-000000000002
|
||||
target_party_id: 7d1e5a2c-0001-4a7b-9c11-000000000001
|
||||
association_type: Partner
|
||||
association_start_date: 2016-06-01
|
||||
verified: false
|
||||
rejects:
|
||||
- set: {association_type: Nemesis}
|
||||
violates: party_association_association_type_check
|
||||
- set: {target_party_id: null}
|
||||
violates: not-null
|
||||
|
||||
# Relationship traversals in graphql/schema.graphql, checked against the seed. `expect` must be
|
||||
# contained in the response (lists compare item by item, in order).
|
||||
graphql:
|
||||
- name: person-extends-party
|
||||
query: '{ personCollection(filter: {personId: {eq: "7d1e5a2c-0001-4a7b-9c11-000000000001"}}) { edges { node { preferredName party { legalName partyType } } } } }'
|
||||
expect:
|
||||
personCollection: {edges: [{node: {preferredName: Alice, party: {legalName: Alice Margaret Ng, partyType: Person}}}]}
|
||||
- name: party-has-its-company-subtype
|
||||
query: '{ partyCollection(filter: {partyId: {eq: "7d1e5a2c-0001-4a7b-9c11-000000000004"}}) { edges { node { company { incorporationCountry } person { preferredName } } } } }'
|
||||
expect:
|
||||
partyCollection: {edges: [{node: {company: {incorporationCountry: AU}, person: null}}]}
|
||||
- name: customer-role-of-party
|
||||
query: '{ customerCollection(filter: {customerNumber: {eq: "CUST-000001"}}) { edges { node { partyRole { roleStatus party { legalName } } } } } }'
|
||||
expect:
|
||||
customerCollection: {edges: [{node: {partyRole: {roleStatus: Active, party: {legalName: Alice Margaret Ng}}}}]}
|
||||
- name: role-uses-contact-addresses
|
||||
query: '{ partyRoleCollection(filter: {partyRoleId: {eq: "7d1e5a2c-0003-4a7b-9c11-000000000001"}}) { edges { node { partyRoleContactAddressCollection(orderBy: [{partyRoleContactAddressId: AscNullsLast}]) { edges { node { contactAddress { addressPurpose address { city } } } } } } } } }'
|
||||
expect:
|
||||
partyRoleCollection: {edges: [{node: {partyRoleContactAddressCollection: {edges: [
|
||||
{node: {contactAddress: {addressPurpose: Home, address: {city: Auckland}}}},
|
||||
{node: {contactAddress: {addressPurpose: Mailing, address: {city: Wellington}}}}]}}}]}
|
||||
- name: associations-are-directional
|
||||
query: '{ partyCollection(filter: {partyId: {eq: "7d1e5a2c-0001-4a7b-9c11-000000000001"}}) { edges { node { outgoingAssociationCollection(orderBy: [{partyAssociationId: AscNullsLast}]) { edges { node { associationType targetParty { legalName } } } } incomingAssociationCollection { edges { node { associationType sourceParty { legalName } } } } } } } }'
|
||||
expect:
|
||||
partyCollection: {edges: [{node: {
|
||||
outgoingAssociationCollection: {edges: [
|
||||
{node: {associationType: Director, targetParty: {legalName: Kowhai Trading Limited}}},
|
||||
{node: {associationType: Authorised Signatory, targetParty: {legalName: Kowhai Trading Limited}}}]},
|
||||
incomingAssociationCollection: {edges: [
|
||||
{node: {associationType: Partner, sourceParty: {legalName: Rangi Parata}}}]}}}]}
|
||||
|
||||
# One record published to an inbound topic and followed through every interface, then updated
|
||||
# and deleted through GraphQL. Use a table without required foreign keys, and a key no seed row
|
||||
# uses; the test refuses to publish a record the ODS would reject.
|
||||
round_trip:
|
||||
table: address
|
||||
record:
|
||||
address_id: 7d1e5a2c-0002-4a7b-9c11-00000000e2e0
|
||||
address_type: PO Box
|
||||
address_line_1: PO Box 999
|
||||
city: Nelson
|
||||
postcode: "7040"
|
||||
country: NZ
|
||||
update:
|
||||
city: Richmond
|
||||
Reference in new issue
Block a user