Skip to content

Commit 4905d98

Browse files
Making test_properties into its own util: BCSS-20024
1 parent 3900e96 commit 4905d98

File tree

8 files changed

+84
-164
lines changed

8 files changed

+84
-164
lines changed

tests/smokescreen/test_compartment_1.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from sys import platform
21
import pytest
32
import logging
4-
from jproperties import Properties
53
from pages.logout.log_out_page import Logout
64
from utils.user_tools import UserTools
75
from pages.base_page import BasePage
@@ -12,28 +10,13 @@
1210
from pages.call_and_recall.generate_invitations_page import GenerateInvitations
1311
from playwright.sync_api import Page
1412
from utils.batch_processing import batch_processing
13+
from utils.load_properties_file import PropertiesFile
1514

1615

1716
@pytest.fixture
1817
def smokescreen_properties() -> dict:
19-
"""
20-
Reads the 'bcss_smokescreen_tests.properties' file and populates a 'Properties' object.
21-
Returns a dictionary of properties for use in tests.
22-
23-
Returns:
24-
dict: A dictionary containing the values loaded from the 'bcss_smokescreen_tests.properties' file.
25-
"""
26-
configs = Properties()
27-
if platform == "win32": # File path from content root is required on Windows OS
28-
with open(
29-
"tests/smokescreen/bcss_smokescreen_tests.properties", "rb"
30-
) as read_prop:
31-
configs.load(read_prop)
32-
elif platform == "darwin": # Only the filename is required on macOS
33-
with open("bcss_smokescreen_tests.properties", "rb") as read_prop:
34-
configs.load(read_prop)
35-
return configs.properties
36-
18+
properties = PropertiesFile().smokescreen_properties("compartment")
19+
return properties
3720

3821
@pytest.mark.smoke
3922
@pytest.mark.compartment1

tests/smokescreen/test_compartment_2.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,13 @@
1010
from utils.fit_kit_generation import create_fit_id_df
1111
from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no
1212
from utils.user_tools import UserTools
13-
from jproperties import Properties
14-
from sys import platform
13+
from utils.load_properties_file import PropertiesFile
1514

1615

1716
@pytest.fixture
1817
def smokescreen_properties() -> dict:
19-
"""
20-
Reads the 'bcss_smokescreen_tests.properties' file and populates a 'Properties' object.
21-
Returns a dictionary of properties for use in tests.
22-
23-
Returns:
24-
dict: A dictionary containing the values loaded from the 'bcss_smokescreen_tests.properties' file.
25-
"""
26-
configs = Properties()
27-
if platform == "win32": # File path from content root is required on Windows OS
28-
with open(
29-
"tests/smokescreen/bcss_smokescreen_tests.properties", "rb"
30-
) as read_prop:
31-
configs.load(read_prop)
32-
elif platform == "darwin": # Only the filename is required on macOS
33-
with open("bcss_smokescreen_tests.properties", "rb") as read_prop:
34-
configs.load(read_prop)
35-
return configs.properties
18+
properties = PropertiesFile().smokescreen_properties("compartment")
19+
return properties
3620

3721

3822
@pytest.mark.smoke

tests/smokescreen/test_compartment_3.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,13 @@
1010
execute_fit_kit_stored_procedures,
1111
)
1212
from utils.user_tools import UserTools
13-
from jproperties import Properties
14-
from sys import platform
13+
from utils.load_properties_file import PropertiesFile
1514

1615

1716
@pytest.fixture
1817
def smokescreen_properties() -> dict:
19-
"""
20-
Reads the 'bcss_smokescreen_tests.properties' file and populates a 'Properties' object.
21-
Returns a dictionary of properties for use in tests.
22-
23-
Returns:
24-
dict: A dictionary containing the values loaded from the 'bcss_smokescreen_tests.properties' file.
25-
"""
26-
configs = Properties()
27-
if platform == "win32": # File path from content root is required on Windows OS
28-
with open(
29-
"tests/smokescreen/bcss_smokescreen_tests.properties", "rb"
30-
) as read_prop:
31-
configs.load(read_prop)
32-
elif platform == "darwin": # Only the filename is required on macOS
33-
with open("bcss_smokescreen_tests.properties", "rb") as read_prop:
34-
configs.load(read_prop)
35-
return configs.properties
18+
properties = PropertiesFile().smokescreen_properties("compartment")
19+
return properties
3620

3721

3822
@pytest.mark.smokescreen

