Skip to content

Commit 0711b5c

Browse files
lint fixes
1 parent 4bf38e9 commit 0711b5c

5 files changed

Lines changed: 38 additions & 40 deletions

File tree

src/rules_validation_api/validators/campaign_config_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic import Field, field_validator
1+
from pydantic import Field
22

33
from eligibility_signposting_api.model.campaign_config import CampaignConfig
44
from rules_validation_api.validators.iteration_validator import IterationValidation

src/rules_validation_api/validators/iteration_validator.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ def validate_default_comms_routing_in_actions_mapper(self):
1818
if default_routing:
1919
if not actions_mapper or default_routing not in actions_mapper:
2020
error = InitErrorDetails(
21-
type='value_error',
22-
loc=('actions_mapper',),
21+
type="value_error",
22+
loc=("actions_mapper",),
2323
input=actions_mapper,
24-
ctx={'error': f"Missing entry for DefaultCommsRouting '{default_routing}' in ActionsMapper"}
25-
)
26-
raise ValidationError.from_exception_data(
27-
title='IterationValidation',
28-
line_errors=[error]
24+
ctx={"error": f"Missing entry for DefaultCommsRouting '{default_routing}' in ActionsMapper"},
2925
)
26+
raise ValidationError.from_exception_data(title="IterationValidation", line_errors=[error])
3027

3128
return self

tests/unit/validation/conftest.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ def valid_campaign_config_with_only_mandatory_fields():
2828
"DefaultNotActionableRouting": "RouteC",
2929
"IterationCohorts": [],
3030
"IterationRules": [],
31-
"ActionsMapper":
32-
{
33-
"BOOK_NBS":
34-
{
35-
"ExternalRoutingCode": "BookNBS",
36-
"ActionDescription": "",
37-
"ActionType": "ButtonWithAuthLink",
38-
"UrlLink": "http://www.nhs.uk/book-rsv",
39-
"UrlLabel": "Continue to booking"
40-
}
31+
"ActionsMapper": {
32+
"BOOK_NBS": {
33+
"ExternalRoutingCode": "BookNBS",
34+
"ActionDescription": "",
35+
"ActionType": "ButtonWithAuthLink",
36+
"UrlLink": "http://www.nhs.uk/book-rsv",
37+
"UrlLabel": "Continue to booking",
4138
}
39+
},
4240
}
4341
],
4442
}
@@ -67,5 +65,5 @@ def valid_available_action():
6765
"ActionDescription": "",
6866
"ActionType": "ButtonWithAuthLink",
6967
"UrlLink": "http://www.nhs.uk/book-rsv",
70-
"UrlLabel": "Continue to booking"
68+
"UrlLabel": "Continue to booking",
7169
}

tests/unit/validation/test_available_action_validator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
# 🔍 Mandatory Fields
1010
class TestMandatoryFieldsSchemaValidations:
11-
1211
def test_valid_minimal_input(self, valid_available_action):
1312
data = copy.deepcopy(valid_available_action)
1413
data.pop("ActionDescription")
@@ -34,7 +33,6 @@ def test_missing_required_fields(self, valid_available_action):
3433

3534
# 🔍 Optional Fields
3635
class TestOptionalFieldsSchemaValidations:
37-
3836
def test_valid_full_input(self, valid_available_action):
3937
action = AvailableActionValidation(**valid_available_action)
4038
assert action.action_type == "ButtonWithAuthLink"

tests/unit/validation/test_iteration_validator.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,34 +143,39 @@ def test_approval_maximum(self, approval_maximum, valid_campaign_config_with_onl
143143

144144

145145
class TestIterationCohortsSchemaValidations:
146-
def test_valid_iteration_if_actions_mapper_has_entry_for_the_provided_default_routing_key(self, valid_campaign_config_with_only_mandatory_fields):
146+
def test_valid_iteration_if_actions_mapper_has_entry_for_the_provided_default_routing_key(
147+
self, valid_campaign_config_with_only_mandatory_fields
148+
):
147149
expected_action = {
148150
"ExternalRoutingCode": "BookLocal",
149151
"ActionDescription": "##Getting the vaccine\n"
150-
"You can get an RSV vaccination at your GP surgery.\n"
151-
"Your GP surgery may contact you about getting the RSV vaccine. "
152-
"This may be by letter, text, phone call, email or through the NHS App. "
153-
"You do not need to wait to be contacted before booking your vaccination.",
154-
"ActionType": "InfoText"
152+
"You can get an RSV vaccination at your GP surgery.\n"
153+
"Your GP surgery may contact you about getting the RSV vaccine. "
154+
"This may be by letter, text, phone call, email or through the NHS App. "
155+
"You do not need to wait to be contacted before booking your vaccination.",
156+
"ActionType": "InfoText",
155157
}
156158

157-
data = {**valid_campaign_config_with_only_mandatory_fields["Iterations"][0],
158-
"DefaultCommsRouting": "BOOK_LOCAL", "ActionsMapper": {
159-
"BOOK_LOCAL": expected_action
160-
}}
159+
data = {
160+
**valid_campaign_config_with_only_mandatory_fields["Iterations"][0],
161+
"DefaultCommsRouting": "BOOK_LOCAL",
162+
"ActionsMapper": {"BOOK_LOCAL": expected_action},
163+
}
161164
IterationValidation(**data)
162165

163-
def test_invalid_iteration_if_actions_mapper_has_no_entry_for_the_provided_default_routing_key(self, valid_campaign_config_with_only_mandatory_fields):
164-
data = {**valid_campaign_config_with_only_mandatory_fields["Iterations"][0],
165-
"DefaultCommsRouting": "BOOK_LOCAL", "ActionsMapper": {}} # Missing BOOK_LOCAL in ActionsMapper
166+
def test_invalid_iteration_if_actions_mapper_has_no_entry_for_the_provided_default_routing_key(
167+
self, valid_campaign_config_with_only_mandatory_fields
168+
):
169+
data = {
170+
**valid_campaign_config_with_only_mandatory_fields["Iterations"][0],
171+
"DefaultCommsRouting": "BOOK_LOCAL",
172+
"ActionsMapper": {},
173+
} # Missing BOOK_LOCAL in ActionsMapper
166174

167175
with pytest.raises(ValidationError) as error:
168176
IterationValidation(**data)
169177

170178
errors = error.value.errors()
171-
assert any(
172-
e["loc"][-1] == "actions_mapper" and "BOOK_LOCAL" in str(e["msg"])
173-
for e in errors
174-
), "Expected validation error for missing BOOK_LOCAL entry in ActionsMapper"
175-
176-
179+
assert any(e["loc"][-1] == "actions_mapper" and "BOOK_LOCAL" in str(e["msg"]) for e in errors), (
180+
"Expected validation error for missing BOOK_LOCAL entry in ActionsMapper"
181+
)

0 commit comments

Comments
 (0)