Skip to content

Commit 75c026d

Browse files
committed
Merge branch 'main' into feature/BCSS-20441-tableutil-markdown-doc-and-doc-strings
2 parents 6ce082b + 52f204b commit 75c026d

17 files changed

+187
-86
lines changed

conftest.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import os
99
from dotenv import load_dotenv
1010
from pathlib import Path
11+
from utils.load_properties_file import PropertiesFile
1112

12-
LOCAL_ENV_PATH = Path(os.getcwd()) / 'local.env'
13+
LOCAL_ENV_PATH = Path(os.getcwd()) / "local.env"
1314

1415

1516
@pytest.fixture(autouse=True, scope="session")
@@ -24,3 +25,13 @@ def import_local_env_file() -> None:
2425
"""
2526
if Path.is_file(LOCAL_ENV_PATH):
2627
load_dotenv(LOCAL_ENV_PATH, override=False)
28+
29+
30+
@pytest.fixture
31+
def smokescreen_properties() -> dict:
32+
return PropertiesFile().get_smokescreen_properties()
33+
34+
35+
@pytest.fixture
36+
def general_properties() -> dict:
37+
return PropertiesFile().get_general_properties()

docs/utility-guides/Oracle.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Utility Guide: Oracle
2+
3+
The Oracle Utility can be used to run SQL queries or stored procedures on the Oracle database.
4+
5+
## Table of Contents
6+
7+
- [Utility Guide: Oracle](#utility-guide-oracle)
8+
- [Table of Contents](#table-of-contents)
9+
- [Using the Oracle Utility](#using-the-oracle-utility)
10+
- [Required arguments](#required-arguments)
11+
- [Example usage](#example-usage)
12+
- [Oracle Specific Functions](#oracle-specific-functions)
13+
- [Example Usage](#example-usage-1)
14+
15+
## Using the Oracle Utility
16+
17+
To use the Oracle Utility, import the 'OracleDB' class into your test file and then call the OracleDB methods from within your tests, as required.
18+
19+
## Required arguments
20+
21+
The functions in this class require different arguments.<br>
22+
Look at the docstrings for each function to see what arguments are required.<br>
23+
The docstrings also specify when arguments are optional, and what the default values are when no argument is provided.
24+
25+
## Example usage
26+
27+
from utils.oracle.oracle import OracleDB
28+
29+
def test_oracle_query() -> None:
30+
31+
query = """select column_a,
32+
column_b,
33+
column_c
34+
from example_table
35+
where condition_1 = :condition1
36+
and condition_2 = :condition2"""
37+
38+
params = {
39+
"condition1": 101,
40+
"condition2": 202,
41+
}
42+
43+
result_df = OracleDB().execute_query(query, params)
44+
45+
def run_stored_procedure() -> None:
46+
47+
OracleDB().execute_stored_procedure("bcss_timed_events")
48+
49+
## Oracle Specific Functions
50+
51+
This contains SQL queries that can be used to run tests.<br>
52+
These are all stored in one location to make it easier to edit the query at a later date and to make it accessible to multiple tests.
53+
54+
Common values are placed in the `SqlQueryValues` class to avoid repeating the same values in the queries.
55+
56+
## Example Usage
57+
58+
from oracle.oracle import OracleDB
59+
60+
def example_query() -> pd.DataFrame:
61+
62+
example_df = OracleDB().execute_query(
63+
f"""subject_nhs_number
64+
from ep_subject_episode_t
65+
where se.latest_event_status_id in ({SqlQueryValues.S10_EVENT_STATUS}, {SqlQueryValues.S19_EVENT_STATUS})""")
66+
67+
return example_df

setup_env_file.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@
1111
import os
1212
from pathlib import Path
1313

14-
REQUIRED_KEYS = ["USER_PASS"]
15-
DEFAULT_LOCAL_ENV_PATH = Path(os.getcwd()) / 'local.env'
14+
REQUIRED_KEYS = ["BCSS_PASS", "ORACLE_USERNAME", "ORACLE_DB", "ORACLE_PASS"]
15+
DEFAULT_LOCAL_ENV_PATH = Path(os.getcwd()) / "local.env"
16+
1617

1718
def create_env_file():
1819
"""
1920
Create a local.env file with the required keys.
2021
"""
21-
with open(DEFAULT_LOCAL_ENV_PATH, 'w') as f:
22-
f.write("# Use this file to populate secrets without committing them to the codebase (as this file is set in .gitignore).\n")
23-
f.write("# To retrieve values as part of your tests, use os.getenv('VARIABLE_NAME').\n")
24-
f.write("# Note: When running in a pipeline or workflow, you should pass these variables in at runtime.\n\n")
22+
with open(DEFAULT_LOCAL_ENV_PATH, "w") as f:
23+
f.write(
24+
"# Use this file to populate secrets without committing them to the codebase (as this file is set in .gitignore).\n"
25+
)
26+
f.write(
27+
"# To retrieve values as part of your tests, use os.getenv('VARIABLE_NAME').\n"
28+
)
29+
f.write(
30+
"# Note: When running in a pipeline or workflow, you should pass these variables in at runtime.\n\n"
31+
)
2532
for key in REQUIRED_KEYS:
26-
f.write(f'{key}=\n')
33+
f.write(f"{key}=\n")
2734

2835

2936
if __name__ == "__main__":

tests/smokescreen/bcss_smokescreen_tests.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
c3_fit_kit_normal_result=75
2121
c3_fit_kit_abnormal_result=150
2222
c3_fit_kit_analyser_code=UU2_tdH3
23-
c3_total_fit_kits_to_retieve=9
23+
c3_total_fit_kits_to_retrieve=9
2424
c3_fit_kit_authorised_user=AUTO1
2525

2626
# ----------------------------------

tests/smokescreen/test_compartment_1.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
from pages.call_and_recall.generate_invitations_page import GenerateInvitationsPage
1111
from playwright.sync_api import Page
1212
from utils.batch_processing import batch_processing
13-
from utils.load_properties_file import PropertiesFile
14-
15-
16-
@pytest.fixture
17-
def smokescreen_properties() -> dict:
18-
return PropertiesFile().get_smokescreen_properties()
1913

2014

2115
@pytest.mark.smoke

tests/smokescreen/test_compartment_2.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
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 utils.load_properties_file import PropertiesFile
14-
15-
16-
@pytest.fixture
17-
def smokescreen_properties() -> dict:
18-
return PropertiesFile().get_smokescreen_properties()
1913

2014

2115
@pytest.mark.vpn_required

tests/smokescreen/test_compartment_3.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
execute_fit_kit_stored_procedures,
1111
)
1212
from utils.user_tools import UserTools
13-
from utils.load_properties_file import PropertiesFile
14-
15-
16-
@pytest.fixture
17-
def smokescreen_properties() -> dict:
18-
return PropertiesFile().get_smokescreen_properties()
1913

2014

2115
@pytest.mark.vpn_required

tests/smokescreen/test_compartment_4.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
EpisodeEventsAndNotesPage,
2525
)
2626
from utils.user_tools import UserTools
27-
from utils.load_properties_file import PropertiesFile
2827
from utils.calendar_picker import CalendarPicker
2928
from utils.batch_processing import batch_processing
3029
from datetime import datetime
@@ -33,11 +32,6 @@
3332
import logging
3433

3534

36-
@pytest.fixture
37-
def smokescreen_properties() -> dict:
38-
return PropertiesFile().get_smokescreen_properties()
39-
40-
4135
@pytest.mark.vpn_required
4236
@pytest.mark.smokescreen
4337
@pytest.mark.compartment4

tests/smokescreen/test_compartment_5.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,13 @@
4949
)
5050

5151
from utils.user_tools import UserTools
52-
from utils.load_properties_file import PropertiesFile
5352
from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no
5453
from utils.calendar_picker import CalendarPicker
5554
from utils.oracle.oracle_specific_functions import get_subjects_with_booked_appointments
5655
from datetime import datetime, timedelta
5756
import logging
5857

5958

60-
@pytest.fixture
61-
def smokescreen_properties() -> dict:
62-
return PropertiesFile().get_smokescreen_properties()
63-
64-
6559
@pytest.mark.vpn_required
6660
@pytest.mark.smokescreen
6761
@pytest.mark.compartment5

tests/test_call_and_recall_page.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
from pages.call_and_recall.invitations_plans_page import InvitationsPlansPage
1212
from pages.call_and_recall.create_a_plan_page import CreateAPlanPage
1313
from utils.user_tools import UserTools
14-
from utils.load_properties_file import PropertiesFile
15-
16-
17-
@pytest.fixture
18-
def general_properties() -> dict:
19-
return PropertiesFile().get_general_properties()
2014

2115

2216
@pytest.fixture(scope="function", autouse=True)

0 commit comments

Comments
 (0)