Skip to content

Commit 36a9506

Browse files
committed
Removed hard coded values from tests, added properties files for tests and smokescreen tests.
Changed properties keys from camel case to snake case, to be consistent with Python's naming conventions. Some general refactoring. # Conflicts: # tests/Smokescreen/test_compartment_1.py
1 parent 8959a1d commit 36a9506

13 files changed

+269
-67
lines changed

pages/create_a_plan_page.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from playwright.sync_api import Page
22

3+
34
class CreateAPlan:
45
def __init__(self, page: Page):
56
self.page = page
@@ -16,7 +17,7 @@ def __init__(self, page: Page):
1617
def click_set_all_button(self):
1718
self.set_all_button.click()
1819

19-
def fill_daily_invitation_rate_field(self,value):
20+
def fill_daily_invitation_rate_field(self,value: str):
2021
self.daily_invitation_rate_field.fill(value)
2122

2223
def fill_weekly_invitation_rate_field(self,value):
@@ -36,6 +37,3 @@ def fill_note_field(self,value):
3637

3738
def click_saveNote_button(self):
3839
self.saveNote_button.click()
39-
40-
41-
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
from playwright.sync_api import Page
22

3+
34
class InvitationsMonitoring:
45
def __init__(self, page: Page):
56
self.page = page
6-
# Call and Recall - page links
7-
self.bcss009_invitations_plan = self.page.get_by_role("link", name="BCS009")
8-
self.bcss001_invitations_plan = self.page.get_by_role("link", name="BCS001")
9-
10-
def go_to_bcss009_invitations_plan_page(self):
11-
self.bcss009_invitations_plan.click()
12-
13-
def go_to_bcss001_invitations_plan_page(self):
14-
self.bcss001_invitations_plan.click()
15-
16-
177

8+
def go_to_invitation_plan_page(self, sc_id):
9+
self.page.get_by_role("link", name=sc_id).click()

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
pytest-playwright>=0.5.1
22
pytest-html>=4.1.1
33
pytest-json-report>=1.5.0
4+
oracledb~=3.0.0
5+
pandas~=2.2.3
46
python-dotenv~=1.0.1
7+
Flask~=3.0.3
8+
sqlalchemy>=2.0.38
9+
jproperties~=2.1.2
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# ----------------------------------
2+
# compartment 1
3+
# ----------------------------------
4+
c1_daily_invitation_rate=10
5+
c1_screening_centre_code=BCS001
6+
7+
# ----------------------------------
8+
# compartment 2
9+
# ----------------------------------
10+
# c2_fit_kit_logging_test_org_id=23159
11+
# c2_eng_gfobt_kit_logging_test_org_id=23159
12+
13+
# ----------------------------------
14+
# compartment 3
15+
# ----------------------------------
16+
# c3_fit_kit_results_test_org_id=23159
17+
# c3_fit_kit_normal_result=75
18+
# c3_fit_kit_abnormal_result=150
19+
# c3_fit_kit_authorised_user=AUTO1
20+
# c3_fit_kit_analyser_code=HMJackalt1
21+
22+
# ----------------------------------
23+
# compartment 4
24+
# ----------------------------------
25+
# c4_eng_org_id=23159
26+
# c4_eng_centre_name=Wolverhampton
27+
# c4_eng_site_name=Royal Hospital
28+
# c4_eng_practitioner_id=243
29+
# c4_eng_practitioner_name=Arvind, Vanaja
30+
# c4_eng_practitioner_name=Macarena, Gave #use this for anonymised
31+
# c4_eng_practitioner_id_for_rebooking=870
32+
# c4_eng_practitioner_name_for_rebookings=Burns, Harriet
33+
34+
# ----------------------------------
35+
# compartment 6
36+
# ----------------------------------
37+
# c6_eng_org_id=23159
38+
# c6_eng_site_id=35317
39+
# c6_eng_practitioner_id=243
40+
# c6_eng_testing_clinician_id=805
41+
# c6_eng_aspirant_endoscopist_id=1731
42+
43+
# ----------------------------------
44+
# NUMBER OF KITS / SUBJECTS TO PROCESS IN EACH COMPARTMENT
45+
# ----------------------------------
46+
# NOTE: England gFOBT has been turned off (all values set to 0), properties have been left just in case for now
47+
48+
# ----------------------------------
49+
# compartment 1
50+
# ----------------------------------
51+
# c1_eng_number_of_batches_to_create=1
52+
53+
# ----------------------------------
54+
# compartment 2
55+
# ----------------------------------
56+
# c2_eng_number_of_fit_kits_to_log=8
57+
# c2_eng_number_of_gfobt_kits_to_log=0
58+
# ## Spare subjects (subjects required for subject creation check = fit kits to log + gfobt kits to log + spare subject count)
59+
# ## NOTE: Should be at least 1 due to poke the beast requiring a subject to log a fit kit for on National
60+
# c2_spare_subject_count=5
61+
62+
# ----------------------------------
63+
# compartment 3
64+
# ----------------------------------
65+
# c3_eng_number_of_abnormal_gfobt_kits_to_log=0
66+
# c3_eng_number_of_normal_gfobt_kits_to_log=0
67+
# c3_eng_number_of_weak_positive_gfobt_kits_to_log=0
68+
# c3_eng_number_of_abnormal_fit_kits=7
69+
# c3_eng_number_of_normal_fit_kits=1
70+
71+
# ----------------------------------
72+
# compartment 4
73+
# ----------------------------------
74+
# # note there is a max of 16 slots available each day
75+
# c4_eng_number_of_appointments_to_book=6
76+
77+
# ----------------------------------
78+
# compartment 5
79+
# ----------------------------------
80+
# c5_eng_number_of_screening_appts_to_attend=6
81+
82+
# ----------------------------------
83+
# compartment 6
84+
# ----------------------------------
85+
# c6_eng_number_of_normal_results_to_record=2
86+
# c6_eng_number_of_lnpcp_results_to_record=1
87+
# c6_eng_number_of_high_risk_findings_results_to_record=1
88+
# c6_eng_number_of_lnpcp_results_over_74_to_record=1
89+
# c6_eng_number_of_high_risk_findings_results_over_74_to_record=1

