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,48 @@
|
||||
"""Constraints and triggers: the ODS refuses what the model forbids, and keeps updated_at current.
|
||||
|
||||
Every statement runs in a transaction that is rolled back, so the seed is untouched. Each
|
||||
rejected update in expectations.yaml is applied to the table's first sample row and must fail
|
||||
with the named constraint (or "not-null") in PostgreSQL's error.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from semprini_data_domain.testing import expectations_for
|
||||
|
||||
TABLES = list(expectations_for(__file__)["tables"].items())
|
||||
REJECTS = [(table, reject) for table, spec in TABLES for reject in spec.get("rejects", [])]
|
||||
|
||||
|
||||
def key_of(dp, table):
|
||||
return next(t.key for t in dp.product.tables if t.name == table)
|
||||
|
||||
|
||||
def first_sample_key(dp, table, spec):
|
||||
assert spec.get("samples"), f"{table} needs a sample in expectations.yaml"
|
||||
return spec["samples"][0][key_of(dp, table)]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"table,reject", REJECTS, ids=[f"{t}-{r['violates']}" for t, r in REJECTS]
|
||||
)
|
||||
def test_update_is_refused(dp, table, reject):
|
||||
spec = dict(TABLES)[table]
|
||||
key = key_of(dp, table)
|
||||
assignments = ", ".join(f"{column} = {dp.sql_literal(value)}" for column, value in reject["set"].items())
|
||||
error = dp.sql_error(
|
||||
f"UPDATE {dp.product.schema}.{table} SET {assignments} "
|
||||
f"WHERE {key} = '{first_sample_key(dp, table, spec)}'"
|
||||
)
|
||||
assert error is not None, f"{table}: update {reject['set']} was accepted"
|
||||
assert reject["violates"] in error, error
|
||||
|
||||
|
||||
@pytest.mark.parametrize("table,spec", TABLES, ids=[t for t, _ in TABLES])
|
||||
def test_update_sets_updated_at(dp, table, spec):
|
||||
key = key_of(dp, table)
|
||||
sample_key = first_sample_key(dp, table, spec)
|
||||
rows = dp.sql_rolled_back(
|
||||
f"UPDATE {dp.product.schema}.{table} SET {key} = {key} WHERE {key} = '{sample_key}'",
|
||||
f"SELECT updated_at > created_at AS moved FROM {dp.product.schema}.{table} WHERE {key} = '{sample_key}'",
|
||||
)
|
||||
assert rows == [{"moved": True}]
|
||||
Reference in new issue
Block a user