"""Tests for `default_tier_pool_share` — the assumed per-parent tier share used when no FK snapshot exists yet. See its docstring in `app/utils/tip_predicates.py` and the "Bug A" history: `AllocationInputLoader.load` and `PlanningService._tier_pool_left` must never derive this differently, which is why it takes an explicit `parent_count` now instead of always halving (a sole parent gets the whole pool, not half of it). """ from app.config import settings from app.utils.tip_predicates import default_tier_pool_share class TestDefaultTierPoolShare: def test_sole_parent_gets_the_full_pool(self) -> None: sjuk, lagsta = default_tier_pool_share(settings.rules, parent_count=1) assert (sjuk, lagsta) == (390, 90) def test_zero_parents_is_treated_as_a_sole_parent(self) -> None: """Defensive: an empty workspace (shouldn't normally happen) still gets a sane default rather than a divide/half-of-nothing edge case.""" sjuk, lagsta = default_tier_pool_share(settings.rules, parent_count=0) assert (sjuk, lagsta) == (390, 90) def test_two_parents_split_the_pool_in_half(self) -> None: sjuk, lagsta = default_tier_pool_share(settings.rules, parent_count=2) assert (sjuk, lagsta) == (195, 45) def test_more_than_two_parents_still_splits_in_half(self) -> None: """The domain model caps workspaces at 2 parents (see `WorkspaceService.add_placeholder_parent`), but this helper doesn't itself need to assume that cap holds -- any partnered case (>= 2) gets the halved share, matching FK's own per-parent allocation.""" sjuk, lagsta = default_tier_pool_share(settings.rules, parent_count=3) assert (sjuk, lagsta) == (195, 45)