Skip to content

Commit c201efb

Browse files
Removing hardcoded calues from C3 and using the properties file instead
1 parent 9bb49e5 commit c201efb

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

tests/smokescreen/bcss_smokescreen_tests.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# compartment 3
1616
# ----------------------------------
1717
# c3_fit_kit_results_test_org_id=23159
18-
# c3_fit_kit_normal_result=75
19-
# c3_fit_kit_abnormal_result=150
18+
c3_fit_kit_normal_result=75
19+
c3_fit_kit_abnormal_result=150
2020
# c3_fit_kit_authorised_user=AUTO1
2121
# c3_fit_kit_analyser_code=HMJackalt1
2222

@@ -66,8 +66,8 @@
6666
# c3_eng_number_of_abnormal_gfobt_kits_to_log=0
6767
# c3_eng_number_of_normal_gfobt_kits_to_log=0
6868
# c3_eng_number_of_weak_positive_gfobt_kits_to_log=0
69-
# c3_eng_number_of_abnormal_fit_kits=7
70-
# c3_eng_number_of_normal_fit_kits=1
69+
c3_eng_number_of_abnormal_fit_kits=9
70+
c3_eng_number_of_normal_fit_kits=1
7171

7272
# ----------------------------------
7373
# compartment 4

tests/smokescreen/test_compartment_3.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,34 @@
1010
execute_stored_procedures,
1111
)
1212
from utils.user_tools import UserTools
13+
from jproperties import Properties
14+
from sys import platform
15+
16+
17+
@pytest.fixture
18+
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
1336

1437

1538
@pytest.mark.smokescreen
1639
@pytest.mark.compartment3
17-
def test_compartment_3(page: Page) -> None:
40+
def test_compartment_3(page: Page, smokescreen_properties: dict) -> None:
1841
"""
1942
This is the main compartment 3 method
2043
First it finds any relevant test data from the DB and stores it in a pandas dataframe
@@ -27,13 +50,15 @@ def test_compartment_3(page: Page) -> None:
2750

2851
# 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)
2952
# and get device IDs and their flags
30-
device_ids = process_kit_data()
53+
device_ids = process_kit_data(smokescreen_properties)
3154
# Retrieve NHS numbers for each device_id and determine normal/abnormal status
3255
nhs_numbers = []
3356
normal_flags = []
3457

3558
for device_id, is_normal in device_ids:
36-
nhs_number = update_kit_service_management_entity(device_id, is_normal)
59+
nhs_number = update_kit_service_management_entity(
60+
device_id, is_normal, smokescreen_properties
61+
)
3762
nhs_numbers.append(nhs_number)
3863
normal_flags.append(
3964
is_normal
@@ -66,7 +91,6 @@ def test_compartment_3(page: Page) -> None:
6691
f"Verification failed for NHS number {nhs_number} with status {expected_status}: {str(e)}"
6792
)
6893
raise
69-
7094
# Process S2 batch
7195
batch_processing(
7296
page,
@@ -75,14 +99,12 @@ def test_compartment_3(page: Page) -> None:
7599
"S158 - Subject Discharge Sent (Normal)",
76100
True,
77101
)
78-
79102
# Process S158 batch
80103
batch_processing(
81104
page,
82105
"S158",
83106
"GP Result (Normal)",
84107
"S159 - GP Discharge Sent (Normal)",
85108
)
86-
87109
# Log out
88110
Logout(page).log_out()

utils/fit_kit_logged.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77

8-
def process_kit_data() -> list:
8+
def process_kit_data(smokescreen_properties) -> list:
99
"""
1010
This method retrieved the test data needed for compartment 3 and then splits it into two data frames:
1111
- 1 normal
@@ -17,7 +17,9 @@ def process_kit_data() -> list:
1717
kit_id_df = get_kit_id_logged_from_db()
1818

1919
# Split dataframe into two different dataframes, normal and abnormal
20-
normal_fit_kit_df, abnormal_fit_kit_df = split_fit_kits(kit_id_df)
20+
normal_fit_kit_df, abnormal_fit_kit_df = split_fit_kits(
21+
kit_id_df, smokescreen_properties
22+
)
2123

2224
# Prepare a list to store device IDs and their respective flags
2325
device_ids = []
@@ -47,12 +49,14 @@ def process_kit_data() -> list:
4749

4850

4951
# Seperate kits into normal and abnormal
50-
def split_fit_kits(kit_id_df) -> pd.DataFrame:
52+
def split_fit_kits(kit_id_df, smokescreen_properties: dict) -> pd.DataFrame:
5153
"""
5254
This method splits the dataframe into two, 1 normal and 1 abnormal
5355
"""
54-
number_of_normal = 1
55-
number_of_abnormal = 9
56+
number_of_normal = int(smokescreen_properties["c3_eng_number_of_normal_fit_kits"])
57+
number_of_abnormal = int(
58+
smokescreen_properties["c3_eng_number_of_abnormal_fit_kits"]
59+
)
5660
# Split dataframe into two dataframes
5761
normal_fit_kit_df = kit_id_df.iloc[:number_of_normal]
5862
abnormal_fit_kit_df = kit_id_df.iloc[

utils/oracle/oracle_specific_functions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ def get_service_management_by_device_id(deviceid) -> pd.DataFrame:
117117
return get_service_management_df
118118

119119

120-
def update_kit_service_management_entity(device_id, normal) -> str:
120+
def update_kit_service_management_entity(
121+
device_id, normal, smokescreen_properties: dict
122+
) -> str:
121123
"""
122124
This method is used to update the KIT_QUEUE table on the DB
123125
This is done so that we can then run two stored procedures to update the subjects and kits status to either normal or abnormal
@@ -141,9 +143,9 @@ def update_kit_service_management_entity(device_id, normal) -> str:
141143
+ f"{datetime.now().microsecond:06d}000"
142144
)
143145
if normal:
144-
test_result = 75
146+
test_result = int(smokescreen_properties["c3_fit_kit_normal_result"])
145147
else:
146-
test_result = 150
148+
test_result = int(smokescreen_properties["c3_fit_kit_abnormal_result"])
147149
# Parameterized query
148150
update_query = """
149151
UPDATE kit_queue kq

0 commit comments

Comments
 (0)