Skip to content

Commit a4246fb

Browse files
committed
more tests
1 parent 43cc501 commit a4246fb

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

manage_breast_screening/mammograms/tests/forms/test_breast_augmentation_history_form.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.http import QueryDict
66
from django.test import RequestFactory
77

8+
from manage_breast_screening.core.models import AuditLog
89
from manage_breast_screening.participants.models.breast_augmentation_history_item import (
910
BreastAugmentationHistoryItem,
1011
)
@@ -424,7 +425,13 @@ def test_success(self, clinical_user, data):
424425

425426
assert form.is_valid()
426427

428+
existing_log_count = AuditLog.objects.count()
427429
obj = form.create(appointment=appointment, request=request)
430+
assert AuditLog.objects.count() == existing_log_count + 1
431+
audit_log = AuditLog.objects.filter(
432+
object_id=obj.pk, operation=AuditLog.Operations.CREATE
433+
).first()
434+
assert audit_log.actor == clinical_user
428435

429436
assert obj.appointment == appointment
430437
assert obj.left_breast_procedures == data.get("left_breast_procedures")

manage_breast_screening/tests/system/clinical/test_breast_augmentation_history.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ def test_adding_breast_augmentation(self):
1818
self.when_i_click_on_add_breast_augmentation()
1919
self.then_i_see_the_add_breast_augmentation_form()
2020

21+
self.when_i_click_save_without_entering_details()
22+
self.then_i_see_validation_errors_for_missing_benign_lump_details()
23+
2124
self.when_i_select_procedures()
25+
self.and_i_enter_the_procedure_year()
26+
self.and_i_enter_the_removal_year()
27+
self.and_i_enter_additional_details()
2228
self.and_i_click_save_augmentation()
2329
self.then_i_am_back_on_the_medical_information_page()
2430
self.and_the_augmentation_is_listed()
@@ -59,6 +65,18 @@ def then_i_see_the_add_breast_augmentation_form(self):
5965
"Add details of breast implants or augmentation"
6066
)
6167

68+
def then_i_see_validation_errors_for_missing_benign_lump_details(self):
69+
self.expect_validation_error(
70+
error_text="Select procedures for the right breast",
71+
fieldset_legend="Right breast",
72+
field_label="Breast implants (silicone or saline)",
73+
)
74+
self.expect_validation_error(
75+
error_text="Select procedures for the left breast",
76+
fieldset_legend="Left breast",
77+
field_label="Breast implants (silicone or saline)",
78+
)
79+
6280
def when_i_select_procedures(self):
6381
self.page.get_by_role("group", name="Right breast").get_by_label(
6482
"Breast implants (silicone or saline)", exact=True
@@ -67,6 +85,21 @@ def when_i_select_procedures(self):
6785
"Other augmentation", exact=True
6886
).click()
6987

88+
def and_i_enter_the_procedure_year(self):
89+
self.page.get_by_label("Year of procedure (optional)", exact=True).fill("2000")
90+
91+
def and_i_enter_the_removal_year(self):
92+
self.page.get_by_text("Implants have been removed").click()
93+
self.page.get_by_label("Year removed (if available)", exact=True).fill("2025")
94+
95+
def and_i_enter_additional_details(self):
96+
self.page.get_by_label("Additional details (optional)", exact=True).fill(
97+
"additional details for test of breast augmentation history"
98+
)
99+
100+
def when_i_click_save_without_entering_details(self):
101+
self.and_i_click_save_augmentation()
102+
70103
def and_i_click_save_augmentation(self):
71104
self.page.get_by_text("Save").click()
72105

@@ -82,7 +115,12 @@ def and_the_augmentation_is_listed(self):
82115
expect(row).to_contain_text(
83116
"Right breast: Breast implants (silicone or saline)"
84117
)
85-
expect(row).to_contain_text("Other augmentation")
118+
expect(row).to_contain_text("Left breast: Other augmentation")
119+
expect(row).to_contain_text("2000")
120+
expect(row).to_contain_text("Yes (2025)")
121+
expect(row).to_contain_text(
122+
"additional details for test of breast augmentation history"
123+
)
86124

87125
def and_the_message_says_augmentation_added(self):
88126
alert = self.page.get_by_role("alert")

0 commit comments

Comments
 (0)