tests/Smokescreen/test_compartment_1.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
import pytest
2-
from playwright.sync_api import Page
2+
from jproperties import Properties
3+
34
from my_pages import *
45
from utils.batch_processing import batch_processing
56
from utils.oracle import OracleDB
67

8+
9+
@pytest.fixture
10+
def smokescreen_properties() -> dict:
11+
"""
12+
Reads the 'bcss_smokescreen_tests.properties' file and populates a 'Properties' object.
13+
Returns a dictionary of properties for use in tests.
14+
15+
Returns:
16+
dict: A dictionary containing the values loaded from the 'bcss_smokescreen_tests.properties' file.
17+
"""
18+
configs = Properties()
19+
with open('bcss_smokescreen_tests.properties', 'rb') as read_prop:
20+
configs.load(read_prop)
21+
return configs.properties
22+
23+
724
@pytest.mark.smoke
825
@pytest.mark.compartment1
9-
def test_create_invitations_plan(page: Page) -> None:
26+
def test_compartment_1(page: Page, smokescreen_properties: dict) -> None:
1027
logging.info("Compartment 1 - Create Invitations Plan")
1128
UserTools.user_login(page, "Hub Manager State Registered")
1229
# Create plan - England
1330
MainMenu(page).go_to_call_and_recall_page()
1431
CallAndRecall(page).go_to_planning_and_monitoring_page()
15-
InvitationsMonitoring(page).go_to_bcss001_invitations_plan_page()
32+
InvitationsMonitoring(page).go_to_invitation_plan_page(smokescreen_properties["c1_screening_centre_code"])
1633
InvitationsPlans(page).go_to_create_a_plan_page()
1734
logging.info("Setting daily invitation rate")
1835
CreateAPlan(page).click_set_all_button()
19-
CreateAPlan(page).fill_daily_invitation_rate_field("10")
36+
CreateAPlan(page).fill_daily_invitation_rate_field(smokescreen_properties["c1_daily_invitation_rate"])
2037
CreateAPlan(page).click_update_button()
2138
CreateAPlan(page).click_confirm_button()
2239
CreateAPlan(page).click_save_button()

