|
| 1 | +import numpy as np |
| 2 | + |
| 3 | +from policyengine_uk import Simulation |
| 4 | +from policyengine_uk.scenarios import abolish_benefit_cap |
| 5 | + |
| 6 | +BENEFIT_CAP_FAMILY = { |
| 7 | + "people": { |
| 8 | + "parent1": {"age": {2026: 30}, "employment_income": {2026: 0}}, |
| 9 | + "parent2": {"age": {2026: 28}, "employment_income": {2026: 0}}, |
| 10 | + "child1": {"age": {2026: 6}}, |
| 11 | + "child2": {"age": {2026: 3}}, |
| 12 | + "child3": {"age": {2026: 1}}, |
| 13 | + }, |
| 14 | + "benunits": { |
| 15 | + "family": {"members": ["parent1", "parent2", "child1", "child2", "child3"]} |
| 16 | + }, |
| 17 | + "households": { |
| 18 | + "home": { |
| 19 | + "members": ["parent1", "parent2", "child1", "child2", "child3"], |
| 20 | + "rent": {2026: 24_000}, |
| 21 | + } |
| 22 | + }, |
| 23 | +} |
| 24 | + |
| 25 | + |
| 26 | +class TestAbolishBenefitCapScenario: |
| 27 | + def test_removes_benefit_cap_reduction(self): |
| 28 | + baseline = Simulation(situation=BENEFIT_CAP_FAMILY) |
| 29 | + reformed = Simulation( |
| 30 | + situation=BENEFIT_CAP_FAMILY, scenario=abolish_benefit_cap |
| 31 | + ) |
| 32 | + |
| 33 | + baseline_reduction = baseline.calculate("benefit_cap_reduction", 2026) |
| 34 | + baseline_uc = baseline.calculate("universal_credit", 2026) |
| 35 | + reformed_cap = reformed.calculate("benefit_cap", 2026) |
| 36 | + reformed_reduction = reformed.calculate("benefit_cap_reduction", 2026) |
| 37 | + reformed_uc = reformed.calculate("universal_credit", 2026) |
| 38 | + reformed_uc_pre_cap = reformed.calculate( |
| 39 | + "universal_credit_pre_benefit_cap", 2026 |
| 40 | + ) |
| 41 | + |
| 42 | + assert baseline_reduction[0] > 0 |
| 43 | + assert np.isfinite(baseline.calculate("benefit_cap", 2026)[0]) |
| 44 | + assert np.isinf(reformed_cap[0]) |
| 45 | + assert reformed_reduction.tolist() == [0.0] |
| 46 | + assert reformed_uc.tolist() == reformed_uc_pre_cap.tolist() |
| 47 | + assert reformed_uc[0] > baseline_uc[0] |
0 commit comments