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>
48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
"""CRUD API: pg_graphql reflects every column of every table, serves the seed rows, and
|
|
resolves the relationships the product documents in graphql/schema.graphql.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from semprini_data_domain.platform import camel, pascal
|
|
from semprini_data_domain.testing import contains, expectations_for, same_value
|
|
|
|
EXPECT = expectations_for(__file__)
|
|
TABLES = list(EXPECT["tables"].items())
|
|
SAMPLES = [(table, sample) for table, spec in TABLES for sample in spec.get("samples", [])]
|
|
QUERIES = EXPECT.get("graphql", [])
|
|
|
|
|
|
def key_of(dp, table):
|
|
return next(t.key for t in dp.product.tables if t.name == table)
|
|
|
|
|
|
@pytest.mark.parametrize("table,spec", TABLES, ids=[t for t, _ in TABLES])
|
|
def test_type_reflects_every_column(dp, table, spec):
|
|
data = dp.graphql(f'{{ __type(name: "{pascal(table)}") {{ fields {{ name }} }} }}')
|
|
assert data["__type"], f"type {pascal(table)} not reflected"
|
|
fields = {f["name"] for f in data["__type"]["fields"]}
|
|
missing = [camel(c) for c in dp.columns(table) if camel(c) not in fields]
|
|
assert not missing, f"{pascal(table)} lacks {missing}"
|
|
|
|
|
|
@pytest.mark.parametrize("table,sample", SAMPLES, ids=[t for t, _ in SAMPLES])
|
|
def test_seed_row_through_graphql(dp, table, sample):
|
|
key = key_of(dp, table)
|
|
fields = " ".join(camel(column) for column in sample)
|
|
data = dp.graphql(
|
|
f'{{ {camel(table)}Collection(filter: {{{camel(key)}: {{eq: "{sample[key]}"}}}}) '
|
|
f"{{ edges {{ node {{ {fields} }} }} }} }}"
|
|
)
|
|
edges = data[f"{camel(table)}Collection"]["edges"]
|
|
assert len(edges) == 1, f"{table} {sample[key]}: {edges}"
|
|
node = edges[0]["node"]
|
|
for column, expected in sample.items():
|
|
assert same_value(expected, node[camel(column)]), f"{camel(column)}: {node[camel(column)]!r} != {expected!r}"
|
|
|
|
|
|
@pytest.mark.parametrize("case", QUERIES, ids=[q["name"] for q in QUERIES])
|
|
def test_relationship(dp, case):
|
|
data = dp.graphql(case["query"])
|
|
assert contains(case["expect"], data), f"{data} does not contain {case['expect']}"
|