Skip to content

Commit 5190bf2

Browse files
authored
Merge branch 'master' into VED-713-mavis-permissions-update
2 parents bf71abf + 50292e2 commit 5190bf2

Some content is hidden

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

41 files changed

+1517
-1483
lines changed

ack_backend/poetry.lock

Lines changed: 136 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ack_backend/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ packages = [
1010

1111
[tool.poetry.dependencies]
1212
python = "~3.11"
13-
boto3 = "~1.40.20"
13+
boto3 = "~1.40.22"
1414
mypy-boto3-dynamodb = "^1.40.20"
1515
freezegun = "^1.5.2"
1616
moto = "^4"
17-
coverage = "^7.10.5"
17+
coverage = "^7.10.6"
1818

1919

2020
[build-system]

backend/poetry.lock

Lines changed: 102 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ packages = [{include = "src"}]
99
[tool.poetry.dependencies]
1010
python = "~3.11"
1111
"fhir.resources" = "~7.0.2"
12-
boto3 = "~1.40.20"
13-
boto3-stubs-lite = {extras = ["dynamodb"], version = "~1.40.20"}
12+
boto3 = "~1.40.22"
13+
boto3-stubs-lite = {extras = ["dynamodb"], version = "~1.40.22"}
1414
aws-lambda-typing = "~2.20.0"
1515
redis = "^4.6.0"
1616
moto = "^5.1.11"
@@ -25,7 +25,7 @@ simplejson = "^3.19.2"
2525
structlog = "^24.1.0"
2626
python-stdnum = "^2.1"
2727
freezegun = "^1.5.1"
28-
coverage = "^7.10.5"
28+
coverage = "^7.10.6"
2929

3030
[build-system]
3131
requires = ["poetry-core ~= 1.5.0"]

backend/src/fhir_service.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@
2929
logging.basicConfig(level="INFO")
3030
logger = logging.getLogger()
3131

32-
def get_service_url(
33-
service_env: str = os.getenv("IMMUNIZATION_ENV"),
34-
service_base_path: str = os.getenv("IMMUNIZATION_BASE_PATH"),
35-
):
32+
def get_service_url(service_env: str = os.getenv("IMMUNIZATION_ENV"), service_base_path: str = os.getenv("IMMUNIZATION_BASE_PATH")
33+
) -> str:
34+
35+
if not service_base_path:
36+
service_base_path = "immunisation-fhir-api/FHIR/R4"
37+
3638
non_prod = ["internal-dev", "int", "sandbox"]
3739
if service_env in non_prod:
3840
subdomain = f"{service_env}."
3941
elif service_env == "prod":
4042
subdomain = ""
4143
else:
4244
subdomain = "internal-dev."
45+
4346
return f"https://{subdomain}api.service.nhs.uk/{service_base_path}"
4447

4548

@@ -366,7 +369,7 @@ def search_immunizations(
366369
BundleEntry(
367370
resource=Immunization.parse_obj(imms),
368371
search=BundleEntrySearch(mode="match"),
369-
fullUrl=f"https://api.service.nhs.uk/immunisation-fhir-api/Immunization/{imms['id']}",
372+
fullUrl=f"{get_service_url()}/Immunization/{imms['id']}",
370373
)
371374
for imms in resources_filtered_for_search
372375
]

backend/tests/test_fhir_service.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import uuid
33
import datetime
44
import unittest
5-
from unittest.mock import MagicMock
5+
import os
6+
from unittest.mock import MagicMock, patch
67
from copy import deepcopy
78
from unittest.mock import create_autospec, patch
89
from decimal import Decimal
@@ -54,22 +55,22 @@ def tearDown(self):
5455
def test_get_service_url(self):
5556
"""it should create service url"""
5657
env = "int"
57-
base_path = "my-base-path"
58+
base_path = "immunisation-fhir-api/FHIR/R4"
5859
url = get_service_url(env, base_path)
5960
self.assertEqual(url, f"https://{env}.api.service.nhs.uk/{base_path}")
6061
# default should be internal-dev
6162
env = "it-does-not-exist"
62-
base_path = "my-base-path"
63+
base_path = "immunisation-fhir-api/FHIR/R4"
6364
url = get_service_url(env, base_path)
6465
self.assertEqual(url, f"https://internal-dev.api.service.nhs.uk/{base_path}")
6566
# prod should not have a subdomain
6667
env = "prod"
67-
base_path = "my-base-path"
68+
base_path = "immunisation-fhir-api/FHIR/R4"
6869
url = get_service_url(env, base_path)
6970
self.assertEqual(url, f"https://api.service.nhs.uk/{base_path}")
7071
# any other env should fall back to internal-dev (like pr-xx or per-user)
7172
env = "pr-42"
72-
base_path = "my-base-path"
73+
base_path = "immunisation-fhir-api/FHIR/R4"
7374
url = get_service_url(env, base_path)
7475
self.assertEqual(url, f"https://internal-dev.api.service.nhs.uk/{base_path}")
7576

@@ -772,6 +773,8 @@ class TestSearchImmunizations(unittest.TestCase):
772773
MOCK_SUPPLIER_SYSTEM_NAME = "Test"
773774

774775
def setUp(self):
776+
os.environ["IMMUNIZATION_ENV"] = "internal-dev"
777+
os.environ["IMMUNIZATION_BASE_PATH"] = "immunisation-fhir-api/FHIR/R4"
775778
self.authoriser = create_autospec(Authoriser)
776779
self.imms_repo = create_autospec(ImmunizationRepository)
777780
self.validator = create_autospec(ImmunizationValidator)
@@ -1083,7 +1086,6 @@ def test_matches_contain_fullUrl(self):
10831086
"""All matches must have a fullUrl consisting of their id.
10841087
See http://hl7.org/fhir/R4B/bundle-definitions.html#Bundle.entry.fullUrl.
10851088
Tested because fhir.resources validation doesn't check this as mandatory."""
1086-
10871089
imms_ids = ["imms-1", "imms-2"]
10881090
imms_list = [create_covid_19_immunization_dict(imms_id) for imms_id in imms_ids]
10891091
self.imms_repo.find_immunizations.return_value = imms_list
@@ -1100,14 +1102,13 @@ def test_matches_contain_fullUrl(self):
11001102
for i, entry in enumerate(entries):
11011103
self.assertEqual(
11021104
entry.fullUrl,
1103-
f"https://api.service.nhs.uk/immunisation-fhir-api/Immunization/{imms_ids[i]}",
1105+
f"https://internal-dev.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4/Immunization/{imms_ids[i]}",
11041106
)
11051107

11061108
def test_patient_contains_fullUrl(self):
11071109
"""Patient must have a fullUrl consisting of its id.
11081110
See http://hl7.org/fhir/R4B/bundle-definitions.html#Bundle.entry.fullUrl.
11091111
Tested because fhir.resources validation doesn't check this as mandatory."""
1110-
11111112
imms_ids = ["imms-1", "imms-2"]
11121113
imms_list = [create_covid_19_immunization_dict(imms_id) for imms_id in imms_ids]
11131114
self.imms_repo.find_immunizations.return_value = imms_list

0 commit comments

Comments
 (0)