Skip to content

Commit 6a14aa2

Browse files
committed
docs+test: soften module docstring; add fixture-scope sanity assert (#105 PR 2a)
Two small cleanups; no behavior change. (1) src/bigquery_agent_analytics/binding_validation.py: module docstring previously read like a PR-review note (told callers not to import a graph_validation module that does not exist yet). Replaced with a public-doc-shaped sentence that just describes the relationship to #76's planned extracted-graph validator. (2) tests/test_integration_ontology_binding.py: the live test TestBindingValidationLive depends on two function-scope fixtures (isolated_scratch and isolated_ontology_and_binding), and the second's binding YAML embeds the first's dataset id. If either fixture is later flipped to module scope by accident, the binding would point at a stale dataset. New assertion binding.target.dataset == ds_id catches that drift before any BQ call runs. Live test still PASSES against test-project-0728-467323 (13.24s).
1 parent 6ececb1 commit 6a14aa2

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/bigquery_agent_analytics/binding_validation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
most common authoring error (binding YAML drifted out of sync with
2121
physical tables) before extraction wastes ``AI.GENERATE`` tokens.
2222
23-
Different from the planned extracted-graph validator in issue #76:
24-
that one will validate extracted graph output against the spec
25-
(post-extraction, pre-materialization). This one validates the
26-
binding against the live BigQuery schemas (pre-extraction). #76 has
27-
not landed yet, so do not import any symbol from a
28-
``graph_validation`` module — it does not exist on this PR.
23+
Different from the planned extracted-graph validator in #76, which
24+
will validate ``ExtractedGraph`` output against the resolved spec
25+
after extraction. This validator runs before extraction.
2926
3027
Usage::
3128

tests/test_integration_ontology_binding.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,18 @@ def test_validator_end_to_end_against_real_bigquery(
748748
client, ds_id = isolated_scratch
749749
ontology, binding = isolated_ontology_and_binding
750750

751+
# Cheap fixture-scope sanity check: the binding YAML the second
752+
# fixture wrote must point at the dataset the first fixture
753+
# created. If a future refactor flips either fixture to module
754+
# scope by accident, the binding would race with whichever
755+
# dataset was created first and this assert would catch it
756+
# before any BQ call runs.
757+
assert binding.target.dataset == ds_id, (
758+
f"binding.target.dataset={binding.target.dataset!r} but "
759+
f"isolated_scratch yielded {ds_id!r}; fixture scopes are "
760+
f"out of sync"
761+
)
762+
751763
# Phase 1: materialize real tables.
752764
mat = OntologyMaterializer.from_ontology_binding(
753765
ontology=ontology,

0 commit comments

Comments
 (0)