Skip to content

Commit d6d4b0f

Browse files
adrianoaru-nhsAndyg79
authored andcommitted
Making test_properties into its own util: BCSS-20024 (#15)
<!-- markdownlint-disable-next-line first-line-heading --> <!-- Describe your changes in detail. --> This is moving all of the smokescreen_properties/test_properties methods into a util to be used by all tests. As there are two different property files, one for the compartments and one for the rest I added an if statement to select between them depending on the input provided This change is tracked by the Jira ticket: [BCSS-20024](https://nhsd-jira.digital.nhs.uk/browse/BCSS-20024) <!-- Why is this change required? What problem does it solve? --> This helps to reduce the number of duplicate code and we can easier load the properties file across all of our tests with the same method, instead of repeating it again for each test. <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 47ac901 commit d6d4b0f

File tree

8 files changed

+125
-182
lines changed

8 files changed

+125
-182
lines changed

tests/smokescreen/test_compartment_1.py

Lines changed: 2 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,12 @@
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+
return PropertiesFile().get_smokescreen_properties()
3719

3820
@pytest.mark.smoke
3921
@pytest.mark.compartment1

tests/smokescreen/test_compartment_2.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,12 @@
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+
return PropertiesFile().get_smokescreen_properties()
3619

3720

3821
@pytest.mark.smoke

tests/smokescreen/test_compartment_3.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,12 @@
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+
return PropertiesFile().get_smokescreen_properties()
3619

3720

3821
@pytest.mark.smokescreen

tests/test_call_and_recall_page.py

Lines changed: 5 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,12 @@
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 general_properties() -> dict:
17+
return PropertiesFile().get_general_properties()
3318

3419

3520
@pytest.fixture(scope="function", autouse=True)
@@ -79,7 +64,7 @@ def test_call_and_recall_page_navigation(page: Page) -> None:
7964
BasePage(page).main_menu_header_is_displayed()
8065

8166

82-
def test_view_an_invitation_plan(page: Page, tests_properties: dict) -> None:
67+
def test_view_an_invitation_plan(page: Page, general_properties: dict) -> None:
8368
"""
8469
Confirms that an invitation plan can be viewed via a screening centre from the planning ad monitoring page
8570
"""
@@ -88,7 +73,7 @@ def test_view_an_invitation_plan(page: Page, tests_properties: dict) -> None:
8873

8974
# Select a screening centre
9075
InvitationsMonitoring(page).go_to_invitation_plan_page(
91-
tests_properties["screening_centre_code"]
76+
general_properties["screening_centre_code"]
9277
)
9378

9479
# Select an invitation plan

tests/test_organisations_page.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
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 general_properties() -> dict:
11+
return PropertiesFile().get_general_properties()
2712

2813

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

8772

8873
def test_view_an_organisations_system_parameters(
89-
page: Page, tests_properties: dict
74+
page: Page, general_properties: dict
9075
) -> None:
9176
"""
9277
Confirms that an organisation's system parameters can be accessed and viewed
@@ -95,7 +80,7 @@ def test_view_an_organisations_system_parameters(
9580
OrganisationsPage(page).go_to_screening_centre_parameters_page()
9681

9782
# View an Organisation
98-
page.get_by_role("link", name=tests_properties["screening_centre_code"]).click()
83+
page.get_by_role("link", name=general_properties["screening_centre_code"]).click()
9984
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
10085
"System Parameters"
10186
)

tests/test_reports_page.py

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
11
import pytest
22
from playwright.sync_api import Page, expect
3-
<<<<<<< HEAD
4-
=======
5-
from sys import platform
6-
>>>>>>> 9311a0b (BCSS-20020: Compartment 1 Smokescreen Tests (#7))
73
from pages.base_page import BasePage
84
from pages.reports.reports_page import ReportsPage
95
from utils.date_time_utils import DateTimeUtils
106
from utils.user_tools import UserTools
11-
from jproperties import Properties
12-
<<<<<<< HEAD
13-
import os
14-
=======
15-
>>>>>>> 9311a0b (BCSS-20020: Compartment 1 Smokescreen Tests (#7))
7+
from utils.load_properties_file import PropertiesFile
168

179

1810
@pytest.fixture
19-
def tests_properties() -> dict:
20-
"""
21-
Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
22-
Returns a dictionary of properties for use in tests.
23-
24-
Returns:
25-
dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
26-
"""
27-
<<<<<<< HEAD
28-
path = f"{os.getcwd()}/tests/bcss_tests.properties"
29-
configs = Properties()
30-
with open(path, "rb") as read_prop:
31-
configs.load(read_prop)
32-
=======
33-
configs = Properties()
34-
if platform == "win32": # File path from content root is required on Windows OS
35-
with open("tests/bcss_tests.properties", "rb") as read_prop:
36-
configs.load(read_prop)
37-
elif platform == "darwin": # Only the filename is required on macOS
38-
with open("bcss_tests.properties", "rb") as read_prop:
39-
configs.load(read_prop)
40-
>>>>>>> 9311a0b (BCSS-20020: Compartment 1 Smokescreen Tests (#7))
41-
return configs.properties
11+
def general_properties() -> dict:
12+
return PropertiesFile().get_general_properties()
4213

4314

4415
@pytest.fixture(scope="function", autouse=True)
@@ -273,7 +244,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
273244

274245

275246
def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries(
276-
page: Page, tests_properties: dict
247+
page: Page, general_properties: dict
277248
) -> None:
278249
"""
279250
Confirms 'allocate_sc_for_patient_movements_within_hub_boundaries' page loads,
@@ -338,15 +309,15 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
338309

339310
# Select another screening centre
340311
set_patients_screening_centre_dropdown.select_option(
341-
tests_properties["coventry_and_warwickshire_bcs_centre"]
312+
general_properties["coventry_and_warwickshire_bcs_centre"]
342313
)
343314

344315
# Click update
345316
failsafe_report_page.click_reports_pages_update_button()
346317

347318
# Verify new screening centre has saved
348319
expect(ReportsPage(page).set_patients_screening_centre_dropdown).to_have_value(
349-
tests_properties["coventry_and_warwickshire_bcs_centre"]
320+
general_properties["coventry_and_warwickshire_bcs_centre"]
350321
)
351322

352323

@@ -478,7 +449,7 @@ def test_operational_reports_appointment_attendance_not_updated(
478449

479450
# Operational Reports
480451
def test_operational_reports_appointment_attendance_not_updated(
481-
page: Page, tests_properties: dict
452+
page: Page, general_properties: dict
482453
) -> None:
483454
"""
484455
Confirms 'appointment_attendance_not_updated' page loads,
@@ -508,17 +479,15 @@ def test_operational_reports_appointment_attendance_not_updated(
508479
)
509480

510481
# Select a screening centre from the drop-down options
511-
ReportsPage(
512-
page
513-
).attendance_not_updated_set_patients_screening_centre_dropdown.select_option(
514-
tests_properties["coventry_and_warwickshire_bcs_centre"]
482+
set_patients_screening_centre_dropdown.select_option(
483+
general_properties["coventry_and_warwickshire_bcs_centre"]
515484
)
516485
=======
517486
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Appointment Attendance Not Updated")
518487

519488
# Select a screening centre from the drop-down options
520489
set_patients_screening_centre_dropdown.select_option(
521-
tests_properties["coventry_and_warwickshire_bcs_centre"]
490+
general_properties["coventry_and_warwickshire_bcs_centre"]
522491
)
523492

524493
# Click "Generate Report" button
@@ -606,7 +575,7 @@ def test_operational_reports_demographic_update_inconsistent_with_manual_update(
606575

607576

608577
def test_operational_reports_screening_practitioner_6_weeks_availability_not_set_up(
609-
page: Page, tests_properties: dict
578+
page: Page, general_properties: dict
610579
) -> None:
611580
"""
612581
Confirms 'screening_practitioner_6_weeks_availability_not_set_up_report' page loads,
@@ -651,7 +620,19 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
651620

652621
# Select a screening centre
653622
set_patients_screening_centre_dropdown.select_option(
654-
tests_properties["coventry_and_warwickshire_bcs_centre"]
623+
general_properties["coventry_and_warwickshire_bcs_centre"]
624+
)
625+
=======
626+
ReportsPage(page).go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page()
627+
628+
# Verify page title is "Screening Practitioner 6 Weeks Availability Not Set Up"
629+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
630+
"Screening Practitioner 6 Weeks Availability Not Set Up"
631+
)
632+
633+
# Select a screening centre
634+
set_patients_screening_centre_dropdown.select_option(
635+
general_properties["coventry_and_warwickshire_bcs_centre"]
655636
)
656637

657638
# Click "Generate Report"
@@ -691,7 +672,7 @@ def test_operational_reports_screening_practitioner_appointments(
691672

692673
@pytest.mark.only
693674
def test_operational_reports_screening_practitioner_appointments(
694-
page: Page, tests_properties: dict
675+
page: Page, general_properties: dict
695676
) -> None:
696677
"""
697678
Confirms 'screening_practitioner_appointments' page loads,
@@ -749,12 +730,35 @@ def test_operational_reports_screening_practitioner_appointments(
749730

750731
# Select a screening centre
751732
set_patients_screening_centre_dropdown.select_option(
752-
tests_properties["coventry_and_warwickshire_bcs_centre"]
733+
general_properties["coventry_and_warwickshire_bcs_centre"]
734+
)
735+
736+
# Select a screening practitioner
737+
ReportsPage(page).screening_practitioner_dropdown.select_option(
738+
general_properties["screening_practitioner_named_another_stubble"]
739+
)
740+
741+
# Click "Generate Report"
742+
ReportsPage(page).operational_reports_sp_appointments_generate_report_button.click()
743+
744+
# Verify timestamp has updated to current date and time
745+
report_timestamp = (
746+
DateTimeUtils.screening_practitioner_appointments_report_timestamp_date_format()
747+
)
748+
expect(ReportsPage(Page).common_report_timestamp_element).to_contain_text(
749+
report_timestamp
750+
)
751+
=======
752+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Screening Practitioner Appointments")
753+
754+
# Select a screening centre
755+
set_patients_screening_centre_dropdown.select_option(
756+
general_properties["coventry_and_warwickshire_bcs_centre"]
753757
)
754758

755759
# Select a screening practitioner
756760
screening_practitioner_dropdown.select_option(
757-
tests_properties["screening_practitioner_named_another_stubble"]
761+
general_properties["screening_practitioner_named_another_stubble"]
758762
)
759763

760764
# Click "Generate Report"

0 commit comments

Comments
 (0)