Skip to content

Commit caa27f3

Browse files
Test get value from all attribute_levels
1 parent 7f199f3 commit caa27f3

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from collections.abc import Collection, Mapping
2+
from typing import Any
3+
4+
import pytest
5+
6+
from eligibility_signposting_api.model import rules
7+
from eligibility_signposting_api.services.calculators.rule_calculator import RuleCalculator
8+
from tests.fixtures.builders.model import rule as rule_builder
9+
10+
Row = Collection[Mapping[str, Any]]
11+
12+
13+
@pytest.mark.parametrize(
14+
("person_data", "rule", "expected"),
15+
[
16+
# PERSON attribute level
17+
(
18+
[{"ATTRIBUTE_TYPE": "PERSON", "POSTCODE": "SW19"}],
19+
rule_builder.IterationRuleFactory.build(
20+
attribute_level=rules.RuleAttributeLevel.PERSON, attribute_name="POSTCODE"
21+
),
22+
"SW19",
23+
),
24+
# TARGET attribute level
25+
(
26+
[{"ATTRIBUTE_TYPE": "RSV", "LAST_SUCCESSFUL_DATE": "20240101"}],
27+
rule_builder.IterationRuleFactory.build(
28+
attribute_level=rules.RuleAttributeLevel.TARGET,
29+
attribute_name="LAST_SUCCESSFUL_DATE",
30+
attribute_target="RSV",
31+
),
32+
"20240101",
33+
),
34+
# COHORT attribute level
35+
(
36+
[{"ATTRIBUTE_TYPE": "COHORTS", "COHORT_LABEL": ""}],
37+
rule_builder.IterationRuleFactory.build(
38+
attribute_level=rules.RuleAttributeLevel.COHORT, attribute_name="COHORT_LABEL"
39+
),
40+
"",
41+
),
42+
],
43+
)
44+
def test_get_attribute_value_for_all_attribute_levels(person_data: Row, rule: rules.IterationRule, expected: str):
45+
# Given
46+
calc = RuleCalculator(person_data=person_data, rule=rule)
47+
# When
48+
actual = calc.get_attribute_value()
49+
# Then
50+
assert actual == expected

0 commit comments

Comments
 (0)