Skip to content

Commit 0ed876e

Browse files
committed
Update TestAppointmentCannotGoAheadForm test case
When testing how the reinvite decision is saved: - Use parametrize to make the test more succinct - Assert the starting value of reinvite prior to any changes
1 parent c09a115 commit 0ed876e

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

manage_breast_screening/record_a_mammogram/tests/test_forms.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,17 @@ def test_decision_cannot_be_left_blank(self):
1212

1313
@pytest.mark.django_db
1414
class TestAppointmentCannotGoAheadForm:
15-
def test_reinvite_reflects_form_data(self):
15+
@pytest.mark.parametrize("decision,reinvite_value", [("True", True), ("False", False)])
16+
def test_reinvite_reflects_form_data(self, decision, reinvite_value):
1617
appointment = AppointmentFactory()
17-
form_data = {
18-
"stopped_reasons": ["failed_identity_check"],
19-
"decision": "True",
20-
}
21-
form = AppointmentCannotGoAheadForm(form_data, instance=appointment)
22-
form.is_valid()
23-
form.save()
24-
appointment.refresh_from_db()
25-
assert appointment.reinvite is True
18+
assert appointment.reinvite == False
2619

2720
form_data = {
2821
"stopped_reasons": ["failed_identity_check"],
29-
"decision": "False",
22+
"decision": decision,
3023
}
3124
form = AppointmentCannotGoAheadForm(form_data, instance=appointment)
3225
form.is_valid()
3326
form.save()
3427
appointment.refresh_from_db()
35-
assert appointment.reinvite is False
36-
37-
28+
assert appointment.reinvite == reinvite_value

0 commit comments

Comments
 (0)