From e2eaf659c6fe3f4505c17ba772897f5e5de2b0fe Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 31 Jan 2026 16:33:43 -0500 Subject: [PATCH] Add coverage tests for 4 untested variables Add YAML tests for: - tax_unit_state: verifies state code propagation to tax unit - emp_self_emp_ratio: tests employment vs self-employment ratio calculation - is_premium_free_part_a: tests Medicare Part A premium-free eligibility - savers_credit_credit_limit: tests retirement savings credit limit calculation Co-Authored-By: Claude Opus 4.5 --- changelog_entry.yaml | 4 +++ .../part_a/is_premium_free_part_a.yaml | 31 +++++++++++++++++++ .../savers_credit_credit_limit.yaml | 13 ++++++++ .../geographic/tax_unit_state.yaml | 13 ++++++++ .../household/emp_self_emp_ratio.yaml | 31 +++++++++++++++++++ 5 files changed, 92 insertions(+) create mode 100644 policyengine_us/tests/variables/gov/hhs/medicare/eligibility/part_a/is_premium_free_part_a.yaml create mode 100644 policyengine_us/tests/variables/gov/irs/credits/retirement_savings/savers_credit_credit_limit.yaml create mode 100644 policyengine_us/tests/variables/household/demographic/geographic/tax_unit_state.yaml create mode 100644 policyengine_us/tests/variables/household/emp_self_emp_ratio.yaml diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..6d5d0bbabba 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + added: + - Add tests for tax_unit_state, emp_self_emp_ratio, is_premium_free_part_a, and savers_credit_credit_limit variables diff --git a/policyengine_us/tests/variables/gov/hhs/medicare/eligibility/part_a/is_premium_free_part_a.yaml b/policyengine_us/tests/variables/gov/hhs/medicare/eligibility/part_a/is_premium_free_part_a.yaml new file mode 100644 index 00000000000..ae4e3a6a909 --- /dev/null +++ b/policyengine_us/tests/variables/gov/hhs/medicare/eligibility/part_a/is_premium_free_part_a.yaml @@ -0,0 +1,31 @@ +- name: Person with 40 quarters qualifies for premium-free Part A + period: 2024 + input: + age: 66 + medicare_quarters_of_coverage: 40 + output: + is_premium_free_part_a: true + +- name: Person with more than 40 quarters qualifies for premium-free Part A + period: 2024 + input: + age: 66 + medicare_quarters_of_coverage: 50 + output: + is_premium_free_part_a: true + +- name: Person with less than 40 quarters does not qualify + period: 2024 + input: + age: 66 + medicare_quarters_of_coverage: 39 + output: + is_premium_free_part_a: false + +- name: Person not Medicare eligible returns zero + period: 2024 + input: + age: 50 + medicare_quarters_of_coverage: 40 + output: + is_premium_free_part_a: false diff --git a/policyengine_us/tests/variables/gov/irs/credits/retirement_savings/savers_credit_credit_limit.yaml b/policyengine_us/tests/variables/gov/irs/credits/retirement_savings/savers_credit_credit_limit.yaml new file mode 100644 index 00000000000..c340c3c4124 --- /dev/null +++ b/policyengine_us/tests/variables/gov/irs/credits/retirement_savings/savers_credit_credit_limit.yaml @@ -0,0 +1,13 @@ +- name: Savers credit limit equals income tax before credits with no preceding credits + period: 2024 + input: + income_tax_before_credits: 5000 + output: + savers_credit_credit_limit: 5000 + +- name: Savers credit limit is zero when income tax before credits is zero + period: 2024 + input: + income_tax_before_credits: 0 + output: + savers_credit_credit_limit: 0 diff --git a/policyengine_us/tests/variables/household/demographic/geographic/tax_unit_state.yaml b/policyengine_us/tests/variables/household/demographic/geographic/tax_unit_state.yaml new file mode 100644 index 00000000000..6befa7df6e5 --- /dev/null +++ b/policyengine_us/tests/variables/household/demographic/geographic/tax_unit_state.yaml @@ -0,0 +1,13 @@ +- name: Tax unit state reflects household state + period: 2024 + input: + state_code_str: CA + output: + tax_unit_state: CA + +- name: Tax unit state with different state + period: 2024 + input: + state_code_str: NY + output: + tax_unit_state: NY diff --git a/policyengine_us/tests/variables/household/emp_self_emp_ratio.yaml b/policyengine_us/tests/variables/household/emp_self_emp_ratio.yaml new file mode 100644 index 00000000000..562ce5d4d03 --- /dev/null +++ b/policyengine_us/tests/variables/household/emp_self_emp_ratio.yaml @@ -0,0 +1,31 @@ +- name: Employment income only returns ratio of 1 + period: 2024 + input: + employment_income: 50000 + self_employment_income: 0 + output: + emp_self_emp_ratio: 1.0 + +- name: Self-employment income only returns ratio of 0 + period: 2024 + input: + employment_income: 0 + self_employment_income: 50000 + output: + emp_self_emp_ratio: 0.0 + +- name: Equal employment and self-employment returns ratio of 0.5 + period: 2024 + input: + employment_income: 25000 + self_employment_income: 25000 + output: + emp_self_emp_ratio: 0.5 + +- name: Zero earnings returns ratio of 1 (default) + period: 2024 + input: + employment_income: 0 + self_employment_income: 0 + output: + emp_self_emp_ratio: 1.0