Skip to content

Commit a7197d6

Browse files
BCSS-19934 - BCSS - Review / Refactor Compartment 1 data management
1 parent fa6162a commit a7197d6

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

pages/generate_invitations_page.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def wait_for_invitation_generation_complete(self):
3535
logging.info(f"Waiting for successful generation")
3636
while elapsed < timeout: # there may be a stored procedure to speed this process up
3737
table_text = self.displayRS.text_content()
38-
if "Queued" in table_text or "In Progress" in table_text:
38+
if "Failed" in table_text:
39+
pytest.fail("Invitation has failed to generate")
40+
elif "Queued" in table_text or "In Progress" in table_text:
3941
# Click the Refresh button
4042
self.click_refresh_button()
4143
self.page.wait_for_timeout(wait_interval)
4244
elapsed += wait_interval
43-
elif "Failed" in table_text:
44-
pytest.fail("Invitation has failed to generate")
4545
else:
4646
break
4747

pages/log_out_page.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from playwright.sync_api import Page,expect
2-
2+
from pages.navigation_bar_links import NavigationBar
3+
import logging
34
class Logout:
45
def __init__(self, page: Page):
56
self.page = page
@@ -9,7 +10,8 @@ def __init__(self, page: Page):
910
def verify_log_out_page(self):
1011
expect(self.log_out_msg).to_be_visible()
1112

12-
13-
14-
15-
13+
def log_out(self):
14+
logging.info("Test Complete - Logging Out")
15+
NavigationBar(self.page).click_log_out_link()
16+
expect(self.log_out_msg).to_be_visible()
17+
self.page.close()

tests/Smokescreen/test_compartment_1.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
from utils.oracle import OracleDB
66

77
@pytest.mark.smoke
8-
@pytest.mark.smokescreen
98
@pytest.mark.compartment1
10-
def test_compartment_1(page: Page) -> None:
9+
def test_create_invitations_plan(page: Page) -> None:
10+
logging.info("Compartment 1 - Create Invitations Plan")
1111
UserTools.user_login(page, "Hub Manager State Registered")
12-
1312
# Create plan - England
1413
MainMenu(page).go_to_call_and_recall_page()
1514
CallAndRecall(page).go_to_planning_and_monitoring_page()
@@ -24,29 +23,36 @@ def test_compartment_1(page: Page) -> None:
2423
CreateAPlan(page).fill_note_field("test data")
2524
CreateAPlan(page).click_saveNote_button()
2625
InvitationsPlans(page).invitations_plans_title.wait_for()
26+
logging.info("Invitation plan created")
27+
28+
@pytest.mark.smoke
29+
@pytest.mark.smokescreen
30+
@pytest.mark.compartment1
31+
def test_compartment_1(page: Page) -> None:
32+
logging.info("Compartment 1 - Generate Invitations")
33+
UserTools.user_login(page, "Hub Manager State Registered")
2734

2835
# Generate Invitations
29-
NavigationBar(page).click_main_menu_link()
3036
MainMenu(page).go_to_call_and_recall_page()
3137
CallAndRecall(page).go_to_generate_invitations_page()
32-
logging.info("Generating Invitations")
38+
logging.info("Generating invitations based on the invitations plan")
3339
GenerateInvitations(page).click_generate_invitations_button()
3440
GenerateInvitations(page).wait_for_invitation_generation_complete()
3541

3642
# Print the batch of Pre-Invitation Letters - England
43+
logging.info("Compartment 1 - Process S1 Batch")
3744
batch_processing(page, "S1", "Pre-invitation (FIT) (digital leaflet)", "S9 - Pre-invitation Sent")
3845
nhs_number_df = batch_processing(page, "S1", "Pre-invitation (FIT)", "S9 - Pre-invitation Sent")
3946
OracleDB().exec_bcss_timed_events(nhs_number_df)
4047

4148
# Print the batch of Invitation & Test Kit Letters - England
49+
logging.info("Compartment 1 - Process S9 Batch")
4250
nhs_number_df = batch_processing(page, "S9", "Invitation & Test Kit (FIT)", "S10 - Invitation & Test Kit Sent")
4351
OracleDB().exec_bcss_timed_events(nhs_number_df)
4452

4553
# Print a set of reminder letters
54+
logging.info("Compartment 1 - Process S10 Batch")
4655
batch_processing(page, "S10", "Test Kit Reminder", "S19 - Reminder of Initial Test Sent")
4756

4857
# Log out
49-
logging.info("Logging Out")
50-
NavigationBar(page).click_log_out_link()
51-
Logout(page).verify_log_out_page()
52-
page.close()
58+
Logout(page).log_out()

tests/Smokescreen/test_compartment_2.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,4 @@ def test_compartment_2(page: Page) -> None:
5656
batch_processing(page, "S3", "Retest (Spoilt) (FIT)", "S11 - Retest Kit Sent (Spoilt)")
5757

5858
# Log out
59-
logging.info("Logging Out")
60-
NavigationBar(page).click_log_out_link()
61-
Logout(page).verify_log_out_page()
62-
page.close()
59+
Logout(page).log_out()

tests/Smokescreen/test_compartment_3.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,4 @@ def test_compartment_3(page: Page) -> None:
5656
OracleDB().exec_bcss_timed_events(nhs_number_df)
5757

5858
# Log out
59-
logging.info("Logging Out")
60-
NavigationBar(page).click_log_out_link()
61-
Logout(page).verify_log_out_page()
62-
page.close()
59+
Logout(page).log_out()

utils/batch_processing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
3434
# Find the first link in that row and click it
3535
link = row.locator("a").first
3636
link_text = link.inner_text() # Get the batch id dynamically
37+
logging.info(f"Successfully found open '{batch_type} - {batch_description}' batch")
3738
try:
38-
logging.info(f"Attempting to get NHS Numbers for batch: {link_text} from the DB")
39+
logging.info(f"Attempting to get NHS Numbers for batch {link_text} from the DB")
3940
nhs_no_df = get_nhs_no_from_batch_id(link_text)
40-
logging.info(f"Successfully retrieved NHS Numbers from batch: {link_text}")
41+
logging.info(f"Successfully retrieved NHS Numbers from batch {link_text}")
4142
except Exception as e:
42-
pytest.fail(f"Failed to retrieve NHS Numbers from batch: {link_text}, {str(e)}")
43+
pytest.fail(f"Failed to retrieve NHS Numbers from batch {link_text}, {str(e)}")
4344
link.click()
4445
break
4546
else:

utils/oracle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def exec_bcss_timed_events(self, nhs_number_df): # Executes bcss_timed_events wh
2323
cursor.execute(f"SELECT SCREENING_SUBJECT_ID FROM SCREENING_SUBJECT_T WHERE SUBJECT_NHS_NUMBER = {int(row["subject_nhs_number"])}")
2424
result = cursor.fetchall()
2525
subject_id = result[0][0]
26-
logging.info("Able to extract subject ID")
26+
logging.info(f"Able to extract subject ID: {subject_id}")
2727
try:
2828
logging.info(f"Attempting to execute stored procedure: {f"'bcss_timed_events', [{subject_id},'Y']"}")
2929
cursor = conn.cursor()

0 commit comments

Comments
 (0)