Skip to content

Add serialization snapshot tests and backward-compat deserialization tests #322

@andrewherren

Description

@andrewherren

Part of #315 (cross-version deserialization, RFC 0002).

Two categories of tests, in both R (test/R/testthat/) and Python (test/python/):

1. Snapshot tests
Serialize a BART and BCF model (covering: RFX, adaptive coding, variance forest, internal propensity) under the current version and save the JSON as a checked-in fixture. Future test runs load the fixture and assert deserialization succeeds — preventing silent regressions when the schema changes.

2. Backward-compat tests
Construct minimal "old-format" JSON strings with specific fields deliberately omitted (mirroring the version brackets in #318) and assert that:

  • Deserialization succeeds (no error)
  • The correct default value is applied
  • The expected warning is emitted (use expect_warning / pytest.warns)

Fields to cover at minimum:

  • Missing outcome / link (pre-v0.4.1 format)
  • Missing multivariate_treatment (pre-v0.4.0 Python BCF)
  • Missing internal_propensity_model (pre-v0.3.2)
  • Missing rfx_model_spec with has_rfx = TRUE (should warn)
  • Missing covariate_preprocessor / preprocessor_metadata (should warn)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions