diff --git a/manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja b/manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja index 55b192a5c..6819d196e 100644 --- a/manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja +++ b/manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja @@ -165,17 +165,6 @@ "items": [] } }, - { - "key": { - "text": "Non-cancerous lump diagnosis" - }, - "value": { - "html": non_cancerous_lump_diagnosis_link - }, - "actions": { - "items": [] - } - }, { "key": { "text": "Mastectomy or lumpectomy history" @@ -186,17 +175,6 @@ "actions": { "items": [] } - }, - { - "key": { - "text": "Other breast or chest procedures" - }, - "value": { - "html": chest_procedures_link - }, - "actions": { - "items": [] - } } ] }) }} diff --git a/manage_breast_screening/mammograms/presenters/appointment_presenters.py b/manage_breast_screening/mammograms/presenters/appointment_presenters.py index ca12a985b..e4b334743 100644 --- a/manage_breast_screening/mammograms/presenters/appointment_presenters.py +++ b/manage_breast_screening/mammograms/presenters/appointment_presenters.py @@ -93,9 +93,9 @@ def current_status(self): colour = status_colour(current_status.state) return { - "classes": f"nhsuk-tag--{colour} app-u-nowrap" - if colour - else "app-u-nowrap", + "classes": ( + f"nhsuk-tag--{colour} app-u-nowrap" if colour else "app-u-nowrap" + ), "text": current_status.get_state_display(), "key": current_status.state, "is_confirmed": current_status.state == AppointmentStatus.CONFIRMED, diff --git a/manage_breast_screening/mammograms/presenters/medical_history/__init__.py b/manage_breast_screening/mammograms/presenters/medical_history/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/manage_breast_screening/mammograms/presenters/benign_lump_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/benign_lump_history_item_presenter.py similarity index 90% rename from manage_breast_screening/mammograms/presenters/benign_lump_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/benign_lump_history_item_presenter.py index e695796d0..a6866ae80 100644 --- a/manage_breast_screening/mammograms/presenters/benign_lump_history_item_presenter.py +++ b/manage_breast_screening/mammograms/presenters/medical_history/benign_lump_history_item_presenter.py @@ -7,8 +7,9 @@ class BenignLumpHistoryItemPresenter: - def __init__(self, benign_lump_history_item): + def __init__(self, benign_lump_history_item, counter=None): self._item = benign_lump_history_item + self.counter = counter self.right_breast_procedures = self._format_multiple_choices( self._item.right_breast_procedures, BenignLumpHistoryItem.Procedure ) @@ -63,6 +64,11 @@ def change_link(self): }, ), "text": "Change", + "visually_hidden_text": ( + f" benign lump item {self.counter}" + if self.counter + else " benign lump item" + ), } def _format_multiple_choices(self, choices, ChoiceClass): diff --git a/manage_breast_screening/mammograms/presenters/breast_augmentation_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/breast_augmentation_history_item_presenter.py similarity index 100% rename from manage_breast_screening/mammograms/presenters/breast_augmentation_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/breast_augmentation_history_item_presenter.py diff --git a/manage_breast_screening/mammograms/presenters/breast_cancer_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/breast_cancer_history_item_presenter.py similarity index 100% rename from manage_breast_screening/mammograms/presenters/breast_cancer_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/breast_cancer_history_item_presenter.py diff --git a/manage_breast_screening/mammograms/presenters/cyst_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/cyst_history_item_presenter.py similarity index 100% rename from manage_breast_screening/mammograms/presenters/cyst_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/cyst_history_item_presenter.py diff --git a/manage_breast_screening/mammograms/presenters/implanted_medical_device_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/implanted_medical_device_history_item_presenter.py similarity index 100% rename from manage_breast_screening/mammograms/presenters/implanted_medical_device_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/implanted_medical_device_history_item_presenter.py diff --git a/manage_breast_screening/mammograms/presenters/mastectomy_or_lumpectomy_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/mastectomy_or_lumpectomy_history_item_presenter.py similarity index 100% rename from manage_breast_screening/mammograms/presenters/mastectomy_or_lumpectomy_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/mastectomy_or_lumpectomy_history_item_presenter.py diff --git a/manage_breast_screening/mammograms/presenters/other_procedure_history_item_presenter.py b/manage_breast_screening/mammograms/presenters/medical_history/other_procedure_history_item_presenter.py similarity index 100% rename from manage_breast_screening/mammograms/presenters/other_procedure_history_item_presenter.py rename to manage_breast_screening/mammograms/presenters/medical_history/other_procedure_history_item_presenter.py diff --git a/manage_breast_screening/mammograms/presenters/medical_information_presenter.py b/manage_breast_screening/mammograms/presenters/medical_information_presenter.py index 8ecf0d63f..9e3f39a2d 100644 --- a/manage_breast_screening/mammograms/presenters/medical_information_presenter.py +++ b/manage_breast_screening/mammograms/presenters/medical_information_presenter.py @@ -1,24 +1,24 @@ from django.urls import reverse -from manage_breast_screening.mammograms.presenters.benign_lump_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.benign_lump_history_item_presenter import ( BenignLumpHistoryItemPresenter, ) -from manage_breast_screening.mammograms.presenters.breast_augmentation_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.breast_augmentation_history_item_presenter import ( BreastAugmentationHistoryItemPresenter, ) -from manage_breast_screening.mammograms.presenters.breast_cancer_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.breast_cancer_history_item_presenter import ( BreastCancerHistoryItemPresenter, ) -from manage_breast_screening.mammograms.presenters.cyst_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.cyst_history_item_presenter import ( CystHistoryItemPresenter, ) -from manage_breast_screening.mammograms.presenters.implanted_medical_device_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.implanted_medical_device_history_item_presenter import ( ImplantedMedicalDeviceHistoryItemPresenter, ) -from manage_breast_screening.mammograms.presenters.mastectomy_or_lumpectomy_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.mastectomy_or_lumpectomy_history_item_presenter import ( MastectomyOrLumpectomyHistoryItemPresenter, ) -from manage_breast_screening.mammograms.presenters.other_procedure_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.other_procedure_history_item_presenter import ( OtherProcedureHistoryItemPresenter, ) from manage_breast_screening.mammograms.presenters.symptom_presenter import ( @@ -35,6 +35,7 @@ def __init__(self, appointment): "symptom_type__name", "reported_at" ) self.symptoms = [SymptomPresenter(symptom) for symptom in symptoms] + self.breast_cancer_history = self._present_items( appointment.breast_cancer_history_items.all(), BreastCancerHistoryItemPresenter, @@ -60,10 +61,9 @@ def __init__(self, appointment): OtherProcedureHistoryItemPresenter, ) - self.benign_lump_history = [ - BenignLumpHistoryItemPresenter(item) - for item in appointment.benign_lump_history_items.all() - ] + self.benign_lump_history = self._present_items( + appointment.benign_lump_history_items.all(), BenignLumpHistoryItemPresenter + ) self.cyst_history = self._present_items( appointment.cyst_history_items.all(), CystHistoryItemPresenter diff --git a/manage_breast_screening/mammograms/tests/presenters/medical_history/__init__.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/manage_breast_screening/mammograms/tests/presenters/test_benign_lump_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_benign_lump_history_item_presenter.py similarity index 79% rename from manage_breast_screening/mammograms/tests/presenters/test_benign_lump_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_benign_lump_history_item_presenter.py index 98a2a167b..2e1cbaa6a 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_benign_lump_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_benign_lump_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.benign_lump_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.benign_lump_history_item_presenter import ( BenignLumpHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.benign_lump_history_item import ( @@ -62,4 +62,15 @@ def test_change_link(self): assert result == { "href": f"/mammograms/{item.appointment_id}/record-medical-information/benign-lump-history/{item.id}/", "text": "Change", + "visually_hidden_text": " benign lump item", + } + + def test_change_link_with_counter(self): + item = BenignLumpHistoryItemFactory.build() + + presenter = BenignLumpHistoryItemPresenter(item, counter=2) + assert presenter.change_link == { + "href": f"/mammograms/{item.appointment_id}/record-medical-information/benign-lump-history/{item.pk}/", + "text": "Change", + "visually_hidden_text": " benign lump item 2", } diff --git a/manage_breast_screening/mammograms/tests/presenters/test_breast_augmentation_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_augmentation_history_item_presenter.py similarity index 91% rename from manage_breast_screening/mammograms/tests/presenters/test_breast_augmentation_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_augmentation_history_item_presenter.py index 359e482f8..ca88678f5 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_breast_augmentation_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_augmentation_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.breast_augmentation_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.breast_augmentation_history_item_presenter import ( BreastAugmentationHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.breast_augmentation_history_item import ( @@ -65,7 +65,7 @@ def test_change_link(self): presenter = BreastAugmentationHistoryItemPresenter(item) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-augmentation-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-augmentation-history/{item.pk}/", "text": "Change", "visually_hidden_text": " breast implants or augmentation item", } @@ -75,7 +75,7 @@ def test_change_link_with_counter(self): presenter = BreastAugmentationHistoryItemPresenter(item, counter=2) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-augmentation-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-augmentation-history/{item.pk}/", "text": "Change", "visually_hidden_text": " breast implants or augmentation item 2", } diff --git a/manage_breast_screening/mammograms/tests/presenters/test_breast_cancer_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_cancer_history_item_presenter.py similarity index 93% rename from manage_breast_screening/mammograms/tests/presenters/test_breast_cancer_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_cancer_history_item_presenter.py index 7ba0cff89..22cd0ef98 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_breast_cancer_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_breast_cancer_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.breast_cancer_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.breast_cancer_history_item_presenter import ( BreastCancerHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.breast_cancer_history_item import ( @@ -79,7 +79,7 @@ def test_change_link(self): presenter = BreastCancerHistoryItemPresenter(item) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-cancer-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-cancer-history/{item.pk}/", "text": "Change", "visually_hidden_text": " breast cancer item", } @@ -89,7 +89,7 @@ def test_change_link_with_counter(self): presenter = BreastCancerHistoryItemPresenter(item, counter=2) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-cancer-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/breast-cancer-history/{item.pk}/", "text": "Change", "visually_hidden_text": " breast cancer item 2", } diff --git a/manage_breast_screening/mammograms/tests/presenters/test_cyst_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_cyst_history_item_presenter.py similarity index 91% rename from manage_breast_screening/mammograms/tests/presenters/test_cyst_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_cyst_history_item_presenter.py index 292cd6466..956fb108c 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_cyst_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_cyst_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.cyst_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.cyst_history_item_presenter import ( CystHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.cyst_history_item import ( @@ -44,7 +44,7 @@ def test_change_link(self): presenter = CystHistoryItemPresenter(item) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/cyst-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/cyst-history/{item.pk}/", "text": "Change", "visually_hidden_text": " cyst item", } @@ -57,7 +57,7 @@ def test_change_link_with_counter(self): presenter = CystHistoryItemPresenter(item, counter=2) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/cyst-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/cyst-history/{item.pk}/", "text": "Change", "visually_hidden_text": " cyst item 2", } diff --git a/manage_breast_screening/mammograms/tests/presenters/test_implanted_medical_device_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_implanted_medical_device_history_item_presenter.py similarity index 92% rename from manage_breast_screening/mammograms/tests/presenters/test_implanted_medical_device_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_implanted_medical_device_history_item_presenter.py index 7af0002a3..016ebadbd 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_implanted_medical_device_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_implanted_medical_device_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.implanted_medical_device_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.implanted_medical_device_history_item_presenter import ( ImplantedMedicalDeviceHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.implanted_medical_device_history_item import ( @@ -74,7 +74,7 @@ def test_change_link(self): presenter = ImplantedMedicalDeviceHistoryItemPresenter(item) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/implanted-medical-device-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/implanted-medical-device-history/{item.pk}/", "text": "Change", "visually_hidden_text": " implanted medical device item", } @@ -87,7 +87,7 @@ def test_change_link_with_counter(self): presenter = ImplantedMedicalDeviceHistoryItemPresenter(item, counter=2) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/implanted-medical-device-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/implanted-medical-device-history/{item.pk}/", "text": "Change", "visually_hidden_text": " item 2", } diff --git a/manage_breast_screening/mammograms/tests/presenters/test_mastectomy_or_lumpectomy_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_mastectomy_or_lumpectomy_history_item_presenter.py similarity index 93% rename from manage_breast_screening/mammograms/tests/presenters/test_mastectomy_or_lumpectomy_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_mastectomy_or_lumpectomy_history_item_presenter.py index 55f496e6f..27cffe4a3 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_mastectomy_or_lumpectomy_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_mastectomy_or_lumpectomy_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.mastectomy_or_lumpectomy_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.mastectomy_or_lumpectomy_history_item_presenter import ( MastectomyOrLumpectomyHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.mastectomy_or_lumpectomy_history_item import ( @@ -87,7 +87,7 @@ def test_change_link(self): presenter = MastectomyOrLumpectomyHistoryItemPresenter(item) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/mastectomy-or-lumpectomy-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/mastectomy-or-lumpectomy-history/{item.pk}/", "text": "Change", "visually_hidden_text": " mastectomy or lumpectomy item", } @@ -99,7 +99,7 @@ def test_change_link_with_counter(self): presenter = MastectomyOrLumpectomyHistoryItemPresenter(item, counter=2) assert presenter.change_link == { - "href": f"/mammograms/{item.appointment_id}/record-medical-information/mastectomy-or-lumpectomy-history/{item.pk}", + "href": f"/mammograms/{item.appointment_id}/record-medical-information/mastectomy-or-lumpectomy-history/{item.pk}/", "text": "Change", "visually_hidden_text": " mastectomy or lumpectomy item 2", } diff --git a/manage_breast_screening/mammograms/tests/presenters/test_other_procedure_history_item_presenter.py b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_other_procedure_history_item_presenter.py similarity index 93% rename from manage_breast_screening/mammograms/tests/presenters/test_other_procedure_history_item_presenter.py rename to manage_breast_screening/mammograms/tests/presenters/medical_history/test_other_procedure_history_item_presenter.py index 692f2cf49..9826af964 100644 --- a/manage_breast_screening/mammograms/tests/presenters/test_other_procedure_history_item_presenter.py +++ b/manage_breast_screening/mammograms/tests/presenters/medical_history/test_other_procedure_history_item_presenter.py @@ -1,4 +1,4 @@ -from manage_breast_screening.mammograms.presenters.other_procedure_history_item_presenter import ( +from manage_breast_screening.mammograms.presenters.medical_history.other_procedure_history_item_presenter import ( OtherProcedureHistoryItemPresenter, ) from manage_breast_screening.participants.models.medical_history.other_procedure_history_item import ( diff --git a/manage_breast_screening/mammograms/tests/views/medical_history/test_benign_lump_history_item_views.py b/manage_breast_screening/mammograms/tests/views/medical_history/test_benign_lump_history_item_views.py new file mode 100644 index 000000000..7177b2fbe --- /dev/null +++ b/manage_breast_screening/mammograms/tests/views/medical_history/test_benign_lump_history_item_views.py @@ -0,0 +1,156 @@ +from urllib.parse import urlencode + +import pytest +from django.contrib import messages +from django.http import QueryDict +from django.urls import reverse +from pytest_django.asserts import assertInHTML, assertMessages, assertRedirects + +from manage_breast_screening.participants.models.medical_history.benign_lump_history_item import ( + BenignLumpHistoryItem, +) +from manage_breast_screening.participants.tests.factories import ( + AppointmentFactory, + BenignLumpHistoryItemFactory, +) + + +@pytest.mark.django_db +class TestAddBenignLumpHistoryView: + def test_renders_response(self, clinical_user_client): + appointment = AppointmentFactory.create( + clinic_slot__clinic__setting__provider=clinical_user_client.current_provider + ) + response = clinical_user_client.http.get( + reverse( + "mammograms:add_benign_lump_history_item", + kwargs={"pk": appointment.pk}, + ) + ) + assert response.status_code == 200 + + def test_valid_post_redirects_to_appointment(self, clinical_user_client): + appointment = AppointmentFactory.create( + clinic_slot__clinic__setting__provider=clinical_user_client.current_provider + ) + response = clinical_user_client.http.post( + reverse( + "mammograms:add_benign_lump_history_item", + kwargs={"pk": appointment.pk}, + ), + { + "left_breast_procedures": BenignLumpHistoryItem.Procedure.LUMP_REMOVED, + "right_breast_procedures": BenignLumpHistoryItem.Procedure.NO_PROCEDURES, + "procedure_location": BenignLumpHistoryItem.ProcedureLocation.EXACT_LOCATION_UNKNOWN, + "exact_location_unknown_details": "abc", + }, + ) + assertRedirects( + response, + reverse( + "mammograms:record_medical_information", + kwargs={"pk": appointment.pk}, + ), + ) + assertMessages( + response, + [ + messages.Message( + level=messages.SUCCESS, + message="Benign lumps added", + ) + ], + ) + + def test_invalid_post_renders_response_with_errors(self, clinical_user_client): + appointment = AppointmentFactory.create( + clinic_slot__clinic__setting__provider=clinical_user_client.current_provider + ) + response = clinical_user_client.http.post( + reverse( + "mammograms:add_benign_lump_history_item", + kwargs={"pk": appointment.pk}, + ), + {}, + ) + assert response.status_code == 200 + assertInHTML( + """ + + """, + response.text, + ) + + +@pytest.mark.django_db +class TestChangeBenignLumpHistoryView: + @pytest.fixture + def appointment(self, clinical_user_client): + return AppointmentFactory.create( + clinic_slot__clinic__setting__provider=clinical_user_client.current_provider + ) + + @pytest.fixture + def history_item(self, appointment): + return BenignLumpHistoryItemFactory.create(appointment=appointment) + + def test_renders_response(self, clinical_user_client, history_item): + response = clinical_user_client.http.get( + reverse( + "mammograms:change_benign_lump_history_item", + kwargs={ + "pk": history_item.appointment_id, + "history_item_pk": history_item.pk, + }, + ) + ) + assert response.status_code == 200 + + def test_valid_post_redirects_to_appointment( + self, clinical_user_client, history_item + ): + response = clinical_user_client.http.post( + reverse( + "mammograms:change_benign_lump_history_item", + kwargs={ + "pk": history_item.appointment_id, + "history_item_pk": history_item.pk, + }, + ), + QueryDict( + urlencode( + { + "left_breast_procedures": [ + BenignLumpHistoryItem.Procedure.NO_PROCEDURES + ], + "right_breast_procedures": [ + BenignLumpHistoryItem.Procedure.NEEDLE_BIOPSY + ], + "procedure_location": BenignLumpHistoryItem.ProcedureLocation.EXACT_LOCATION_UNKNOWN, + "exact_location_unknown_details": "abc", + }, + doseq=True, + ) + ), + ) + + assertRedirects( + response, + reverse( + "mammograms:record_medical_information", + kwargs={"pk": history_item.appointment_id}, + ), + ) + assertMessages( + response, + [ + messages.Message( + level=messages.SUCCESS, + message="Benign lumps updated", + ) + ], + ) diff --git a/manage_breast_screening/mammograms/urls.py b/manage_breast_screening/mammograms/urls.py index 1ddc27e31..cfee41fea 100644 --- a/manage_breast_screening/mammograms/urls.py +++ b/manage_breast_screening/mammograms/urls.py @@ -135,12 +135,12 @@ name="add_breast_cancer_history_item", ), path( - "/record-medical-information/breast-cancer-history/", + "/record-medical-information/breast-cancer-history//", breast_cancer_history_item_views.UpdateBreastCancerHistoryView.as_view(), name="change_breast_cancer_history_item", ), path( - "/record-medical-information/breast-cancer-history//delete", + "/record-medical-information/breast-cancer-history//delete/", breast_cancer_history_item_views.DeleteBreastCancerHistoryView.as_view(), name="delete_breast_cancer_history_item", ), @@ -150,7 +150,7 @@ name="add_implanted_medical_device_history_item", ), path( - "/record-medical-information/implanted-medical-device-history/", + "/record-medical-information/implanted-medical-device-history//", implanted_medical_device_history_item_views.UpdateImplantedMedicalDeviceHistoryView.as_view(), name="change_implanted_medical_device_history_item", ), @@ -160,7 +160,7 @@ name="add_cyst_history_item", ), path( - "/record-medical-information/cyst-history/", + "/record-medical-information/cyst-history//", cyst_history_item_views.UpdateCystHistoryView.as_view(), name="change_cyst_history_item", ), @@ -170,7 +170,7 @@ name="add_breast_augmentation_history_item", ), path( - "/record-medical-information/breast-augmentation-history/", + "/record-medical-information/breast-augmentation-history//", breast_augmentation_history_item_views.UpdateBreastAugmentationHistoryView.as_view(), name="change_breast_augmentation_history_item", ), @@ -190,7 +190,7 @@ name="add_mastectomy_or_lumpectomy_history_item", ), path( - "/record-medical-information/mastectomy-or-lumpectomy-history/", + "/record-medical-information/mastectomy-or-lumpectomy-history//", mastectomy_or_lumpectomy_history_item_views.UpdateMastectomyOrLumpectomyHistoryView.as_view(), name="change_mastectomy_or_lumpectomy_history_item", ), @@ -200,12 +200,12 @@ name="add_other_procedure_history_item", ), path( - "/record-medical-information/other-procedure-history/", + "/record-medical-information/other-procedure-history//", other_procedure_history_item_views.UpdateOtherProcedureHistoryView.as_view(), name="change_other_procedure_history_item", ), path( - "/record-medical-information/other-procedure-history//delete", + "/record-medical-information/other-procedure-history//delete/", other_procedure_history_item_views.DeleteOtherProcedureHistoryView.as_view(), name="delete_other_procedure_history_item", ),