tests/Smokescreen/test_compartment_2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from utils.fit_kit_generation import create_fit_id_df
88
import logging
99

10+
1011
@pytest.mark.smoke
1112
@pytest.mark.smokescreen
1213
@pytest.mark.compartment2
@@ -22,7 +23,7 @@ def test_compartment_2(page: Page) -> None:
2223
logging.info(f"Logging FIT Device ID: {fit_device_id}")
2324
LogDevices(page).fill_fit_device_id_field(fit_device_id)
2425
sample_date = datetime.now().strftime("%#d %b %Y")
25-
logging.info("Setting sample date to todays date")
26+
logging.info("Setting sample date to today's date")
2627
LogDevices(page).fill_sample_date_field(sample_date)
2728
try:
2829
LogDevices(page).verify_successfully_logged_device_text()
@@ -33,7 +34,8 @@ def test_compartment_2(page: Page) -> None:
3334
nhs_no = subjectdf["subject_nhs_number"].iloc[0]
3435
try:
3536
verify_subject_event_status_by_nhs_no(page, nhs_no, "S43 - Kit Returned and Logged (Initial Test)")
36-
logging.info(f"Successfully verified NHS number {nhs_no} with status S43 - Kit Returned and Logged (Initial Test)")
37+
logging.info(
38+
f"Successfully verified NHS number {nhs_no} with status S43 - Kit Returned and Logged (Initial Test)")
3739
except Exception as e:
3840
pytest.fail(f"Verification failed for NHS number {nhs_no}: {str(e)}")
3941

@@ -50,8 +52,7 @@ def test_compartment_2(page: Page) -> None:
5052
LogDevices(page).verify_successfully_logged_device_text()
5153
logging.info(f"{spoilt_fit_device_id} Successfully logged")
5254
except:
53-
pytest.fail(f"{spoilt_fit_device_id} unsuccessfully logged")
54-
55+
pytest.fail(f"{spoilt_fit_device_id} Unsuccessfully logged")
5556

5657
batch_processing(page, "S3", "Retest (Spoilt) (FIT)", "S11 - Retest Kit Sent (Spoilt)")
5758

tests/Smokescreen/test_compartment_3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
from utils.oracle import OracleDB
1010
from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no
1111

12+
1213
@pytest.mark.smokescreen
1314
@pytest.mark.compartment3
1415
def test_compartment_3(page: Page) -> None:
1516
UserTools.user_login(page, "Hub Manager State Registered")
1617

17-
# (STEP 1 ,2 & 3) find data , seperate it into normal and abnormal, Add results to the test records in the KIT_QUEUE table (i.e. mimic receiving results from the middleware)
18+
# (STEP 1 ,2 & 3) find data , separate it into normal and abnormal, Add results to the test records in the KIT_QUEUE table (i.e. mimic receiving results from the middleware)
1819
# and get device IDs and their flags
1920
device_ids = process_kit_data()
2021
# Retrieve NHS numbers for each device_id and determine normal/abnormal status
@@ -25,13 +26,15 @@ def test_compartment_3(page: Page) -> None:
2526
nhs_number = update_kit_service_management_entity(device_id, is_normal)
2627
nhs_numbers.append(nhs_number)
2728
normal_flags.append(is_normal) # Store the flag (True for normal, False for abnormal)
29+
2830
# (STEP - 4) Run two stored procedures to process any kit queue records at status BCSS_READY
2931
try:
3032
fit_kit_logged.execute_stored_procedures()
3133
logging.info("Stored procedures executed successfully.")
3234
except Exception as e:
3335
logging.error(f"Error executing stored procedures: {str(e)}")
3436
raise
37+
3538
# (STEP - 5) Check the results of the processed FIT kits have correctly updated the status of the associated subjects
3639
# Verify subject event status based on normal or abnormal classification
3740
for nhs_number, is_normal in zip(nhs_numbers, normal_flags):

