Skip to content

Commit 8581406

Browse files
authored
Eli 782/add constant and field for configurable status text (#631)
* added status_text_override constant and tests * added tests to test_status * created test to show override working * updated tests to use hamcrest
1 parent a877fc2 commit 8581406

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

src/eligibility_signposting_api/config/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
CONSUMER_MAPPING_FILE_NAME = "consumer_mapping_config.json"
1010

1111
CACHE_TTL_SECONDS = int(os.getenv("CONFIG_CACHE_TTL_SECONDS", "1800"))
12+
STATUS_TEXT_OVERRIDE_ACTION_TYPE = "norender_StatusTextOverride"

src/eligibility_signposting_api/model/eligibility_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class MatchedActionDetail:
151151
rule_name: campaign_config.RuleName | None = None
152152
rule_priority: campaign_config.RulePriority | None = None
153153
actions: list[SuggestedAction] | None = None
154+
status_text_override: StatusText | None = None
154155

155156

156157
@dataclass

tests/unit/config/test_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from yarl import URL
55

66
from eligibility_signposting_api.config.config import LOG_LEVEL, AwsAccessKey, AwsRegion, AwsSecretAccessKey, config
7+
from eligibility_signposting_api.config.constants import STATUS_TEXT_OVERRIDE_ACTION_TYPE
78
from eligibility_signposting_api.repos.campaign_repo import BucketName
89
from eligibility_signposting_api.repos.person_repo import TableName
910

@@ -48,3 +49,7 @@ def test_config_without_env_variable():
4849
assert config_data_without_env["s3_endpoint"] == URL("http://localhost:4566")
4950
assert config_data_without_env["rules_bucket_name"] == BucketName("test-rules-bucket")
5051
assert config_data_without_env["log_level"] == LOG_LEVEL
52+
53+
54+
def test_status_text_override_action_type_constant_value():
55+
assert STATUS_TEXT_OVERRIDE_ACTION_TYPE == "norender_StatusTextOverride"

tests/unit/model/test_status.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
from eligibility_signposting_api.model.eligibility_status import ConditionName, RuleType, Status, StatusText
1+
from hamcrest import assert_that, has_properties
2+
3+
from eligibility_signposting_api.model.campaign_config import RuleName, RulePriority
4+
from eligibility_signposting_api.model.eligibility_status import (
5+
ConditionName,
6+
MatchedActionDetail,
7+
RuleType,
8+
Status,
9+
StatusText,
10+
SuggestedAction,
11+
)
212

313

414
class TestStatus:
@@ -45,3 +55,49 @@ def test_get_action_rule_type(self):
4555
assert Status.not_actionable.get_action_rule_type() == RuleType(RuleType.not_actionable_actions)
4656

4757
assert Status.actionable.get_action_rule_type() == RuleType(RuleType.redirect)
58+
59+
60+
def test_matched_action_detail_default_status_text_override_is_none():
61+
action_detail = MatchedActionDetail()
62+
63+
assert_that(action_detail, has_properties(status_text_override=None))
64+
65+
66+
def test_matched_action_detail_stores_status_text_override_value():
67+
action_detail = MatchedActionDetail(status_text_override=StatusText("X"))
68+
69+
assert_that(action_detail, has_properties(status_text_override=StatusText("X")))
70+
71+
72+
def test_matched_action_detail_existing_constructor_still_works_with_three_args():
73+
actions: list[SuggestedAction] = []
74+
75+
action_detail = MatchedActionDetail(RuleName("RuleA"), RulePriority(1), actions)
76+
77+
assert_that(
78+
action_detail,
79+
has_properties(
80+
rule_name=RuleName("RuleA"),
81+
rule_priority=RulePriority(1),
82+
actions=actions,
83+
status_text_override=StatusText(None),
84+
),
85+
)
86+
87+
88+
def test_matched_action_detail_existing_constructor_works_with_four_args():
89+
actions: list[SuggestedAction] = []
90+
91+
action_detail = MatchedActionDetail(
92+
RuleName("RuleA"), RulePriority(1), actions, status_text_override=StatusText("Override")
93+
)
94+
95+
assert_that(
96+
action_detail,
97+
has_properties(
98+
rule_name=RuleName("RuleA"),
99+
rule_priority=RulePriority(1),
100+
actions=actions,
101+
status_text_override=StatusText("Override"),
102+
),
103+
)

0 commit comments

Comments
 (0)