From cbff7d2f9197583c0aeb645184fd379c34942a35 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Wed, 27 May 2026 11:11:24 +0200 Subject: [PATCH] Add three EntitledTo-style integration tests (#778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #778 asks for ~20 worked benefit scenarios checked against EntitledTo. This is a first batch of three covering the most common household shapes the calculator handles: 1. single 30-year-old working part-time on low pay, private renter in London (UC + child benefit zero, no income tax/NI), 2. couple with two children, one earner at £22k, social housing in North West (UC + child benefit, partial NI/income tax), 3. pensioner couple with low state pension, sits below Pension Credit guarantee level (PC payout + winter fuel allowance). Values are pinned to the current PolicyEngine output and the file is labelled as a regression-grade baseline rather than an authoritative EntitledTo cross-validation — future work is to manually re-run the matching cases through EntitledTo and tighten any rows where the two disagree, ratcheting up to the ~20-scenario coverage in the issue. Person-level variables (income_tax, national_insurance) can't be asserted with a single scalar when multiple people are in the benunit, so scenario 2 uses household_tax instead. --- changelog.d/778.md | 1 + .../integration/entitledto_scenarios.yaml | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 changelog.d/778.md create mode 100644 policyengine_uk/tests/policy/integration/entitledto_scenarios.yaml diff --git a/changelog.d/778.md b/changelog.d/778.md new file mode 100644 index 000000000..66418daf9 --- /dev/null +++ b/changelog.d/778.md @@ -0,0 +1 @@ +- Add three worked benefit scenarios at `policyengine_uk/tests/policy/integration/entitledto_scenarios.yaml` as a first batch of EntitledTo-style regression tests (single low-earner private renter, couple with two children in social housing, pensioner couple on the Pension Credit guarantee), seeding the ~20-scenario coverage suggested in #778. diff --git a/policyengine_uk/tests/policy/integration/entitledto_scenarios.yaml b/policyengine_uk/tests/policy/integration/entitledto_scenarios.yaml new file mode 100644 index 000000000..40bddabb5 --- /dev/null +++ b/policyengine_uk/tests/policy/integration/entitledto_scenarios.yaml @@ -0,0 +1,99 @@ +# Worked benefit scenarios for cross-checking against EntitledTo +# (https://www.entitledto.co.uk/), tracked in issue #778. +# +# These are pinned to PolicyEngine's current outputs and serve as +# regression tests rather than authoritative EntitledTo matches: the +# numbers were generated by running each scenario through PolicyEngine +# at the time the file was added. Future work is to manually run the +# matching cases through EntitledTo and tighten any rows where the two +# disagree, ratcheting up to the ~20-scenario coverage suggested in #778. + +- name: "EntitledTo #1 - single 30yo working part-time at low pay, private renter in London" + period: 2025 + absolute_error_margin: 1 + input: + people: + adult: + age: 30 + employment_income: 12_000 + benunits: + benunit: + members: [adult] + households: + household: + members: [adult] + rent: 8_000 + council_tax: 1_200 + region: LONDON + country: ENGLAND + tenure_type: RENT_PRIVATELY + output: + income_tax: 0 + national_insurance: 0 + universal_credit: 3_662.72 + housing_benefit: 0 + child_benefit: 0 + household_net_income: 14_303.68 + +- name: "EntitledTo #2 - couple with 2 children, one earner at £22k, social housing in North West" + period: 2025 + absolute_error_margin: 1 + input: + people: + adult_1: + age: 35 + employment_income: 22_000 + adult_2: + age: 35 + child_1: + age: 5 + child_2: + age: 3 + benunits: + benunit: + members: [adult_1, adult_2, child_1, child_2] + households: + household: + members: [adult_1, adult_2, child_1, child_2] + rent: 6_000 + council_tax: 1_500 + region: NORTH_WEST + country: ENGLAND + tenure_type: RENT_FROM_COUNCIL + output: + # Household-level aggregates only — per-person income_tax / NI can't be + # asserted with a single scalar when multiple people are in the benunit. + household_tax: 4_047.45 + universal_credit: 12_490.86 + housing_benefit: 0 + child_benefit: 2_251.60 + household_net_income: 36_130.40 + +- name: "EntitledTo #3 - pensioner couple, low state pension, qualifies for Pension Credit" + period: 2025 + absolute_error_margin: 1 + input: + people: + pensioner_1: + age: 70 + state_pension: 8_000 + pensioner_2: + age: 68 + state_pension: 6_000 + benunits: + benunit: + members: [pensioner_1, pensioner_2] + households: + household: + members: [pensioner_1, pensioner_2] + region: WEST_MIDLANDS + country: ENGLAND + council_tax: 1_800 + output: + universal_credit: 0 + housing_benefit: 0 + pension_credit: 3_607.72 + winter_fuel_allowance: 200 + income_tax: 0 + national_insurance: 0 + household_net_income: 15_848.68