From d845709478f7e5bfe37c0dfb25cef5600435cac3 Mon Sep 17 00:00:00 2001 From: edithatogo <15080672+edithatogo@users.noreply.github.com> Date: Fri, 7 Aug 2026 06:29:12 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20testing=20for=20float=20pa?= =?UTF-8?q?rsing=20error=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/tests/test_public_source_transforms.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/models/tests/test_public_source_transforms.py b/models/tests/test_public_source_transforms.py index c2b4892..a413682 100644 --- a/models/tests/test_public_source_transforms.py +++ b/models/tests/test_public_source_transforms.py @@ -8,6 +8,7 @@ from models.primarycare_model.data.public_source_transforms import ( check_source_transform_readiness, transform_public_source, + _safe_float, verify_public_source_transform_scripts, ) @@ -72,3 +73,14 @@ def test_statsnz_transform_writes_schema_valid_public_aggregate() -> None: with output.artifact.open(encoding="utf-8", newline="") as handle: rows = list(csv.DictReader(handle)) assert rows == [{"jurisdiction": "NZ", "year": "2026", "population_count": "5361300"}] + + +def test_safe_float() -> None: + assert _safe_float("123.45") == 123.45 + assert _safe_float("0.0") == 0.0 + assert _safe_float("-1.5") == -1.5 + + # Error paths (should return None) + assert _safe_float("abc") is None + assert _safe_float("") is None + assert _safe_float(None) is None