From a270b2140891f24cf0d077f7cb72d6a87ee1b42b Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 7 Jul 2026 07:06:10 -0400 Subject: [PATCH] Add wrapper regression test for local dataset paths Locks in the #415 behavior delivered by #442: a plain local file path with allow_unmanaged=True reaches Microsimulation unchanged and the provenance bundle records it. Fixes #415 Co-Authored-By: Claude Fable 5 --- changelog.d/415.fixed.md | 1 + tests/test_release_manifests.py | 35 +++++++++++++++++++++++++++++++++ uv.lock | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 changelog.d/415.fixed.md diff --git a/changelog.d/415.fixed.md b/changelog.d/415.fixed.md new file mode 100644 index 00000000..0d59518c --- /dev/null +++ b/changelog.d/415.fixed.md @@ -0,0 +1 @@ +Add a full-wrapper regression test covering `managed_microsimulation` with a plain local dataset path and `allow_unmanaged=True` (the #415 scenario, resolved by #442). diff --git a/tests/test_release_manifests.py b/tests/test_release_manifests.py index db5a1295..9872328d 100644 --- a/tests/test_release_manifests.py +++ b/tests/test_release_manifests.py @@ -912,6 +912,41 @@ def test__given_us_unmanaged_dataset_uri__then_source_is_not_rewritten(self): "/tmp/cps_2023.h5" ) + def test__given_us_unmanaged_local_path__then_dataset_reaches_microsimulation( + self, tmp_path + ): + dataset_path = tmp_path / "local_build_2100.h5" + dataset_path.write_bytes(b"not a real h5; source plumbing only") + + mock_microsimulation = MagicMock() + with ( + patch.dict( + sys.modules, + _country_modules_with_microsimulation( + "policyengine_us", + mock_microsimulation, + ), + ), + patch( + "policyengine.tax_benefit_models.common.model_version.certify_data_release_compatibility", + return_value=get_release_manifest("us").certification, + ), + ): + us_model = importlib.import_module( + "policyengine.tax_benefit_models.us.model" + ) + microsim = us_model.managed_microsimulation( + dataset=str(dataset_path), + allow_unmanaged=True, + ) + + assert mock_microsimulation.call_args.kwargs["dataset"] == str(dataset_path) + assert microsim.policyengine_bundle["runtime_dataset"] == "local_build_2100" + assert microsim.policyengine_bundle["runtime_dataset_uri"] == str(dataset_path) + assert microsim.policyengine_bundle["runtime_dataset_source"] == str( + dataset_path + ) + def test__given_uk_managed_dataset_name__then_resolves_within_bundle(self): mock_microsimulation = MagicMock() with ( diff --git a/uv.lock b/uv.lock index 5cf26e02..dd39bb1b 100644 --- a/uv.lock +++ b/uv.lock @@ -2820,7 +2820,7 @@ wheels = [ [[package]] name = "policyengine" -version = "4.18.7" +version = "4.18.10" source = { editable = "." } dependencies = [ { name = "diskcache" },