tests/test_call_and_recall_page.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pytest
2-
from sys import platform
32
from playwright.sync_api import Page
43
from pages.base_page import BasePage
54
from pages.call_and_recall.call_and_recall_page import CallAndRecall
@@ -10,26 +9,13 @@
109
from pages.call_and_recall.invitations_plans_page import InvitationsPlans
1110
from pages.call_and_recall.create_a_plan_page import CreateAPlan
1211
from utils.user_tools import UserTools
13-
from jproperties import Properties
12+
from utils.load_properties_file import PropertiesFile
1413

1514

1615
@pytest.fixture
17-
def tests_properties() -> dict:
18-
"""
19-
Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
20-
Returns a dictionary of properties for use in tests.
21-
22-
Returns:
23-
dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
24-
"""
25-
configs = Properties()
26-
if platform == "win32": # File path from content root is required on Windows OS
27-
with open("tests/bcss_tests.properties", "rb") as read_prop:
28-
configs.load(read_prop)
29-
elif platform == "darwin": # Only the filename is required on macOS
30-
with open("bcss_tests.properties", "rb") as read_prop:
31-
configs.load(read_prop)
32-
return configs.properties
16+
def smokescreen_properties() -> dict:
17+
properties = PropertiesFile().smokescreen_properties("smoke")
18+
return properties
3319

3420

3521
@pytest.fixture(scope="function", autouse=True)
@@ -79,7 +65,7 @@ def test_call_and_recall_page_navigation(page: Page) -> None:
7965
BasePage(page).main_menu_header_is_displayed()
8066

8167

82-
def test_view_an_invitation_plan(page: Page, tests_properties: dict) -> None:
68+
def test_view_an_invitation_plan(page: Page, smokescreen_properties: dict) -> None:
8369
"""
8470
Confirms that an invitation plan can be viewed via a screening centre from the planning ad monitoring page
8571
"""
@@ -88,7 +74,7 @@ def test_view_an_invitation_plan(page: Page, tests_properties: dict) -> None:
8874

8975
# Select a screening centre
9076
InvitationsMonitoring(page).go_to_invitation_plan_page(
91-
tests_properties["screening_centre_code"]
77+
smokescreen_properties["screening_centre_code"]
9278
)
9379

9480
# Select an invitation plan

tests/test_organisations_page.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
from sys import platform
21
import pytest
3-
from jproperties import Properties
42
from playwright.sync_api import Page, expect
53
from pages.base_page import BasePage
64
from pages.organisations.organisations_page import OrganisationsPage
75
from utils.user_tools import UserTools
6+
from utils.load_properties_file import PropertiesFile
87

98

109
@pytest.fixture
11-
def tests_properties() -> dict:
12-
"""
13-
Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
14-
Returns a dictionary of properties for use in tests.
15-
16-
Returns:
17-
dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
18-
"""
19-
configs = Properties()
20-
if platform == "win32": # File path from content root is required on Windows OS
21-
with open("tests/bcss_tests.properties", "rb") as read_prop:
22-
configs.load(read_prop)
23-
elif platform == "darwin": # Only the filename is required on macOS
24-
with open("bcss_tests.properties", "rb") as read_prop:
25-
configs.load(read_prop)
26-
return configs.properties
10+
def smokescreen_properties() -> dict:
11+
properties = PropertiesFile().smokescreen_properties("smoke")
12+
return properties
2713

2814

2915
@pytest.fixture(scope="function", autouse=True)
@@ -86,7 +72,7 @@ def test_organisations_page_navigation(page: Page) -> None:
8672

8773

