11import pytest
22import logging
33import datetime
4+ import pandas as pd
45from playwright .sync_api import Page
56from pages .communication_production .batch_list_page import ActiveBatchListPage
67from utils .oracle .subject_creation_util import CreateSubjectSteps
1617from pages .communication_production .communications_production_page import (
1718 CommunicationsProductionPage ,
1819)
20+ from utils .oracle .oracle import OracleDB
1921
2022
2123# Helper function to navigate to subject profile
@@ -33,6 +35,7 @@ def navigate_to_subject_profile(page, nhs_no: str) -> None:
3335 logging .info ("[SUBJECT VIEW] Subject loaded in UI" )
3436
3537
38+ # Helper function to navigate to active batch list
3639def navigate_to_active_batch_list (page : Page ) -> None :
3740 """
3841 Navigates to the active batch list page in the UI.
@@ -175,14 +178,29 @@ def test_scenario_2(page: Page) -> None:
175178 summary_page .assert_latest_event_status ("S9 Pre-invitation Sent" )
176179 logging .info ("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI" )
177180
178- # TODO: When I run Timed Events for my subject
181+ # When I run Timed Events for my subject
182+ nhs_df = pd .DataFrame (
183+ {"subject_nhs_number" : [nhs_no ]}
184+ ) # Create DataFrame with NHS number to pass to timed events procedure
185+ OracleDB ().exec_bcss_timed_events (
186+ nhs_df
187+ ) # Execute timed events procedure to process the subject
188+ logging .info ("[TIMED EVENTS] Executed for existing subject" )
179189
180190 # Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
181191 navigate_to_active_batch_list (page )
182192 ActiveBatchListPage (page ).is_batch_present ("S9 - Invitation & Test Kit (FIT)" )
183193 logging .info ("[ASSERTIONS COMPLETE]S9 Letter batch exists" )
184194
185- # TODO: When I process the open "S9" letter batch for my subject
195+ # When I process the open "S9" letter batch for my subject
196+ batch_processing (
197+ page ,
198+ "S9" ,
199+ "Invitation & Test Kit (FIT)" ,
200+ "S10 - Invitation & Test Kit Sent" ,
201+ True ,
202+ )
203+ logging .info ("[DB ASSERTIONS COMPLETE]Updated subject status checked in the DB" )
186204
187205 # Then my subject has been updated as follows:
188206 batch_processing (
@@ -237,7 +255,9 @@ def test_scenario_2(page: Page) -> None:
237255 ActiveBatchListPage (page ).is_batch_present ("S2 - Subject Result (Normal)" )
238256 logging .info ("[ASSERTIONS COMPLETE]S2 Letter batch exists" )
239257
240- # TODO: When I process the open "S2" letter batch for my subject
258+ # When I process the open "S2" letter batch for my subject
259+ batch_processing (page , "S2" , "Normal" , "S158 Subject Discharge Sent (Normal)" , True )
260+
241261 # Then my subject has been updated as follows:
242262 batch_processing (
243263 page ,
@@ -254,7 +274,7 @@ def test_scenario_2(page: Page) -> None:
254274 # Assert subject details in the UI
255275 summary_page .assert_latest_event_status ("S158 Subject Discharge Sent (Normal)" )
256276 logging .info ("[UI ASSERTIONS COMPLETE]Updated subject details checked in the UI" )
257-
277+
258278 # And there is a "S158" letter batch for my subject with the exact title "GP Result (Normal)"
259279 navigate_to_active_batch_list (page )
260280 ActiveBatchListPage (page ).is_batch_present ("S158 - GP Result (Normal)" )
0 commit comments