Skip to content

Commit 676899a

Browse files
Merge pull request #796 from NHSDigital/tallying-totals
tallying totals verification
2 parents d2d8385 + 321c8ca commit 676899a

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

mavis/test/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class TallyCategory(StrEnum):
142142
DUE_VACCINATION = "Due vaccination"
143143
DUE_INJECTION = "Due injection"
144144
DUE_NASAL_SPRAY = "Due nasal spray"
145+
NEEDS_TRIAGE = "Needs triage"
146+
UNABLE_TO_VACCINATE = "Unable to vaccinate"
145147

146148

147149
class Programme(StrEnum):
@@ -261,14 +263,16 @@ def tally_categories(self) -> list[str]:
261263
TallyCategory.NEEDS_CONSENT,
262264
TallyCategory.HAS_A_REFUSAL,
263265
TallyCategory.VACCINATED,
266+
TallyCategory.NEEDS_TRIAGE,
267+
TallyCategory.UNABLE_TO_VACCINATE,
264268
]
265269
if self is self.FLU:
266270
return [
267271
*common_categories,
268272
TallyCategory.DUE_INJECTION,
269273
TallyCategory.DUE_NASAL_SPRAY,
270274
]
271-
return [*common_categories, TallyCategory.DUE_VACCINATION]
275+
return [*common_categories]
272276

273277

274278
class Vaccine(StrEnum):

tests/test_tallying.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,44 @@ def test_tallying( # noqa: PLR0915
168168
tally_totals[TallyCategory.DUE_NASAL_SPRAY] -= 1
169169
tally_totals[TallyCategory.VACCINATED] += 1
170170
sessions_overview_page.check_all_totals(tally_totals)
171+
172+
173+
@issue("MAV-2689")
174+
@pytest.mark.parametrize(
175+
"programme", list(Programme), ids=lambda p: f"Programme: {p.value}"
176+
)
177+
def test_tallying_totals_match_eligible_patients(
178+
setup_fixed_child,
179+
sessions_overview_page,
180+
sessions_children_page,
181+
programme,
182+
children,
183+
schools,
184+
):
185+
"""
186+
Test: Verify that tallying totals match the number of eligible patients.
187+
Steps:
188+
1. Navigate to a session with eligible patients for the given programme.
189+
2. Compare the sum of the tally boxes with the count of eligible patients.
190+
Verification:
191+
- Sum of tally totals should equal the number of eligible children shown
192+
on the children tab.
193+
"""
194+
# Get tally totals for the programme
195+
tally_totals = sessions_overview_page.get_all_totals(programme)
196+
sum_of_tally_totals = sum(tally_totals.values())
197+
198+
# Navigate to children tab to count eligible children
199+
sessions_overview_page.click_children_tab()
200+
201+
# Count all children cards displayed (these are the eligible children)
202+
children_cards = sessions_children_page.page.locator(
203+
"div.nhsuk-card.app-card.app-card--compact:has(h4)"
204+
)
205+
eligible_children_count = children_cards.count()
206+
207+
# Verify that the sum of tally totals equals the number of eligible children
208+
assert sum_of_tally_totals == eligible_children_count, (
209+
f"Sum of tally totals ({sum_of_tally_totals}) does not match "
210+
f"eligible children count ({eligible_children_count}) for {programme}"
211+
)

0 commit comments

Comments
 (0)