8874
def test_view_an_organisations_system_parameters(
89-
page: Page, tests_properties: dict
75+
page: Page, smokescreen_properties: dict
9076
) -> None:
9177
"""
9278
Confirms that an organisation's system parameters can be accessed and viewed
@@ -95,7 +81,7 @@ def test_view_an_organisations_system_parameters(
9581
OrganisationsPage(page).go_to_screening_centre_parameters_page()
9682

9783
# View an Organisation
98-
page.get_by_role("link", name=tests_properties["screening_centre_code"]).click()
84+
page.get_by_role("link", name=smokescreen_properties["screening_centre_code"]).click()
9985
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
10086
"System Parameters"
10187
)

tests/test_reports_page.py

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
import pytest
22
from playwright.sync_api import Page, expect
3-
from sys import platform
43
from pages.base_page import BasePage
54
from pages.reports.reports_page import ReportsPage
65
from utils.date_time_utils import DateTimeUtils
76
from utils.user_tools import UserTools
8-
from jproperties import Properties
7+
from utils.load_properties_file import PropertiesFile
98

109

1110
@pytest.fixture
12-
def tests_properties() -> dict:
13-
"""
14-
Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
15-
Returns a dictionary of properties for use in tests.
16-
17-
Returns:
18-
dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
19-
"""
20-
configs = Properties()
21-
if platform == "win32": # File path from content root is required on Windows OS
22-
with open("tests/bcss_tests.properties", "rb") as read_prop:
23-
configs.load(read_prop)
24-
elif platform == "darwin": # Only the filename is required on macOS
25-
with open("bcss_tests.properties", "rb") as read_prop:
26-
configs.load(read_prop)
27-
return configs.properties
11+
def smokescreen_properties() -> dict:
12+
properties = PropertiesFile().smokescreen_properties("smoke")
13+
return properties
2814

2915

3016
@pytest.fixture(scope="function", autouse=True)
@@ -204,7 +190,7 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(
204190

205191

206192
def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries(
207-
page: Page, tests_properties: dict
193+
page: Page, smokescreen_properties: dict
208194
) -> None:
209195
"""
210196
Confirms 'allocate_sc_for_patient_movements_within_hub_boundaries' page loads,
@@ -247,15 +233,15 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
247233

248234
# Select another screening centre
249235
set_patients_screening_centre_dropdown.select_option(
250-
tests_properties["coventry_and_warwickshire_bcs_centre"]
236+
smokescreen_properties["coventry_and_warwickshire_bcs_centre"]
251237
)
252238

253239
# Click update
254240
failsafe_report_page.click_reports_pages_update_button()
255241

256242
# Verify new screening centre has saved
257243
expect(ReportsPage(page).set_patients_screening_centre_dropdown).to_have_value(
258-
tests_properties["coventry_and_warwickshire_bcs_centre"]
244+
smokescreen_properties["coventry_and_warwickshire_bcs_centre"]
259245
)
260246

261247

@@ -346,7 +332,7 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
346332

347333
# Operational Reports
348334
def test_operational_reports_appointment_attendance_not_updated(
349-
page: Page, tests_properties: dict
335+
page: Page, smokescreen_properties: dict
350336
) -> None:
351337
"""
352338
Confirms 'appointment_attendance_not_updated' page loads,
@@ -375,7 +361,7 @@ def test_operational_reports_appointment_attendance_not_updated(
375361

376362
# Select a screening centre from the drop-down options
377363
set_patients_screening_centre_dropdown.select_option(
378-
tests_properties["coventry_and_warwickshire_bcs_centre"]
364+
smokescreen_properties["coventry_and_warwickshire_bcs_centre"]
379365
)
380366

381367
# Click "Generate Report" button
@@ -447,7 +433,7 @@ def test_operational_reports_demographic_update_inconsistent_with_manual_update(
447433

448434

449435
def test_operational_reports_screening_practitioner_6_weeks_availability_not_set_up(
450-
page: Page, tests_properties: dict
436+
page: Page, smokescreen_properties: dict
451437
) -> None:
452438
"""
453439
Confirms 'screening_practitioner_6_weeks_availability_not_set_up_report' page loads,
@@ -474,7 +460,7 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
474460

475461
# Select a screening centre
476462
set_patients_screening_centre_dropdown.select_option(
477-
tests_properties["coventry_and_warwickshire_bcs_centre"]
463+
smokescreen_properties["coventry_and_warwickshire_bcs_centre"]
478464
)
479465

480466
# Click "Generate Report"
@@ -494,7 +480,7 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
494480

495481
@pytest.mark.only
496482
def test_operational_reports_screening_practitioner_appointments(
497-
page: Page, tests_properties: dict
483+
page: Page, smokescreen_properties: dict
498484
) -> None:
499485
"""
500486
Confirms 'screening_practitioner_appointments' page loads,
@@ -523,12 +509,12 @@ def test_operational_reports_screening_practitioner_appointments(
523509

524510
# Select a screening centre
525511
set_patients_screening_centre_dropdown.select_option(
526-
tests_properties["coventry_and_warwickshire_bcs_centre"]
512+
smokescreen_properties["coventry_and_warwickshire_bcs_centre"]
527513
)
528514

529515
# Select a screening practitioner
530516
screening_practitioner_dropdown.select_option(
531-
tests_properties["screening_practitioner_named_another_stubble"]
517+
smokescreen_properties["screening_practitioner_named_another_stubble"]
532518
)
533519

534520
# Click "Generate Report"

0 commit comments

Comments
 (0)