Feature/dataset contract tests - #1089
Merged
Cedarich merged 10 commits intoJul 23, 2026
Merged
Conversation
|
@martinshub-tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Cedarich
requested changes
Jul 23, 2026
Cedarich
left a comment
Contributor
There was a problem hiding this comment.
Kindly fix failing pytest
martinshub-tech
force-pushed
the
feature/dataset-contract-tests
branch
from
July 23, 2026 18:32
b767cb8 to
c8f19ca
Compare
martinshub-tech
force-pushed
the
feature/dataset-contract-tests
branch
from
July 23, 2026 18:38
c8f19ca to
f005178
Compare
Contributor
Cedarich
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1052
Goal
Validate that derived datasets consumed by backend services maintain a stable database schema, JSON shape, and semantic meaning across pipeline changes.
Acceptance Criteria Met
Contract tests exist for at least one backend-consumed dataset: Implemented tests checking both the backend-consumed analytics_records and contract_events datasets.
Breaking shape or semantics changes produce a clear failure:
Database schema checks detect missing/added/modified columns, type mismatches, and nullability modifications statically.
Data shape checks inspect JSON structure keys and type correctness.
Semantic checks enforce mathematical consistency of calculations (e.g. change_percentage matches value/previous_value, trend matches threshold, positive ledgers/amounts, valid status/types).
Test fixtures are easy for contributors to update intentionally: Added --update-contracts CLI flag and UPDATE_CONTRACTS=1 environment variable support to automatically regenerate reference fixtures on the fly.
Coverage includes at least one analytics and one ingestion-derived output: Cover analytics_records (analytics-derived output) and contract_events (ingestion-derived output).
Changes
apps/data-processing/tests/conftest.py: Added command line parser option --update-contracts and its respective fixture to allow updating contract schemas.
apps/data-processing/tests/test_dataset_contracts.py: A new test suite that:
Validates SQLAlchemy database mapping schema statically using inspection (no live DB connection required).
Validates pipeline-generated mock outputs for both analytics and ingestion.
Performs semantic calculations checks and trend checks.
apps/data-processing/tests/fixtures/contracts/: Directory containing the saved JSON reference contracts representing the stable database schema and data shape expectations.