Skip to content

Get the backend test suite green and run it in CI - #171

Merged
duaneatat merged 4 commits into
mainfrom
db/backend-test-suite
Nov 2, 2026
Merged

duaneatat merged 4 commits into
mainfrom
db/backend-test-suite

Conversation

@duaneatat

Copy link
Copy Markdown
Collaborator

CI only ran the MCP tests, so the rest of the backend suite had decayed: 38 failures and 2 collection errors on main. This fixes or retires each failing test and adds a Backend tests workflow that runs the whole suite without a warehouse. Tests that need real warehouse data are marked requires_warehouse and skip there. The result is 444 passed, 53 skipped and 0 failed, both locally and in CI.

  • Retires the dead /load/census/{category}/{subcategory} route, query/timeseries_db.py, its tests and golden CSVs, and the unused Filter_Call.tsx. The frontend reads ACS series from /load/acs5-db/timeseries/*.
  • Points test_sql_render.py at the 40 templates that exist and fixes the lint violations it caught. The three structural SQL rewrites return identical results against the warehouse.
  • Updates test_clean_acs5.py for the DOUBLE value cast and adds a fixture test for Census unavailable codes.
  • Renames the DuckLake diagnostic test_lake.py to inspect_lake.py so pytest doesn't collect it.
  • When there's no warehouse, conftest.py gives modules that open it at import an empty in-memory database.
  • CI skips tests/test_base.py until the margin-of-error work ports it to data_collection.base.
  • Not fixed here: zoning/footprints.sql calls ST_AsGeoJSON on a BLOB, so the building-footprints endpoint fails before and after this change. zoning/geo_query.sql renders invalid SQL when there are no filter sources. The repo-root Data/lake is a stale committed DuckLake catalog.

- Retire the dead /load/census route, query/timeseries_db.py, its tests and
  golden CSVs. The frontend uses /load/acs5-db/timeseries/*; the only caller
  (Filter_Call.tsx, also removed) was never imported and hit a path the route
  did not match, and the acs5_* tables it read are gone from the warehouse.
- Point test_sql_render at the current templates (build/sql moved to
  data_cleaning/sql) and fix the stale compiled-CTE expectation. Fix the SQL
  lint debt that test now catches; rendered output is unchanged.
- Update test_clean_acs5 for the DOUBLE value column and add a fixture test for
  the "(X)" and sentinel-code nulling.
- conftest: give import-time get_db() an empty in-memory DuckDB when no
  warehouse is built, and skip `requires_warehouse` tests instead.
- Rename the DuckLake diagnostic test_lake.py to inspect_lake.py so pytest no
  longer opens the lake on collection.
- Add a Backend tests workflow running the whole suite.
- Fix stale build/sql paths in the justfile, CLAUDE.md and .sqlfluff.
Comment thread backend/query/sql/cdc/county_places.sql Resolved
Comment thread backend/query/timeseries_db.py Resolved

@iansargent iansargent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through the code, most of this stuff looks to be reformatting SQL queries, updating documentation references to the old build/ logic, deleting stale files (timeseries_db.py, Filter_Call.tsx, etc.), and updating the testing files.

Everything looked good besides that one SQL fix with the county column.

The compiled WHERE clause names columns unqualified, and the county lines
share county, county_fips and geoid with PLACES. Excluding county from the
join only covered that one column; a county_fips filter still failed with an
ambiguous reference. Filtering PLACES in a CTE first leaves nothing to clash.
@duaneatat
duaneatat merged commit 9bcfe59 into main Nov 2, 2026
4 checks passed
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.

2 participants