Skip to content

Commit 375b244

Browse files
authored
Merge pull request #62 from NHSDigital/8998-more-tests
Additional tests for the cannot go ahead page
2 parents 258fe6c + 0ed876e commit 375b244

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

manage_breast_screening/record_a_mammogram/tests/system/test_user_submits_cannot_go_ahead_form.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,8 @@ def then_i_see_the_clinics_page(self):
8282
def and_the_appointment_is_updated(self):
8383
self.appointment.refresh_from_db()
8484
self.assertEqual(self.appointment.status, Appointment.Status.ATTENDED_NOT_SCREENED)
85+
self.assertEqual(self.appointment.reinvite, True)
86+
self.assertEqual(self.appointment.stopped_reasons, {
87+
"stopped_reasons": ["failed_identity_check", "other"],
88+
"other_details": "Explain other choice"
89+
})
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
from pytest_django.asserts import assertFormError
2+
import pytest
23

3-
from ..forms import ScreeningAppointmentForm
4+
from manage_breast_screening.clinics.tests.factories import AppointmentFactory
5+
from ..forms import AppointmentCannotGoAheadForm, ScreeningAppointmentForm
46

57

68
class TestScreeningAppointmentForm:
79
def test_decision_cannot_be_left_blank(self):
810
form = ScreeningAppointmentForm({})
911
assertFormError(form, "decision", ["This field is required."])
12+
13+
@pytest.mark.django_db
14+
class TestAppointmentCannotGoAheadForm:
15+
@pytest.mark.parametrize("decision,reinvite_value", [("True", True), ("False", False)])
16+
def test_reinvite_reflects_form_data(self, decision, reinvite_value):
17+
appointment = AppointmentFactory()
18+
assert appointment.reinvite == False
19+
20+
form_data = {
21+
"stopped_reasons": ["failed_identity_check"],
22+
"decision": decision,
23+
}
24+
form = AppointmentCannotGoAheadForm(form_data, instance=appointment)
25+
form.is_valid()
26+
form.save()
27+
appointment.refresh_from_db()
28+
assert appointment.reinvite == reinvite_value

0 commit comments

Comments
 (0)