Skip to content

Commit 7d5e14a

Browse files
adrianoaru-nhsAndyg79
authored andcommitted
Moving hard coded values from tests into the properties file (#20)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Moving hard coded values from tests into the properties file. This is so that if they are changed in the future, they only need to be changed in the properties file ## Context <!-- Why is this change required? What problem does it solve? --> This was done is so that if they are changed in the future, they only need to be changed in the properties file ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [ ] 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) ## Checklist <!-- 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) - [ ] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration 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 05f15c6 commit 7d5e14a

File tree

6 files changed

+51
-25
lines changed

6 files changed

+51
-25
lines changed

pages/call_and_recall/generate_invitations_page.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def verify_invitation_generation_progress_title(self) -> None:
3232
"Invitation Generation Progress"
3333
)
3434

35-
def wait_for_invitation_generation_complete(self) -> bool:
35+
def wait_for_invitation_generation_complete(
36+
self, number_of_invitations: int
37+
) -> bool:
3638
"""
3739
This function is used to wait for the invitations to be generated.
3840
Every 5 seconds it refreshes the table and checks to see if the invitations have been generated.
@@ -78,8 +80,10 @@ def wait_for_invitation_generation_complete(self) -> bool:
7880
value = (
7981
self.planned_invitations_total.text_content().strip()
8082
) # Get text and remove extra spaces
81-
if int(value) < 5:
82-
pytest.fail("There are less than 5 invitations generated")
83+
if int(value) < number_of_invitations:
84+
pytest.fail(
85+
f"There are less than {number_of_invitations} invitations generated"
86+
)
8387

8488
self_referrals_total = int(self.self_referrals_total.text_content().strip())
8589
if self_referrals_total >= 1:

tests/smokescreen/bcss_smokescreen_tests.properties

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
# compartment 2
99
# ----------------------------------
1010
c2_normal_kits_to_log=9
11-
# c2_fit_kit_logging_test_org_id=23159
11+
c2_total_fit_kits_to_retieve=10
12+
c2_fit_kit_logging_test_org_id=23159
13+
c2_fit_kit_tk_type_id=2
1214
# c2_eng_gfobt_kit_logging_test_org_id=23159
1315

1416
# ----------------------------------
@@ -17,8 +19,9 @@
1719
c3_fit_kit_results_test_org_id=23159
1820
c3_fit_kit_normal_result=75
1921
c3_fit_kit_abnormal_result=150
20-
# c3_fit_kit_authorised_user=AUTO1
21-
# c3_fit_kit_analyser_code=HMJackalt1
22+
c3_fit_kit_analyser_code=UU2_tdH3
23+
c3_total_fit_kits_to_retieve=9
24+
c3_fit_kit_authorised_user=AUTO1
2225

2326
# ----------------------------------
2427
# compartment 4

tests/smokescreen/test_compartment_1.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
def smokescreen_properties() -> dict:
1818
return PropertiesFile().get_smokescreen_properties()
1919

20+
2021
@pytest.mark.smoke
2122
@pytest.mark.compartment1
2223
@pytest.mark.compartment1_plan_creation
@@ -50,7 +51,7 @@ def test_create_invitations_plan(page: Page, smokescreen_properties: dict) -> No
5051
@pytest.mark.smoke
5152
@pytest.mark.smokescreen
5253
@pytest.mark.compartment1
53-
def test_compartment_1(page: Page) -> None:
54+
def test_compartment_1(page: Page, smokescreen_properties: dict) -> None:
5455
"""
5556
This is the main compartment 1 function. It covers the following:
5657
- Generating invitations based on the invitation plan
@@ -69,7 +70,9 @@ def test_compartment_1(page: Page) -> None:
6970
GenerateInvitations(page).click_generate_invitations_button()
7071
self_referrals_available = GenerateInvitations(
7172
page
72-
).wait_for_invitation_generation_complete()
73+
).wait_for_invitation_generation_complete(
74+
int(smokescreen_properties["c1_daily_invitation_rate"])
75+
)
7376

7477
# Print the batch of Pre-Invitation Letters - England
7578
logging.info("Compartment 1 - Process S1 Batch")

tests/smokescreen/test_compartment_2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ def test_compartment_2(page: Page, smokescreen_properties: dict) -> None:
3434

3535
BasePage(page).go_to_fit_test_kits_page()
3636
FITTestKits(page).go_to_log_devices_page()
37-
subjectdf = create_fit_id_df()
37+
38+
tk_type_id = smokescreen_properties["c2_fit_kit_tk_type_id"]
39+
hub_id = smokescreen_properties["c2_fit_kit_logging_test_org_id"]
40+
no_of_kits_to_retrieve = smokescreen_properties["c2_total_fit_kits_to_retieve"]
41+
subjectdf = create_fit_id_df(tk_type_id, hub_id, no_of_kits_to_retrieve)
3842

3943
for subject in range(int(smokescreen_properties["c2_normal_kits_to_log"])):
4044
fit_device_id = subjectdf["fit_device_id"].iloc[subject]

utils/fit_kit_generation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import logging
55

66

7-
def create_fit_id_df() -> pd.DataFrame:
7+
def create_fit_id_df(
8+
tk_type_id: int, hub_id: int, no_of_kits_to_retrieve: int
9+
) -> pd.DataFrame:
810
"""
911
The first step here is to get the relevant test data for compartment 2
1012
Then it calculates the check digit for each kit id retrieved
1113
Finally it adds the final part on the end (expiry date + random characters)
1214
"""
13-
df = get_kit_id_from_db()
15+
df = get_kit_id_from_db(tk_type_id, hub_id, no_of_kits_to_retrieve)
1416
df["fit_device_id"] = df["kitid"].apply(calculate_check_digit)
1517
df["fit_device_id"] = df["fit_device_id"].apply(convert_kit_id_to_fit_device_id)
1618
return df

