Skip to content

refactor(unit-tests): exercise dict + csv + sql fixture formats across the 3 cute-dbt dogfooding tests - #291

Merged
cmbays merged 1 commit into
mainfrom
feat/cute-dbt-format-coverage-unit-tests
May 25, 2026
Merged

cmbays merged 1 commit into
mainfrom
feat/cute-dbt-format-coverage-unit-tests

Conversation

@cmbays

@cmbays cmbays commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #290. The three unit_tests authored in #290 all used format: sql for given to avoid the upstream-introspection prerequisite that dict/csv require. Visual review of the rendered cute-dbt report surfaced two problems:

  1. cute-dbt's renderer shows "Fixture uses format: sql — not yet visualized" for all three tests (tracked at cute-dbt#66 — the renderer fix lands in the next cute-dbt PR).
  2. Even after cute-dbt#66 ships, having every test on the same format defeats the format-coverage dogfooding.

This PR re-authors the three tests so each demonstrates a different fixture format end-to-end.

Changes

Test Given format Expect format Demonstrates
test_dim_payers_injects_unknown_sentinel dict dict Compact key-value mock for ~22 columns
test_mart_dq_summary_combines_encounter_and_medication_metrics csv csv Tabular boolean grid (compact for many dq-flag columns)
test_mart_dq_summary_zero_quarantined_when_all_valid sql dict Inline SELECT with explicit casts

Plus dbt_project/README.md gains a new ## Unit tests (cute-dbt format coverage) section documenting the persistent-DuckDB target prerequisite (dict + csv given require the upstream relation to exist in the warehouse — easiest via a file-backed DuckDB target + run-operation load_synthea_sources).

Related Issues

Related to:

Type of Change

  • Refactoring (no functional changes) — same 3 tests, same assertions, different mock-data shape

Testing

All 3 tests pass via dbt-core 1.11.11 against a persistent DuckDB target:

$ dbt run-operation load_synthea_sources --target unit_test
[All Synthea sources loaded successfully!]

$ dbt build --empty --select "+mart_dq_summary +dim_payers" --target unit_test
[Completed successfully]

$ dbt test --select "test_type:unit" --target unit_test
1 of 3 PASS dim_payers::test_dim_payers_injects_unknown_sentinel
2 of 3 PASS mart_dq_summary::test_mart_dq_summary_combines_encounter_and_medication_metrics
3 of 3 PASS mart_dq_summary::test_mart_dq_summary_zero_quarantined_when_all_valid
Completed successfully
Done. PASS=3 WARN=0 ERROR=0 SKIP=0 NO-OP=0 TOTAL=3

Manual Testing

UI-specific test items (Chrome/Firefox/Safari/localStorage) are N/A — this PR only modifies dbt YAML + README.

Specific Test Cases

  1. dim_payers dict given/expect: dim_payers UNION-ALL with unknown sentinel preserves payer_key=-1 + sequenced surrogate keys starting at 1.
  2. mart_dq_summary csv given/expect: 2 encounter rows (1 invalid) + 2 medication rows (both invalid) → encounters quarantined_count=1 (50% rate), medications quarantined_count=2 (100% rate).
  3. mart_dq_summary sql given + dict expect: all-valid rows produce zero quarantined_count + 0.00 rate per entity. dict expect skips the non-deterministic _generated_at column.

🤖 Generated with Claude Code

…s the 3 cute-dbt dogfooding tests

Follow-up to #290 (cute-dbt#39 dogfooding). Surfaced visually:
cmbays/cute-dbt's renderer currently shows "Fixture uses format: sql
— not yet visualized" for the sql-format mocks, AND I had previously
chosen sql for ALL three tests to avoid the upstream-introspection
prerequisite for dict/csv. That choice defeated the format-coverage
demonstration the tests were meant to provide.

This PR re-authors the 3 tests so each test uses a different fixture
format end-to-end:

| Test | Given | Expect | Demonstrates |
|---|---|---|---|
| test_dim_payers_injects_unknown_sentinel | dict | dict | Key-value mock for ~22 columns |
| test_mart_dq_summary_combines_encounter_and_medication_metrics | csv | csv | Tabular boolean grid |
| test_mart_dq_summary_zero_quarantined_when_all_valid | sql | dict | Inline SELECT with explicit casts |

The dict and csv `given` blocks introspect the upstream model's
schema (to NULL-fill unspecified columns), which requires the upstream
relation to exist in the warehouse. Adds a `## Unit tests (cute-dbt
format coverage)` section to `dbt_project/README.md` documenting the
persistent-DuckDB target prerequisite + the exact 3-command workflow
to run them.

All 3 tests pass locally against dbt-core 1.11.11 with a persistent
DuckDB target seeded via `run-operation load_synthea_sources`:

    $ dbt test --select "test_type:unit" --target unit_test
    PASS=3 WARN=0 ERROR=0 SKIP=0 NO-OP=0 TOTAL=3

Closes the cute-dbt-side gap that motivated cute-dbt#66 (fixture
format rendering for csv + sql). cute-dbt's follow-up PR ships the
matching renderer fix + regenerated playground fixture against this
PR's merge commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cmbays
cmbays merged commit a0976b5 into main May 25, 2026
1 of 8 checks passed
@cmbays
cmbays deleted the feat/cute-dbt-format-coverage-unit-tests branch May 25, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant