generated from nhs-england-tools/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This transfers the prototype code that is generic into this project ready to be built upon.
- Loading branch information
1 parent
458a188
commit fe90a9e
Showing
11 changed files
with
100 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pycache__/ | ||
.pytest_cache/ | ||
test-results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3.12-slim | ||
|
||
WORKDIR /test | ||
|
||
# Install dependencies | ||
COPY ./requirements.txt ./requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
RUN playwright install --with-deps | ||
RUN playwright install chrome | ||
|
||
RUN mkdir -p /tests/ | ||
COPY ./tests/ ./tests/ | ||
RUN mkdir -p /utils/ | ||
COPY ./utils/ ./utils/ | ||
COPY ./pytest.ini ./pytest.ini | ||
COPY ./run_tests.sh ./run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[pytest] | ||
log_cli = True | ||
log_cli_level = INFO | ||
addopts = | ||
--html=test-results/report.html | ||
--self-contained-html | ||
--json-report | ||
--json-report-file=test-results/results.json | ||
--json-report-omit=collectors | ||
markers = | ||
subjects: tests for subject-based scenarios | ||
branch: tests designed to run at a branch level | ||
main: tests designed to run against the main branch | ||
release: tests designed to run specifically against a release branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest-playwright>=0.5.1 | ||
pytest-html>=4.1.1 | ||
pytest-json-report>=1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
BASE_URL=${1:-${BASE_URL}} | ||
|
||
pytest --tracing retain-on-failure --base-url $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Add tests here | ||
|
||
Your projects test files should be added to this directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file provides a very basic test to confirm the configuration is working | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
|
||
def test_basic_example(page: Page): | ||
# Navigate to page | ||
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint") | ||
|
||
# Assert repo text is present | ||
expect(page.get_by_role("article")).to_contain_text("Playwright Python Blueprint") | ||
|
||
# Click license link | ||
page.get_by_role("link", name="MIT license").click() | ||
|
||
# Assert license text | ||
expect(page.get_by_role("article")).to_contain_text("MIT Licence") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from nhs_number_tools import NHSNumberTools | ||
__all__ = [NHSNumberTools] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
class NHSNumberTools: | ||
""" | ||
A utility class providing functionality around NHS numbers. | ||
""" | ||
def _nhs_number_checks(self, nhs_number: str) -> None: | ||
""" | ||
This does basic checks on NHS number values provided and outputs information or exceptions if applicable. | ||
Args: | ||
nhs_number (str): The NHS number to check. | ||
""" | ||
if not nhs_number.isnumeric(): | ||
raise Exception("The NHS number provided ({}) is not numeric.".format(nhs_number)) | ||
|
||
|
||
def spaced_nhs_number(self, nhs_number: int | str) -> str: | ||
""" | ||
This will space out a provided NHS number in the format nnn nnn nnnn. | ||
Args: | ||
nhs_number (int | str): The NHS number to space out. | ||
Returns: | ||
str: The NHS number in "nnn nnn nnnn" format. | ||
""" | ||
self._nhs_number_checks(str(nhs_number)) | ||
return "{} {} {}".format(str(nhs_number)[:3], str(nhs_number)[3:6], str(nhs_number)[6:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributing to this project | ||
|
||
This page will be populated in the near future to outline the contribution process. |