@@ -18,7 +18,7 @@ def lump(appointment):
1818
1919
2020@pytest .mark .django_db
21- class TestAddLump :
21+ class TestAddLumpView :
2222 def test_renders_response (self , clinical_user_client , appointment ):
2323 response = clinical_user_client .get (
2424 reverse (
@@ -78,6 +78,92 @@ def test_invvalid_post_renders_response_with_errors(
7878 )
7979
8080
81+ @pytest .mark .django_db
82+ class TestChangeLumpView :
83+ @pytest .fixture
84+ def lump (self , appointment ):
85+ return SymptomFactory .create (lump = True , appointment = appointment )
86+
87+ def test_renders_response (self , clinical_user_client , appointment , lump ):
88+ response = clinical_user_client .get (
89+ reverse (
90+ "mammograms:change_symptom_lump" ,
91+ kwargs = {"pk" : appointment .pk , "symptom_pk" : lump .pk },
92+ )
93+ )
94+ assert response .status_code == 200
95+
96+ def test_non_existant_or_deleted_symptom_id_is_a_404 (
97+ self , clinical_user_client , appointment
98+ ):
99+ """
100+ Note: the behaviour we probably want here is to redirect back to
101+ the "parent page" when a child entity is not found, and use flash
102+ messages to explain the error. However, none of this is
103+ implemented yet.
104+ """
105+ response = clinical_user_client .get (
106+ reverse (
107+ "mammograms:change_symptom_lump" ,
108+ kwargs = {
109+ "pk" : appointment .pk ,
110+ "symptom_pk" : "beefbeef-beef-beef-beef-beefbeefbeef" ,
111+ },
112+ )
113+ )
114+
115+ assert response .status_code == 404
116+
117+ def test_valid_post_redirects_to_appointment (
118+ self , clinical_user_client , appointment , lump
119+ ):
120+ response = clinical_user_client .post (
121+ reverse (
122+ "mammograms:change_symptom_lump" ,
123+ kwargs = {"pk" : appointment .pk , "symptom_pk" : lump .pk },
124+ ),
125+ {
126+ "area" : SymptomAreas .RIGHT_BREAST .value ,
127+ "when_started" : RelativeDateChoices .LESS_THAN_THREE_MONTHS .value ,
128+ "investigated" : YesNo .NO .value ,
129+ },
130+ )
131+ assertRedirects (
132+ response ,
133+ reverse (
134+ "mammograms:record_medical_information" ,
135+ kwargs = {"pk" : appointment .pk },
136+ ),
137+ )
138+
139+ def test_invvalid_post_renders_response_with_errors (
140+ self , clinical_user_client , appointment , lump
141+ ):
142+ response = clinical_user_client .post (
143+ reverse (
144+ "mammograms:change_symptom_lump" ,
145+ kwargs = {"pk" : appointment .pk , "symptom_pk" : lump .pk },
146+ ),
147+ {},
148+ )
149+ assert response .status_code == 200
150+ assertInHTML (
151+ """
152+ <div class="nhsuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="nhsuk-error-summary">
153+ <h2 class="nhsuk-error-summary__title" id="error-summary-title">There is a problem</h2>
154+ <div class="nhsuk-error-summary__body">
155+ <ul class="nhsuk-list nhsuk-error-summary__list" role="list">
156+ <li><a href="#id_area">Select the location of the lump</a></li>
157+ <li><a href="#id_when_started">Select how long the symptom has existed</a></li>
158+ <li><a href="#id_investigated">Select whether the symptom has been investigated or not</a></li>
159+ </ul>
160+ </div>
161+ </div>
162+ """ ,
163+ response .text ,
164+ )
165+
166+
81167@pytest .mark .django_db
82168class TestDeleteSymptomView :
83169 def test_get_renders_response (self , clinical_user_client , appointment , lump ):
0 commit comments