Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Tox support #39

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion nhs_number/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def generate(
for_region: Region = None,
quantity: int = 1,
) -> list:

"""
Generates valid or invalid NHS numbers, for testing.

Expand Down
13 changes: 10 additions & 3 deletions nhs_number/standardise.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
* Marcus Baw <marcusbaw@gmail.com>
"""
# standard imports
from __future__ import annotations # for Python 3.7 (remove once we stop supporting 3.7)
from __future__ import (
annotations,
) # for Python 3.7 (remove once we stop supporting 3.7)
import re
import warnings

Expand Down Expand Up @@ -51,6 +53,11 @@ def standardise_format(nhs_number: str | int) -> str:


def normalise_number(nhs_number: str) -> str:
warnings.warn("The normalise_number() function is deprecated - use "
"standardise_format() instead", DeprecationWarning)
warnings.warn(
(
"The normalise_number() function is deprecated - use "
"standardise_format() instead"
),
DeprecationWarning,
)
return standardise_format(nhs_number)
4 changes: 3 additions & 1 deletion nhs_number/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* Andy Law <andy.law@roslin.ed.ac.uk>
* Marcus Baw <marcusbaw@gmail.com>
"""
from __future__ import annotations # for Python 3.7 (remove once we stop supporting 3.7)
from __future__ import (
annotations,
) # for Python 3.7 (remove once we stop supporting 3.7)
from nhs_number.standardise import standardise_format
from nhs_number.constants import Region

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ python = "^3.7"
pytest = "^7.3.1"
black = "^23.3.0"
mkdocs-material = "^9.1.15"
tox = "^4.8.0"


[tool.poetry.urls]
"Issue Tracker" = "https://github.com/uk-fci/nhs-number/issues"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down
4 changes: 3 additions & 1 deletion tests/context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
)

import nhs_number
12 changes: 8 additions & 4 deletions tests/test_bulk_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@


@pytest.mark.skipif(
not os.path.exists("local-test-data/testdata-909090-valid-nhs-numbers.csv"),
reason="This test requires a large list of valid NHS numbers which we do"
" not want to include in the repo by default for reasons of file"
" size",
not os.path.exists(
"local-test-data/testdata-909090-valid-nhs-numbers.csv"
),
reason=(
"This test requires a large list of valid NHS numbers which we do"
" not want to include in the repo by default for reasons of file"
" size"
),
)
def test_with_large_numbers_of_known_valid_nhs_numbers():
with open(
Expand Down
6 changes: 4 additions & 2 deletions tests/test_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ def test_valid_synthetic_nhs_number_details():
assert number.calculated_checksum == 0
assert isinstance(number.region, Region)
assert "test" in number.region.tags
assert number.region_comment == ("Not to be issued "
"(Synthetic/test patients PDS)")
assert (
number.region_comment
== "Not to be issued (Synthetic/test patients PDS)"
)
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tox]
isolated_build = true
envlist = black, py{37,38,39,310,311}

[testenv]
allowlist_externals = poetry
commands =
poetry install -v
poetry run pytest --ignore=tests/test_bulk_validation.py

[testenv:black]
description = 'Check code format with Black'
commands = poetry run black --check .