11import pytest
22import logging
33import datetime
4- import pandas as pd
54from playwright .sync_api import Page
65from pages .communication_production .batch_list_page import ActiveBatchListPage
76from utils .oracle .subject_creation_util import CreateSubjectSteps
109from utils .call_and_recall_utils import CallAndRecallUtils
1110from utils import screening_subject_page_searcher
1211from utils .batch_processing import batch_processing
13- from utils .fit_kit import FitKitGeneration , FitKitLogged
14- from utils .oracle .oracle import OracleDB
15- from pages .base_page import BasePage
12+ from utils .fit_kit import FitKitLogged
1613from pages .screening_subject_search .subject_screening_summary_page import (
1714 SubjectScreeningSummaryPage ,
1815)
19- from pages .communication_production .communications_production_page import (
20- CommunicationsProductionPage ,
21- )
22- from pages .fit_test_kits .log_devices_page import LogDevicesPage
23- from pages .fit_test_kits .fit_test_kits_page import FITTestKitsPage
2416from pages .communication_production .batch_list_page import BatchListPage
2517
2618
27- # Helper function to log FIT kit
28- def log_fit_kit (page : Page , nhs_no : str ) -> str :
29- BasePage (page ).click_main_menu_link ()
30- fit_kit = FitKitGeneration ().get_fit_kit_for_subject_sql (nhs_no , False , False )
31- BasePage (page ).go_to_fit_test_kits_page ()
32- FITTestKitsPage (page ).go_to_log_devices_page ()
33- logging .info (f"Logging FIT Device ID: { fit_kit } " )
34- LogDevicesPage (page ).fill_fit_device_id_field (fit_kit )
35- sample_date = datetime .datetime .now ()
36- logging .info (f"Setting sample date to { sample_date } " )
37- LogDevicesPage (page ).fill_sample_date_field (sample_date )
38- LogDevicesPage (page ).log_devices_title .get_by_text ("Scan Device" ).wait_for ()
39- try :
40- LogDevicesPage (page ).verify_successfully_logged_device_text ()
41- logging .info (f"{ fit_kit } Successfully logged" )
42- except Exception as e :
43- pytest .fail (f"{ fit_kit } unsuccessfully logged: { str (e )} " )
44- return fit_kit
45-
46-
4719@pytest .mark .wip
4820@pytest .mark .fobt_regression_tests
4921def test_scenario_2 (page : Page ) -> None :
@@ -135,8 +107,8 @@ def test_scenario_2(page: Page) -> None:
135107 logging .info (f"[SUBJECT VIEW] Subject { nhs_no } loaded in UI" )
136108
137109 # Assert subject details in the UI
138- # TODO: summary_page.assert_screening_status("Call")
139110 summary_page .assert_screening_status ("Inactive" )
111+ # summary_page.assert_screening_status("Call") #TODO:
140112 logging .info ("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI" )
141113
142114 # When I invite my subject for FOBT screening
@@ -159,33 +131,21 @@ def test_scenario_2(page: Page) -> None:
159131 logging .info ("[UI ASSERTIONS COMPLETE] S1 Letter batch exists" )
160132
161133 # When I process the open "S1" letter batch for my subject
162- # Then my subject has been updated as follows:
134+ # Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
163135 batch_processing (
164136 page , "S1" , "Pre-invitation (FIT)" , "S9 - Pre-invitation Sent" , True
165137 )
166- logging .info ("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB" )
167138 logging .info ("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI" )
139+ logging .info ("[UI ASSERTIONS COMPLETE] S9 Letter batch exists" )
168140
169- # Navigate to subject summary page in UI
170- # navigate_to_subject_summary_page(page, nhs_no)
171- # logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
172-
173- # Assert subject details in the UI
174- # summary_page.assert_latest_event_status("S9 - Pre-invitation Sent")
175-
176- # When I run Timed Events for my subject
177- # nhs_df = pd.DataFrame(
178- # {"subject_nhs_number": [nhs_no]}
179- # ) # Create DataFrame with NHS number to pass to timed events procedure
180- # OracleDB().exec_bcss_timed_events(
181- # nhs_df
182- # ) # Execute timed events procedure to process the subject
183- # logging.info("[TIMED EVENTS]Executed for existing subject")
184-
185- # Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
186- # navigate_to_active_batch_list(page)
187- # ActiveBatchListPage(page).is_batch_present("S9 - Invitation & Test Kit (FIT)")
188- # logging.info("[UI ASSERTIONS COMPLETE] S9 Letter batch exists")
141+ # Then my subject has been updated as follows:
142+ subject_assertion (
143+ nhs_no ,
144+ {
145+ "latest event status" : "S9 - Pre-invitation Sent" ,
146+ },
147+ )
148+ logging .info ("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB" )
189149
190150 # When I process the open "S9" letter batch for my subject
191151 batch_processing (
@@ -195,20 +155,19 @@ def test_scenario_2(page: Page) -> None:
195155 "S10 - Invitation & Test Kit Sent" ,
196156 True ,
197157 )
198- logging .info ("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB " )
158+ logging .info ("[UI ASSERTIONS COMPLETE] Updated subject status checked in the UI " )
199159
200- # # Then my subject has been updated as follows:
201- # batch_processing(
202- # page,
203- # "S9",
204- # "Invitation & Test Kit (FIT)",
205- # "S10 - Invitation & Test Kit Sent",
206- # True,
207- # )
208- # logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
160+ # Then my subject has been updated as follows:
161+ subject_assertion (
162+ nhs_no ,
163+ {
164+ "latest event status" : "S10 - Invitation & Test Kit Sent" ,
165+ },
166+ )
167+ logging .info ("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB" )
209168
210169 # When I log my subject's latest unlogged FIT kit
211- fit_kit = log_fit_kit (page , nhs_no )
170+ fit_kit = FitKitLogged (). log_fit_kit (page , nhs_no )
212171
213172 # Then my subject has been updated as follows:
214173 subject_assertion (
@@ -262,24 +221,16 @@ def test_scenario_2(page: Page) -> None:
262221 "S158 - Subject Discharge Sent (Normal)" ,
263222 True ,
264223 )
224+ logging .info ("[UI ASSERTIONS COMPLETE] Updated subject status checked in the UI" )
265225
266226 # Then my subject has been updated as follows:
267- # batch_processing(
268- # page,
269- # "S2",
270- # "Subject Result (Normal)",
271- # "S158 Subject Discharge Sent (Normal)",
272- # True,
273- # )
274- # logging.info("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB")
275-
276- # Navigate to subject summary page in UI
277- screening_subject_page_searcher .navigate_to_subject_summary_page (page , nhs_no )
278- logging .info (f"[SUBJECT VIEW] Subject { nhs_no } loaded in UI" )
279-
280- # Assert subject details in the UI
281- summary_page .assert_latest_event_status ("S158 - Subject Discharge Sent (Normal)" )
282- logging .info ("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI" )
227+ subject_assertion (
228+ nhs_no ,
229+ {
230+ "latest event status" : "S158 Subject Discharge Sent (Normal)" ,
231+ },
232+ )
233+ logging .info ("[DB ASSERTIONS COMPLETE] Updated subject status checked in the DB" )
283234
284235 # And there is a "S158" letter batch for my subject with the exact title "GP Result (Normal)"
285236 BatchListPage (page ).navigate_to_active_batch_list_page ()
@@ -294,6 +245,7 @@ def test_scenario_2(page: Page) -> None:
294245 "S159 - GP Discharge Sent (Normal)" ,
295246 True ,
296247 )
248+ logging .info ("[UI ASSERTIONS COMPLETE] Updated subject status checked in the UI" )
297249
298250 # Then my subject has been updated as follows:
299251 subject_assertion (
@@ -328,12 +280,4 @@ def test_scenario_2(page: Page) -> None:
328280 )
329281 logging .info ("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB" )
330282
331- # Navigate to subject summary page in UI
332- screening_subject_page_searcher .navigate_to_subject_summary_page (page , nhs_no )
333- logging .info (f"[SUBJECT VIEW] Subject { nhs_no } loaded in UI" )
334-
335- # Assert subject details in the UI
336- summary_page .assert_latest_event_status ("S159 - GP Discharge Sent (Normal)" )
337- logging .info ("[UI ASSERTIONS COMPLETE] Updated subject details checked in the UI" )
338-
339283 logging .info ("[TEST COMPLETE] Scenario 2 passed all assertions" )
0 commit comments