Skip to content

Commit 32e2f3b

Browse files
WIP: empty strings and remove http url.
1 parent fac3739 commit 32e2f3b

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/eligibility_signposting_api/views/eligibility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def build_actions(condition: Condition) -> list[eligibility.Action] | None:
140140
description=eligibility.Description(action.action_description)
141141
if action.action_description is not None
142142
else None,
143-
urlLink=eligibility.HttpUrl(action.url_link) if action.url_link is not None else None,
144-
urlLabel=eligibility.UrlLabel(action.url_label) if action.url_label is not None else None,
143+
urlLink=eligibility.UrlLink(action.url_link),
144+
urlLabel=eligibility.UrlLabel(action.url_label),
145145
)
146146
for action in condition.actions
147147
]

src/eligibility_signposting_api/views/response_model/eligibility.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
CohortCode = NewType("CohortCode", str)
1717
CohortText = NewType("CohortText", str)
1818
UrlLabel = NewType("UrlLabel", str)
19+
UrlLink = NewType("UrlLink", str)
1920

2021

2122
class Status(StrEnum):
@@ -49,9 +50,9 @@ class SuitabilityRule(BaseModel):
4950
class Action(BaseModel):
5051
action_type: ActionType = Field(..., alias="actionType")
5152
action_code: ActionCode = Field(..., alias="actionCode")
52-
description: Description | None
53-
url_link: HttpUrl | None = Field(..., alias="urlLink")
54-
url_label: UrlLabel | None = Field(..., alias="urlLabel")
53+
description: Description = Field(default="")
54+
url_link: UrlLink = Field(default="", alias="urlLink" )
55+
url_label: UrlLabel = Field(default="", alias="urlLabel")
5556

5657
model_config = {"populate_by_name": True}
5758

tests/fixtures/builders/model/eligibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class SuggestedActionFactory(DataclassFactory[eligibility.SuggestedAction]):
13-
url_link = UrlLink(HttpUrl("https://test-example.com"))
13+
url_link = UrlLink("https://test-example.com")
1414

1515

1616
class ConditionFactory(DataclassFactory[eligibility.Condition]):

tests/unit/views/test_eligibility.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def test_no_suitability_rules_for_actionable():
398398
action_type=ActionType("TYPE_A"),
399399
action_code=ActionCode("CODE123"),
400400
action_description=ActionDescription("Some description"),
401-
url_link=UrlLink(HttpUrl("https://example.com")),
401+
url_link=UrlLink("https://example.com"),
402402
url_label=UrlLabel("Learn more"),
403403
)
404404
],
@@ -407,7 +407,7 @@ def test_no_suitability_rules_for_actionable():
407407
actionType=eligibility.ActionType("TYPE_A"),
408408
actionCode=eligibility.ActionCode("CODE123"),
409409
description=eligibility.Description("Some description"),
410-
urlLink=eligibility.HttpUrl("https://example.com"),
410+
urlLink=eligibility.UrlLink("https://example.com"),
411411
urlLabel=eligibility.UrlLabel("Learn more"),
412412
)
413413
],
@@ -426,9 +426,9 @@ def test_no_suitability_rules_for_actionable():
426426
eligibility.Action(
427427
actionType=eligibility.ActionType("TYPE_B"),
428428
actionCode=eligibility.ActionCode("CODE123"),
429-
description=None,
430-
urlLink=None,
431-
urlLabel=None,
429+
description="",
430+
urlLink="",
431+
urlLabel="",
432432
)
433433
],
434434
),
@@ -654,7 +654,7 @@ def test_build_response_include_values_that_are_not_null(client: FlaskClient):
654654
actionType=eligibility.ActionType("TYPE_A"),
655655
actionCode=eligibility.ActionCode("CODE123"),
656656
description=eligibility.Description("Contact GP"),
657-
urlLink=eligibility.HttpUrl(HttpUrl("https://example.dummy/")),
657+
urlLink=eligibility.UrlLink("https://example.dummy/"),
658658
urlLabel=eligibility.UrlLabel("GP contact"),
659659
)
660660
],

0 commit comments

Comments
 (0)