|
1 | 1 | import hashlib |
2 | 2 | import json |
| 3 | +import os |
3 | 4 | from pathlib import Path |
4 | 5 |
|
5 | 6 | import rfc8785 |
|
21 | 22 | from openstatspec.sql.wide import create_wide_dataset |
22 | 23 |
|
23 | 24 |
|
| 25 | +def _workflow_conformance_manifest() -> Path: |
| 26 | + configured = os.environ.get("OPENSTATSPEC_SPECIFICATION_DIR") |
| 27 | + candidates = [ |
| 28 | + ( |
| 29 | + Path(configured) |
| 30 | + / "conformance/sql-transformation-workflow-0.1.json" |
| 31 | + if configured else None |
| 32 | + ), |
| 33 | + Path(__file__).resolve().parents[1] |
| 34 | + / "openstatspec-specification/conformance/sql-transformation-workflow-0.1.json", |
| 35 | + Path(__file__).resolve().parents[2] |
| 36 | + / "specification/conformance/sql-transformation-workflow-0.1.json", |
| 37 | + ] |
| 38 | + for candidate in candidates: |
| 39 | + if candidate and candidate.is_file(): |
| 40 | + return candidate |
| 41 | + raise RuntimeError( |
| 42 | + "The SQL transformation conformance fixture is required; " |
| 43 | + "set OPENSTATSPEC_SPECIFICATION_DIR." |
| 44 | + ) |
| 45 | + |
| 46 | + |
24 | 47 | def _variables(): |
25 | 48 | return [ |
26 | 49 | { |
@@ -541,10 +564,9 @@ def test_scope_aware_ctes_merge_with_parent_and_shadowing_fails(catalog): |
541 | 564 |
|
542 | 565 |
|
543 | 566 | def test_definition_hash_matches_every_normative_conformance_vector(): |
544 | | - manifest = json.loads(( |
545 | | - Path(__file__).resolve().parents[2] |
546 | | - / "specification/conformance/sql-transformation-workflow-0.1.json" |
547 | | - ).read_text(encoding="utf-8")) |
| 567 | + manifest = json.loads( |
| 568 | + _workflow_conformance_manifest().read_text(encoding="utf-8") |
| 569 | + ) |
548 | 570 | for case in manifest["cases"]: |
549 | 571 | actual = _definition_hash( |
550 | 572 | transformation_id=case["transformation_id"], |
|
0 commit comments