Skip to content

Conversation

@tbhb
Copy link
Contributor

@tbhb tbhb commented Dec 31, 2025

Summary

  • Add comprehensive property-based tests using Hypothesis for JSON serialization roundtrip, record validation, and state computation
  • Create shared strategies.py module with reusable Hypothesis strategies for JSONLT domain types
  • Rename test_key_comparison.py to test_key_properties.py for naming consistency across property test files

Test coverage

The new property-based tests verify:

JSON serialization (test_json_properties.py)

  • Roundtrip preservation: parse(serialize(obj)) == obj
  • Serialization determinism: consistent output for identical data
  • Valid JSON output: parseable by standard json.loads

Record validation (test_record_properties.py)

  • Valid scalar and compound key records pass validation
  • Key extraction matches field values
  • Tombstone detection and construction roundtrip

State computation (test_state_properties.py)

  • Empty sequence yields empty state
  • Upsert idempotence and last-write-wins semantics
  • Delete operations and reinsert-after-delete
  • State invariants: no tombstones in final state, keys match extracted keys

Test plan

  • All 28 property tests pass locally
  • Type checking passes with 0 errors
  • All linting checks pass
  • CI passes

tbhb added 2 commits December 31, 2025 01:02
Add comprehensive property-based tests using Hypothesis to verify:

- JSON serialization roundtrip (serialize -> deserialize preserves data)
- JSON serialization determinism (consistent output for identical data)
- Record validation with generated valid/invalid records
- Key extraction correctness for scalar and compound keys
- Tombstone detection and construction roundtrip
- State computation with random sequences of put/delete operations
- State invariants (no tombstones in final state, keys match records)

Changes:
- Create shared strategies.py module with reusable Hypothesis strategies
- Rename test_key_comparison.py to test_key_properties.py for consistency
- Add test_json_properties.py for serialization tests
- Add test_record_properties.py for record validation tests
- Add test_state_properties.py for state computation tests
@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tbhb tbhb merged commit 8863bbe into main Dec 31, 2025
29 checks passed
@tbhb tbhb deleted the property-tests branch December 31, 2025 18:11
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 31, 2025

CodSpeed Performance Report

Merging #11 will not alter performance

Comparing property-tests (68d373b) with main (6ed513b)1

Summary

✅ 173 untouched
⏩ 1 skipped2

Footnotes

  1. No successful run was found on main (7373632) during the generation of this report, so 6ed513b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

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