|
1 | 1 | from policyengine_household_api.modal_release import _image_setup |
2 | 2 |
|
3 | 3 |
|
| 4 | +def test_worker_image_uses_uv_for_package_version_overlays(monkeypatch): |
| 5 | + from policyengine_household_api.modal_release import images |
| 6 | + |
| 7 | + calls = [] |
| 8 | + |
| 9 | + class FakeImage: |
| 10 | + def uv_sync(self, *args, **kwargs): |
| 11 | + calls.append(("uv_sync", args, kwargs)) |
| 12 | + return self |
| 13 | + |
| 14 | + def uv_pip_install(self, *packages): |
| 15 | + calls.append(("uv_pip_install", packages, {})) |
| 16 | + return self |
| 17 | + |
| 18 | + def pip_install(self, *packages): |
| 19 | + raise AssertionError( |
| 20 | + f"worker image should use uv_pip_install, got {packages}" |
| 21 | + ) |
| 22 | + |
| 23 | + def add_local_python_source(self, *args, **kwargs): |
| 24 | + calls.append(("add_local_python_source", args, kwargs)) |
| 25 | + return self |
| 26 | + |
| 27 | + def add_local_dir(self, *args, **kwargs): |
| 28 | + calls.append(("add_local_dir", args, kwargs)) |
| 29 | + return self |
| 30 | + |
| 31 | + def run_function(self, *args, **kwargs): |
| 32 | + calls.append(("run_function", args, kwargs)) |
| 33 | + return self |
| 34 | + |
| 35 | + def debian_slim(*args, **kwargs): |
| 36 | + calls.append(("debian_slim", args, kwargs)) |
| 37 | + return FakeImage() |
| 38 | + |
| 39 | + monkeypatch.setenv( |
| 40 | + images.PACKAGE_VERSIONS_ENV, |
| 41 | + '{"uk":"2.31.0","us":"1.691.1"}', |
| 42 | + ) |
| 43 | + monkeypatch.setattr(images.modal.Image, "debian_slim", debian_slim) |
| 44 | + |
| 45 | + images.household_api_worker_image() |
| 46 | + |
| 47 | + assert ( |
| 48 | + "uv_pip_install", |
| 49 | + ( |
| 50 | + "policyengine_uk==2.31.0", |
| 51 | + "policyengine_us==1.691.1", |
| 52 | + ), |
| 53 | + {}, |
| 54 | + ) in calls |
| 55 | + |
| 56 | + |
4 | 57 | def test_snapshot_tax_benefit_systems_preloads_all_country_packages( |
5 | 58 | monkeypatch, |
6 | 59 | ): |
|
0 commit comments