From 760648033874e976eba40eafcdc29c85c751d1ce Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 7 Jul 2026 12:00:07 +0000 Subject: [PATCH] =?UTF-8?q?An=20oversized=20postcode=20becomes=20its=20own?= =?UTF-8?q?=20batch=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Behavior emerged from the packing rule — pinned straight to green. Co-Authored-By: Claude Fable 5 --- tests/backend/app/modelling/test_batching.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/backend/app/modelling/test_batching.py b/tests/backend/app/modelling/test_batching.py index a7f196036..635f80e0b 100644 --- a/tests/backend/app/modelling/test_batching.py +++ b/tests/backend/app/modelling/test_batching.py @@ -28,3 +28,16 @@ def test_postcodes_are_never_split_across_batches() -> None: in_batch = [p for p in batch if p.postcode == postcode] everywhere = [p for p in properties if p.postcode == postcode] assert len(in_batch) == len(everywhere) # whole postcode, one batch + + +def test_an_oversized_postcode_becomes_its_own_batch() -> None: + # arrange — one postcode alone exceeds the cap; neighbours are unaffected + properties = _properties("B93 8SU", 60, start_id=0) + _properties( + "M20 4TF", 20, start_id=100 + ) + + # act + batches = pack_postcode_batches(properties, batch_size=50) + + # assert + assert [len(b) for b in batches] == [60, 20]