Skip to content

Commit 2ace356

Browse files
Merge branch 'main' into feature/BCSS-20615-regression-test-subject-episodes-diagnosis-date
Signed-off-by: vidhya-chandra1 <[email protected]>
2 parents 4398a44 + ce60049 commit 2ace356

File tree

48 files changed

+6968
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6968
-147
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ test-results/
1818
axe-reports/
1919
.env
2020
local.env
21+
.test_last_runs.json
2122

2223
# Please, add your custom content below!

buildBase.dockerfile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1+
# This dockerfile allows for the code from the project to be built into a Docker image,
2+
# for use in a CI/CD-style environment such as GitHub Actions or Jenkins.
3+
# Further reading on this: https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-an-image/
4+
15
FROM python:3.13-slim
26

7+
# Create non-root OS user/group and configure environment
8+
RUN addgroup --system nonroot \
9+
&& adduser --system --home /home/nonroot nonroot --ingroup nonroot
10+
311
WORKDIR /test
412

13+
ENV HOME=/home/nonroot
14+
ENV PATH="$HOME/.local/bin:$PATH"
15+
516
# Install dependencies
617
COPY ./requirements.txt ./requirements.txt
7-
RUN pip install --no-cache-dir -r requirements.txt
8-
RUN playwright install --with-deps
9-
RUN playwright install chrome
18+
RUN pip install --no-cache-dir -r requirements.txt && \
19+
playwright install --with-deps && \
20+
mkdir -p /tests/ && \
21+
mkdir -p /utils/ && \
22+
mkdir -p /pages/
1023

11-
RUN mkdir -p /tests/
24+
# Copy project files
1225
COPY ./tests/ ./tests/
13-
RUN mkdir -p /utils/
1426
COPY ./utils/ ./utils/
27+
COPY ./pages/ ./pages/
28+
COPY ./conftest.py ./conftest.py
1529
COPY ./pytest.ini ./pytest.ini
1630
COPY ./run_tests.sh ./run_tests.sh
31+
COPY ./users.json ./users.json
32+
33+
# Set permissions, make the script executable and switch OS user
34+
RUN chmod +x ./run_tests.sh \
35+
&& chown -R nonroot:nonroot /test
1736

18-
RUN chmod +x ./run_tests.sh
37+
USER nonroot

conftest.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66

77
import pytest
88
import os
9+
import typing
910
from dotenv import load_dotenv
1011
from pathlib import Path
12+
from _pytest.python import Function
13+
from pytest_html.report_data import ReportData
1114
from utils.load_properties_file import PropertiesFile
15+
from _pytest.config.argparsing import Parser
16+
from _pytest.fixtures import FixtureRequest
17+
18+
# Environment Variable Handling
1219

1320
LOCAL_ENV_PATH = Path(os.getcwd()) / "local.env"
1421

@@ -35,3 +42,67 @@ def smokescreen_properties() -> dict:
3542
@pytest.fixture
3643
def general_properties() -> dict:
3744
return PropertiesFile().get_general_properties()
45+
46+
47+
# HTML Report Customization
48+
49+
50+
def pytest_html_report_title(report: ReportData) -> None:
51+
report.title = "BCSS Test Automation Report"
52+
53+
54+
def pytest_html_results_table_header(cells: list) -> None:
55+
cells.insert(2, "<th>Description</th>")
56+
57+
58+
def pytest_html_results_table_row(report: object, cells: list) -> None:
59+
description = getattr(report, "description", "N/A")
60+
cells.insert(2, f"<td>{description}</td>")
61+
62+
63+
@pytest.hookimpl(hookwrapper=True)
64+
def pytest_runtest_makereport(item: Function) -> typing.Generator[None, None, None]:
65+
outcome = yield
66+
if outcome is not None:
67+
report = outcome.get_result()
68+
report.description = str(item.function.__doc__)
69+
70+
71+
# Command-Line Options for Pytest
72+
73+
74+
def pytest_addoption(parser: Parser) -> None:
75+
"""
76+
Add custom command-line options to pytest.
77+
78+
Args:
79+
parser (Parser): The pytest parser object used to define CLI options.
80+
81+
Adds:
82+
--subjects-to-run-for (int):
83+
The number of subjects to run the test setup for.
84+
Default is 10.
85+
86+
Example:
87+
pytest tests/test_setup.py::test_setup_subjects_as_a259 --subjects-to-run-for=5
88+
"""
89+
parser.addoption(
90+
"--subjects-to-run-for",
91+
action="store",
92+
default="10",
93+
help="Number of subjects to run the test setup for (default: 10)",
94+
)
95+
96+
97+
@pytest.fixture
98+
def subjects_to_run_for(request: FixtureRequest) -> int:
99+
"""
100+
Fixture to retrieve the value of the '--subjects-to-run-for' CLI argument.
101+
102+
Args:
103+
request (FixtureRequest): Provides access to the requesting test context.
104+
105+
Returns:
106+
int: The number of subjects specified via the CLI or default (10).
107+
"""
108+
return int(request.config.getoption("--subjects-to-run-for")) # type: ignore

docs/utility-guides/DatasetField.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@ The example below is using options that can be imported from `pages.datasets.inv
8383

8484
# populate_select_locator_for_field_inside_div
8585
DatasetFieldUtil(page).populate_select_locator_for_field_inside_div(
86-
"Classification", "divPolypNumber1Section", PolypClassificationOptions.LS
86+
"Classification", "divPolypNumber1Section", PolypClassificationOptions.IS
8787
)

0 commit comments

Comments
 (0)