From d83c6d93e2028bec7d331267ca1304e39cc824d6 Mon Sep 17 00:00:00 2001 From: Tom Brooks Date: Mon, 13 Jul 2026 10:50:05 +0100 Subject: [PATCH] fix: remove stage dependent mandatory fields for plans datasets --- digital_land/phase/harmonise.py | 9 ------ tests/unit/phase/test_harmonise.py | 50 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/digital_land/phase/harmonise.py b/digital_land/phase/harmonise.py index 36ca8135..f78d02f6 100644 --- a/digital_land/phase/harmonise.py +++ b/digital_land/phase/harmonise.py @@ -90,11 +90,8 @@ "description", "dataset", "period-start-date", - "period-end-date", "local-planning-authorities", "documentation-url", - "document-url", - "required-housing", "entry-date", ], "supplementary-plan": [ @@ -103,10 +100,8 @@ "description", "dataset", "period-start-date", - "period-end-date", "local-planning-authorities", "documentation-url", - "document-url", "entry-date", ], "minerals-plan": [ @@ -115,10 +110,8 @@ "description", "dataset", "period-start-date", - "period-end-date", "minerals-and-waste-planning-authorities", "documentation-url", - "document-url", "document-count", "entry-date", ], @@ -128,10 +121,8 @@ "description", "dataset", "period-start-date", - "period-end-date", "minerals-and-waste-planning-authorities", "documentation-url", - "document-url", "document-count", "entry-date", ], diff --git a/tests/unit/phase/test_harmonise.py b/tests/unit/phase/test_harmonise.py index 7fc33530..c8dc9c4f 100755 --- a/tests/unit/phase/test_harmonise.py +++ b/tests/unit/phase/test_harmonise.py @@ -157,6 +157,56 @@ def test_harmonise_missing_mandatory_values(): assert issue["value"] == "" +def test_harmonise_stage_dependent_plan_fields_not_flagged(): + # period-end-date, document-url and required-housing are stage-dependent for + # the plan datasets: they should only be required once the LPA has reached + # proposed-plan-consultation-start. They must NOT be flagged as "missing + # value" when blank here — that check moves to a post-build expectation. + issues = IssueLog() + field_datatype_map = { + "reference": "string", + "name": "string", + "description": "string", + "dataset": "string", + "period-start-date": "datetime", + "period-end-date": "datetime", + "local-planning-authorities": "string", + "documentation-url": "url", + "document-url": "url", + "required-housing": "integer", + "entry-date": "datetime", + } + + h = HarmonisePhase( + field_datatype_map=field_datatype_map, + issues=issues, + dataset="local-plan", + ) + reader = FakeDictReader( + [ + { + "reference": "camden-local-plan", + "name": "Camden Local Plan", + "description": "A plan", + "dataset": "local-plan", + "period-start-date": "2020-01-01", + "period-end-date": "", + "local-planning-authorities": "local-authority:CMD", + "documentation-url": "https://example.com/docs", + "document-url": "", + "required-housing": "", + "entry-date": "2026-01-01", + }, + ], + ) + list(h.process(reader)) + + flagged = {issue["field"] for issue in issues.rows} + assert "period-end-date" not in flagged + assert "document-url" not in flagged + assert "required-housing" not in flagged + + def test_get_field_datatype_name_uses_field_datatype_map(): field_datatype_map = {"reference": "string"} phase = HarmonisePhase(field_datatype_map=field_datatype_map)