utils/oracle/oracle_specific_functions.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
import logging
33
import pandas as pd
44
from datetime import datetime
5+
from enum import IntEnum
56

67

7-
def get_kit_id_from_db() -> pd.DataFrame:
8+
class SqlQueryValues(IntEnum):
9+
S10_EVENT_STATUS = 11198
10+
S19_EVENT_STATUS = 11213
11+
S43_EVENT_STATUS = 11223
12+
OPEN_EPISODE_STATUS_ID = 11352
13+
14+
15+
def get_kit_id_from_db(
16+
tk_type_id: int, hub_id: int, no_of_kits_to_retrieve: int
17+
) -> pd.DataFrame:
818
"""
919
This query is used to obtain test kits used in compartment 2
1020
It searches for kits that have not been logged and meet the following criteria:
@@ -14,19 +24,19 @@ def get_kit_id_from_db() -> pd.DataFrame:
1424
"""
1525
logging.info("Retrieving useable test kit ids")
1626
kit_id_df = OracleDB().execute_query(
17-
"""select tk.kitid, tk.screening_subject_id, sst.subject_nhs_number
27+
f"""select tk.kitid, tk.screening_subject_id, sst.subject_nhs_number
1828
from tk_items_t tk
1929
inner join ep_subject_episode_t se on se.screening_subject_id = tk.screening_subject_id
2030
inner join screening_subject_t sst on (sst.screening_subject_id = tk.screening_subject_id)
2131
inner join sd_contact_t sdc on (sdc.nhs_number = sst.subject_nhs_number)
22-
where tk.tk_type_id = 2
32+
where tk.tk_type_id = {tk_type_id}
2333
and tk.logged_in_flag = 'N'
24-
and sdc.hub_id = 23159
34+
and sdc.hub_id = {hub_id}
2535
and device_id is null
2636
and tk.invalidated_date is null
27-
and se.latest_event_status_id in (11198, 11213)
37+
and se.latest_event_status_id in ({SqlQueryValues.S10_EVENT_STATUS}, {SqlQueryValues.S19_EVENT_STATUS})
2838
order by tk.kitid DESC
29-
fetch first 10 rows only"""
39+
fetch first {no_of_kits_to_retrieve} rows only"""
3040
)
3141
return kit_id_df
3242

@@ -65,13 +75,13 @@ def get_kit_id_logged_from_db(smokescreen_properties: dict) -> pd.DataFrame:
6575
INNER JOIN ep_subject_episode_t se ON se.screening_subject_id = tk.screening_subject_id
6676
WHERE tk.logged_in_flag = 'Y'
6777
AND kq.test_kit_status IN ('LOGGED', 'POSTED')
68-
AND se.episode_status_id = 11352
78+
AND se.episode_status_id = {SqlQueryValues.OPEN_EPISODE_STATUS_ID}
6979
AND tk.tk_type_id = 2
70-
AND se.latest_event_status_id = 11223
80+
AND se.latest_event_status_id = {SqlQueryValues.S43_EVENT_STATUS}
7181
AND tk.logged_in_at = {smokescreen_properties["c3_fit_kit_results_test_org_id"]}
7282
AND tk.reading_flag = 'N'
7383
AND tk.test_results IS NULL
74-
fetch first 9 rows only
84+
fetch first {smokescreen_properties["c3_total_fit_kits_to_retieve"]} rows only
7585
"""
7686
)
7787

@@ -113,9 +123,7 @@ def get_service_management_by_device_id(device_id: str) -> pd.DataFrame:
113123
LEFT OUTER JOIN ORG lo ON lo.org_code = kq.logged_by_hub
114124
WHERE kq.test_kit_type = 'FIT' AND kq.device_id = :device_id
115125
"""
116-
params = {
117-
"device_id": device_id
118-
}
126+
params = {"device_id": device_id}
119127
get_service_management_df = OracleDB().execute_query(query, params)
120128
return get_service_management_df
121129

@@ -160,9 +168,9 @@ def update_kit_service_management_entity(
160168
kq.test_result = :test_result,
161169
kq.calculated_result = :calculated_result,
162170
kq.error_code = NULL,
163-
kq.analyser_code = 'UU2_tdH3',
171+
kq.analyser_code = :analyser_code,
164172
kq.date_time_authorised = TO_TIMESTAMP(:date_time_authorised, 'DD-Mon-YY HH24.MI.SS.FF9'),
165-
kq.authoriser_user_code = 'AUTO1',
173+
kq.authoriser_user_code = :authoriser_user_code,
166174
kq.post_response = :post_response,
167175
kq.post_attempts = :post_attempts,
168176
kq.put_response = :put_response,
@@ -179,7 +187,9 @@ def update_kit_service_management_entity(
179187
"date_time_logged": date_time_logged,
180188
"test_result": int(test_result),
181189
"calculated_result": calculated_result,
190+
"analyser_code": smokescreen_properties["c3_fit_kit_analyser_code"],
182191
"date_time_authorised": str(date_time_authorised),
192+
"authoriser_user_code": smokescreen_properties["c3_fit_kit_authorised_user"],
183193
"post_response": int(post_response) if post_response is not None else 0,
184194
"post_attempts": int(post_attempts) if post_attempts is not None else 0,
185195
"put_response": put_response,

0 commit comments

Comments
 (0)