tests/bcss_tests.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ----------------------------------
2+
# SCREENING CENTRES, CCGs, HUBS & GPs
3+
# ----------------------------------
4+
screening_centre_code=BCS001
5+
eng_screening_centre_id=23162
6+
eng_hub_id=23159
7+
gp_practice_code=C81001
8+
ccg_code=Z1Z1Z
9+
10+
# ----------------------------------
11+
# SUBJECT / PATIENT SEARCH TEST DATA
12+
# ----------------------------------
13+
nhs_number=966 529 9271
14+
forename=Pentagram
15+
surname=Absurd
16+
subject_dob=11/01/1934
17+
episode_closed_date=22/09/2020

tests/test_call_and_recall_page.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
from playwright.sync_api import Page, expect
33
from pages.bcss_home_page import MainMenu
44
from utils.user_tools import UserTools
5+
from jproperties import Properties
6+
7+
8+
@pytest.fixture
9+
def tests_properties() -> dict:
10+
"""
11+
Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
12+
Returns a dictionary of properties for use in tests.
13+
14+
Returns:
15+
dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
16+
"""
17+
configs = Properties()
18+
with open('bcss_tests.properties', 'rb') as read_prop:
19+
configs.load(read_prop)
20+
return configs.properties
521

622

723
@pytest.fixture(scope="function", autouse=True)
@@ -51,15 +67,15 @@ def test_call_and_recall_page_navigation(page: Page) -> None:
5167
expect(page.locator("#ntshPageTitle")).to_contain_text("Main Menu")
5268

5369

54-
def test_view_an_invitation_plan(page: Page) -> None:
70+
def test_view_an_invitation_plan(page: Page, tests_properties: dict) -> None:
5571
"""
5672
Confirms that an invitation plan can be viewed via a screening centre from the planning ad monitoring page
5773
"""
5874
# Go to planning and monitoring page
5975
page.get_by_role("link", name="Planning and Monitoring").click()
6076

6177
# Select a screening centre
62-
page.get_by_role("link", name="BCS009").click()
78+
page.get_by_role("link", name=tests_properties["screening_centre_code"]).click()
6379

6480
# Select an invitation plan
6581
page.get_by_role("row").nth(1).get_by_role("link").click()

tests/test_gfobt_test_kits_page.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,24 @@ def test_create_a_qc_kit(page: Page) -> None:
5151
"""
5252
Confirms that a qc test kit can be created and that each of the dropdowns has an option set available for selection
5353
"""
54+
# 'Reading' dropdown locators
55+
reading1dropdown = page.locator("#A_C_Reading_999_0_0")
56+
reading2dropdown = page.locator("#A_C_Reading_999_0_1")
57+
reading3dropdown = page.locator("#A_C_Reading_999_1_0")
58+
reading4dropdown = page.locator("#A_C_Reading_999_1_1")
59+
reading5dropdown = page.locator("#A_C_Reading_999_2_0")
60+
reading6dropdown = page.locator("#A_C_Reading_999_2_1")
61+
5462
# Navigate to create QC kit page
5563
page.get_by_role("link", name="Create QC Kit").click()
5664

5765
# Select QC kit drop down options
58-
page.locator("#A_C_Reading_999_0_0").select_option("NEGATIVE")
59-
page.locator("#A_C_Reading_999_0_1").select_option("POSITIVE")
60-
page.locator("#A_C_Reading_999_1_0").select_option("POSITIVE")
61-
page.locator("#A_C_Reading_999_1_1").select_option("UNUSED")
62-
page.locator("#A_C_Reading_999_2_0").select_option("NEGATIVE")
63-
page.locator("#A_C_Reading_999_2_1").select_option("POSITIVE")
66+
reading1dropdown.select_option("NEGATIVE")
67+
reading2dropdown.select_option("POSITIVE")
68+
reading3dropdown.select_option("POSITIVE")
69+
reading4dropdown.select_option("UNUSED")
70+
reading5dropdown.select_option("NEGATIVE")
71+
reading6dropdown.select_option("POSITIVE")
6472

6573
# Click save
6674
page.get_by_role("button", name="Save Kit").click()

0 commit comments

Comments
 (0)