11import logging
2+ from re import A
23import pytest
34from playwright .sync_api import Page , expect
45from pages import screening_subject_search
2728 get_supporting_notes ,
2829)
2930
30- def test_subject_does_not_have_an_additional_care_note (page : Page , general_properties : dict ) -> None :
31+
32+ def test_subject_does_not_have_an_additional_care_note (
33+ page : Page , general_properties : dict
34+ ) -> None :
3135 """
3236 Test to check if I can identify if a subject does not have a Additional Care note
3337 """
@@ -67,8 +71,10 @@ def test_subject_does_not_have_an_additional_care_note(page: Page, general_prope
6771 general_properties ["additional_care_note_name" ]
6872 )
6973
74+
7075def test_add_an_additional_care_note_for_a_subject_without_a_note (
71- page : Page , general_properties : dict ) -> None :
76+ page : Page , general_properties : dict
77+ ) -> None :
7278 """
7379 Test to add a note for a subject without an additional care note.
7480 """
@@ -84,8 +90,11 @@ def test_add_an_additional_care_note_for_a_subject_without_a_note(
8490 BasePage (page ).go_to_screening_subject_search_page ()
8591
8692 # Get a subject with no notes of the specified type
87- subjects_df = get_subjects_by_note_count (general_properties ["additional_care_note_type_value" ],
88- general_properties ["note_status_active" ], 0 )
93+ subjects_df = get_subjects_by_note_count (
94+ general_properties ["additional_care_note_type_value" ],
95+ general_properties ["note_status_active" ],
96+ 0 ,
97+ )
8998 if subjects_df .empty :
9099 pytest .fail (
91100 f"No subjects found for note type { general_properties ["additional_care_note_type_value" ]} ."
@@ -149,10 +158,7 @@ def test_add_an_additional_care_note_for_a_subject_without_a_note(
149158
150159
151160def test_add_additional_care_note_for_subject_with_existing_note (
152- page : Page ,
153- note_type_name : str = "Additional Care Note" ,
154- note_type_value : int = 4112 ,
155- note_status = 4100 ,
161+ page : Page , general_properties : dict
156162) -> None :
157163 """
158164 Test to add an additional care note for a subject who already has an existing note.
@@ -169,7 +175,11 @@ def test_add_additional_care_note_for_subject_with_existing_note(
169175 BasePage (page ).go_to_screening_subject_search_page ()
170176
171177 # Get a subject with existing additional care notes
172- subjects_df = get_subjects_by_note_count (note_type_value , note_status , 1 )
178+ subjects_df = get_subjects_by_note_count (
179+ general_properties ["additional_care_note_type_value" ],
180+ general_properties ["note_status_active" ],
181+ 1 ,
182+ )
173183 nhs_no = subjects_df ["subject_nhs_number" ].iloc [0 ]
174184 logging .info (f"Searching for subject with NHS Number: { nhs_no } " )
175185 SubjectScreeningPage (page ).fill_nhs_number (nhs_no )
@@ -209,19 +219,17 @@ def test_add_additional_care_note_for_subject_with_existing_note(
209219 subjects_df ["note_status" ].iloc [0 ]
210220 ) # Get the note status from the DataFrame
211221 notes_df = get_supporting_notes (screening_subject_id , type_id , note_status )
212- # Filter the DataFrame to only include rows where type_id == 4112
213- filtered_notes_df = notes_df [notes_df ["type_id" ] == note_type_value ]
214222
215223 # Verify title and note match the provided values
216224 logging .info (
217225 f"Verifying that the title and note match the provided values for type_id: { type_id } ."
218226 )
219227 assert (
220- filtered_notes_df ["title" ].iloc [0 ].strip () == note_title
221- ), f"Title does not match. Expected: '{ note_title } ', Found: '{ filtered_notes_df ['title' ].iloc [0 ].strip ()} '."
228+ notes_df ["title" ].iloc [0 ].strip () == note_title
229+ ), f"Title does not match. Expected: '{ note_title } ', Found: '{ notes_df ['title' ].iloc [0 ].strip ()} '."
222230 assert (
223- filtered_notes_df ["note" ].iloc [0 ].strip () == note_text
224- ), f"Note does not match. Expected: '{ note_text } ', Found: '{ filtered_notes_df ['note' ].iloc [0 ].strip ()} '."
231+ notes_df ["note" ].iloc [0 ].strip () == note_text
232+ ), f"Note does not match. Expected: '{ note_text } ', Found: '{ notes_df ['note' ].iloc [0 ].strip ()} '."
225233
226234 logging .info (
227235 f"Verification successful: Additional care note added for the subject with NHS Number: { nhs_no } . "
@@ -230,10 +238,7 @@ def test_add_additional_care_note_for_subject_with_existing_note(
230238
231239
232240def test_identify_subject_with_additional_care_note (
233- page : Page ,
234- note_type_name : str = "Additional Care Note" ,
235- note_type_value : int = 4112 ,
236- note_status = 4100 ,
241+ page : Page , general_properties : dict
237242) -> None :
238243 """
239244 Test to identify if a subject has an Additional Care note.
@@ -249,23 +254,24 @@ def test_identify_subject_with_additional_care_note(
249254 BasePage (page ).go_to_screening_subject_search_page ()
250255
251256 # Search for the subject by NHS Number.")
252- subjects_df = get_subjects_by_note_count (note_type_value , note_status , 1 )
257+ subjects_df = get_subjects_by_note_count (
258+ general_properties ["additional_care_note_type_value" ],
259+ general_properties ["note_status_active" ],
260+ 1 ,
261+ )
253262 nhs_no = subjects_df ["subject_nhs_number" ].iloc [0 ]
254263 SubjectScreeningPage (page ).fill_nhs_number (nhs_no )
255264 SubjectScreeningPage (page ).select_search_area_option ("07" )
256265 SubjectScreeningPage (page ).click_search_button ()
257266 # Verify subject has additional care notes present
258267 logging .info ("Verified: Aadditional care notes are present for the subject." )
259268 # logging.info("Verifying that additional care notes are present for the subject.")
260- SubjectScreeningSummaryPage (page ).verify_additional_care_note_visible ()
269+ SubjectScreeningSummaryPage (page ).verify_note_link_present (
270+ general_properties ["additional_care_note_name" ]
271+ )
261272
262273
263- def test_view_active_additional_care_note (
264- page : Page ,
265- note_type_name : str = "Additional Care Note" ,
266- note_type_value : int = 4112 ,
267- note_status = 4100 ,
268- ) -> None :
274+ def test_view_active_additional_care_note (page : Page , general_properties : dict ) -> None :
269275 """
270276 Test to verify if an active Additional Care note is visible for a subject.
271277 """
@@ -280,7 +286,9 @@ def test_view_active_additional_care_note(
280286 BasePage (page ).go_to_screening_subject_search_page ()
281287
282288 # Search for the subject by NHS Number.")
283- subjects_df = get_subjects_by_note_count (note_type_value , 1 )
289+ subjects_df = get_subjects_by_note_count (
290+ general_properties ["additional_care_note_type_value" ], 1
291+ )
284292 nhs_no = subjects_df ["subject_nhs_number" ].iloc [0 ]
285293 SubjectScreeningPage (page ).fill_nhs_number (nhs_no )
286294 SubjectScreeningPage (page ).select_search_area_option ("07" )
@@ -291,7 +299,9 @@ def test_view_active_additional_care_note(
291299 logging .info (
292300 f"Verifying that the Additional Care Note is visible for the subject with NHS Number: { nhs_no } ."
293301 )
294- SubjectScreeningSummaryPage (page ).verify_additional_care_note_visible ()
302+ SubjectScreeningSummaryPage (page ).verify_note_link_present (
303+ general_properties ["additional_care_note_name" ]
304+ )
295305 logging .info (
296306 f"Clicking on the 'Additional Care Note' link for the subject with NHS Number: { nhs_no } ."
297307 )
@@ -306,17 +316,17 @@ def test_view_active_additional_care_note(
306316 screening_subject_id = int (subjects_df ["screening_subject_id" ].iloc [0 ])
307317 logging .info (f"Screening Subject ID retrieved: { screening_subject_id } " )
308318 type_id = int (subjects_df ["type_id" ].iloc [0 ])
309- notes_df = get_supporting_notes (screening_subject_id , type_id , note_status )
310- # Filter the DataFrame to only include rows where type_id == 4112
311- filtered_notes_df = notes_df [ notes_df [ "type_id" ] == note_type_value ]
319+ notes_df = get_supporting_notes (
320+ screening_subject_id , type_id , general_properties [ "note_status_active" ]
321+ )
312322 # Get the title and note from the first row of the UI table
313323 ui_data = SubjectEventsNotes (page ).get_title_and_note_from_row (2 )
314324 logging .info (f"Data from UI: { ui_data } " )
315325
316326 # Get the title and note from the database
317327 db_data = {
318- "title" : filtered_notes_df ["title" ].iloc [0 ].strip (),
319- "note" : filtered_notes_df ["note" ].iloc [0 ].strip (),
328+ "title" : notes_df ["title" ].iloc [0 ].strip (),
329+ "note" : notes_df ["note" ].iloc [0 ].strip (),
320330 }
321331 logging .info (f"Data from DB: { db_data } " )
322332
@@ -330,41 +340,36 @@ def test_view_active_additional_care_note(
330340
331341
332342def test_update_existing_additional_care_note (
333- page : Page ,
334- note_type_name : str = "Additional Care Note" ,
335- note_type_value : int = 4112 ,
336- note_status = 4100 ,
343+ page : Page , general_properties : dict
337344) -> None :
338345 """
339346 Test to verify if an existing Additional Care note can be updated successfully.
340347 """
341348 logging .info ("Starting test: Verify subject has an additional care note." )
342- logging .info ("Logging in as 'ScreeningAssistant at BCS02'." )
343349 # user login
344- logging .info ("Logging in as 'ScreeningAssistant at BCS02 '." )
345- UserTools .user_login (page , "ScreeningAssistant at BCS02 " )
350+ logging .info ("Logging in as 'TeamLeader at BCS01 '." )
351+ UserTools .user_login (page , "Team Leader at BCS01 " )
346352
347353 # Navigate to the Screening Subject Search Page
348354 logging .info ("Navigating to the Screening Subject Search Page." )
349355 BasePage (page ).go_to_screening_subject_search_page ()
350-
351356 # Search for the subject by NHS Number.")
352- subjects_df = get_subjects_by_note_count (note_type_value , note_status , 1 )
357+ subjects_df = get_subjects_by_note_count (
358+ general_properties ["additional_care_note_type_value" ],
359+ general_properties ["note_status_active" ],
360+ 1 ,
361+ )
353362 nhs_no = subjects_df ["subject_nhs_number" ].iloc [0 ]
354363 SubjectScreeningPage (page ).fill_nhs_number (nhs_no )
355364 SubjectScreeningPage (page ).select_search_area_option ("07" )
356365 SubjectScreeningPage (page ).click_search_button ()
357366 # Verify subject has additional care notes present
358- logging .info ("Verified: Additional care notes are present for the subject." )
359- # logging.info("Verifying that additional care notes are present for the subject.")
360367 logging .info (
361368 f"Verifying that the Additional Care Note is visible for the subject with NHS Number: { nhs_no } ."
362369 )
363- SubjectScreeningSummaryPage (page ).verify_additional_care_note_visible ()
364- logging .info (
365- f"Clicking on the 'Additional Care Note' link for the subject with NHS Number: { nhs_no } ."
370+ SubjectScreeningSummaryPage (page ).verify_note_link_present (
371+ general_properties ["additional_care_note_name" ]
366372 )
367-
368373 SubjectScreeningSummaryPage (page ).click_subjects_events_notes ()
369374 SubjectEventsNotes (page ).select_note_type (NotesOptions .ADDITIONAL_CARE_NOTE )
370375 BasePage (page ).safe_accept_dialog_select_option (
@@ -384,12 +389,9 @@ def test_update_existing_additional_care_note(
384389 screening_subject_id = int (subjects_df ["screening_subject_id" ].iloc [0 ])
385390 logging .info (f"Screening Subject ID retrieved: { screening_subject_id } " )
386391 type_id = int (subjects_df ["type_id" ].iloc [0 ])
387- note_status = int (
388- subjects_df ["note_status" ].iloc [0 ]
389- ) # Get the note status from the DataFrame
390- notes_df = get_supporting_notes (screening_subject_id , type_id , note_status )
391- # Filter the DataFrame to only include rows where type_id == 4112
392- filtered_notes_df = notes_df [notes_df ["type_id" ] == note_type_value ]
392+ notes_df = get_supporting_notes (
393+ screening_subject_id , type_id , general_properties ["note_status_active" ]
394+ )
393395 # Verify title and note match the provided values
394396 logging .info ("Verifying that the updated title and note match the provided values." )
395397
@@ -398,21 +400,21 @@ def test_update_existing_additional_care_note(
398400 note_text = "updated additional care note"
399401
400402 # Ensure the filtered DataFrame is not empty
401- if filtered_notes_df .empty :
403+ if notes_df .empty :
402404 pytest .fail (
403- f"No notes found for type_id: { type_id } . Expected at least one updated note."
405+ f"No notes found for type_id: { general_properties [ "additional_care_note_type_value" ] } . Expected at least one updated note."
404406 )
405407
406408 # Verify title and note match the provided values
407409 logging .info (
408410 f"Verifying that the title and note match the provided values for type_id: { type_id } ."
409411 )
410412 assert (
411- filtered_notes_df ["title" ].iloc [0 ].strip () == note_title
412- ), f"Title does not match. Expected: '{ note_title } ', Found: '{ filtered_notes_df ['title' ].iloc [0 ].strip ()} '."
413+ notes_df ["title" ].iloc [0 ].strip () == note_title
414+ ), f"Title does not match. Expected: '{ note_title } ', Found: '{ notes_df ['title' ].iloc [0 ].strip ()} '."
413415 assert (
414- filtered_notes_df ["note" ].iloc [0 ].strip () == note_text
415- ), f"Note does not match. Expected: '{ note_text } ', Found: '{ filtered_notes_df ['note' ].iloc [0 ].strip ()} '."
416+ notes_df ["note" ].iloc [0 ].strip () == note_text
417+ ), f"Note does not match. Expected: '{ note_text } ', Found: '{ notes_df ['note' ].iloc [0 ].strip ()} '."
416418
417419 logging .info (
418420 f"Verification successful: Additional care note added for the subject with NHS Number: { nhs_no } . "
0 commit comments