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]