Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
bab2916
[PRMP-631] Bulk Upload E2e Test
robg-test Nov 28, 2025
44eb3cc
[PRMP-631] Fix Tests
robg-test Dec 1, 2025
8f39095
[PRMP-631] Make command
robg-test Dec 1, 2025
5532645
[PRMP-631] Split Check and Upload
robg-test Dec 1, 2025
ad021a0
[PRMP-631] CI
robg-test Dec 1, 2025
680ef41
[PRMP-631] CI & Test
robg-test Dec 1, 2025
51b021f
[PRMP-631] Fix dependency and closing quotes
robg-test Dec 1, 2025
2f4e774
[PRMP-631] Update Makefile and comments for testing purposes
robg-test Dec 1, 2025
d6a4779
[PRMP-631] Var fix
robg-test Dec 1, 2025
4e6f5ce
[PRMP-631] Test validate and add missing vars
robg-test Dec 1, 2025
c5026a9
[PRMP-631] define branch
robg-test Dec 1, 2025
1ff2096
[PRMP-631] Missing quote
robg-test Dec 1, 2025
b50e14b
[PRMP-631] Fix table names
robg-test Dec 1, 2025
7c03051
[PRMP-631] Fix snapshot
robg-test Dec 1, 2025
49c631d
[PRMP-631] Make Initiate on Workflow Call
robg-test Dec 1, 2025
19d8be1
[PRMP-631] Add seperator
robg-test Dec 1, 2025
616c8df
[PRMP-631] Workflow Rename
robg-test Dec 1, 2025
966b254
[PRMP-631] Prepare for test
robg-test Dec 1, 2025
7e6d1e9
[PRMP-631] Remove weird text
robg-test Dec 1, 2025
60ad4d1
[PRMP-631] Back to previous
robg-test Dec 1, 2025
130d02c
Merge branch 'main' into PRMP-631
robg-test Dec 5, 2025
2e7e852
[PRMP-631] WIP
robg-test Dec 8, 2025
70a233f
[PRMP-631] Bulk Upload Full Tests
robg-test Dec 9, 2025
e4d2b60
Merge branch 'main' into PRMP-631
robg-test Dec 9, 2025
06e94e4
[PRMP-631] Break from this branch
robg-test Dec 11, 2025
580d3fa
[PRMP-631] Nested Directories
robg-test Dec 15, 2025
cd3d31f
[PRMP-631] Support for prefixes
robg-test Dec 17, 2025
cdc0d97
[PRMP-631] Corruption Test
robg-test Dec 18, 2025
8f8916e
[PRMP-631] Filename tests
robg-test Dec 22, 2025
a1d093f
[PRMP-613] Working test
robg-test Dec 22, 2025
9228083
[PRMP-631] Pause
robg-test Dec 24, 2025
0a051f5
[PRMP-631] Make tests repeatedly runnable
robg-test Jan 2, 2026
b0dd351
[PRMP-631] Revert workflow changes
robg-test Jan 2, 2026
aef3a2c
[PRMP-631] Merge pretesting
robg-test Jan 2, 2026
27fdbef
[PRMP-631] Do not change these files
robg-test Jan 2, 2026
fded237
[PRMP-631] use new name in PDM Tests
robg-test Jan 2, 2026
9ae81a2
[PRMP-631] Missed comma
robg-test Jan 2, 2026
673ec84
[PRMP-631] Update Snapshot
robg-test Jan 2, 2026
8567552
Merge branch 'main' into PRMP-631
robg-test Jan 2, 2026
9a7272a
[PRMP-631] Fixes for e2e tests
robg-test Jan 2, 2026
f52e9f3
[PRMP-631] Weird method usage fix
robg-test Jan 2, 2026
0b88e15
[PRMP-631] Remove extra variables
robg-test Jan 2, 2026
7bc0c9d
[PRMP-631] Formatting
robg-test Jan 5, 2026
ffec4af
[PRMP-631] PR Comments
robg-test Jan 5, 2026
44dce85
[PRMP-631] Remove Bulk Upload Helper
robg-test Jan 5, 2026
a423caf
[PRMP-631] Format Data Helper
robg-test Jan 5, 2026
02cd938
[PRMP-631] Use LloydGeorgeHelper Test fixes after changes
robg-test Jan 5, 2026
ca4a62e
Merge branch 'main' into PRMP-631
robg-test Jan 5, 2026
4840212
[PRMP-631] Reorganize methods
robg-test Jan 5, 2026
241d67e
[PRMP-631] Remove TODO
robg-test Jan 6, 2026
333bb1e
Merge branch 'main' into PRMP-631
robg-test Jan 6, 2026
43ad737
Merge branch 'main' into PRMP-631
robg-test Jan 6, 2026
dfe9d0e
[PRMP-631] Typo in 'unstitched'
robg-test Jan 8, 2026
cf84b47
Merge branch 'main' into PRMP-631
robg-test Jan 8, 2026
3c42104
Merge branch 'main' into PRMP-631
robg-test Jan 8, 2026
8efb265
Merge branch 'main' into PRMP-631
robg-test Jan 8, 2026
5517abd
Update .gitignore
robg-test Jan 8, 2026
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
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,25 @@ else
cd ./lambdas && ./venv/bin/python3 -m pytest tests/e2e/api --ignore=tests/e2e/api/fhir --snapshot-update
endif

initiate-bulk-upload:
ifeq ($(CONTAINER), true)
cd ./lambdas && PYTHONPATH=. poetry run pytest tests/e2e/bulk_upload/upload -vv
else
cd ./lambdas && ./venv/bin/python3 -m pytest tests/e2e/bulk_upload/upload -vv
endif

test-bulk-upload-e2e:
ifeq ($(CONTAINER), true)
cd ./lambdas && PYTHONPATH=. poetry run pytest tests/e2e/bulk_upload -vv
cd ./lambdas && PYTHONPATH=. poetry run pytest tests/e2e/bulk_upload/check -vv
else
cd ./lambdas && ./venv/bin/python3 -m pytest tests/e2e/bulk_upload/check -vv
endif

test-bulk-upload-e2e-snapshots:
ifeq ($(CONTAINER), true)
cd ./lambdas && PYTHONPATH=. poetry run pytest tests/e2e/bulk_upload/check --snapshot-update
else
cd ./lambdas && ./venv/bin/python3 -m pytest tests/e2e/bulk_upload -vv
cd ./lambdas && ./venv/bin/python3 -m pytest tests/e2e/bulk_upload/check --snapshot-update
endif

test-unit:
Expand Down
14 changes: 7 additions & 7 deletions lambdas/tests/e2e/api/fhir/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest
import requests

from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
from tests.e2e.helpers.patient_record_data_helper import PdmDataHelper

pdm_data_helper = PdmDataHelper()

Expand All @@ -28,7 +28,7 @@ def test_data():


def fetch_with_retry_mtls(
session, url, headers, condition_func=None, max_retries=5, delay=10
session, url, headers, condition_func=None, max_retries=5, delay=10
):
retries = 0
while retries < max_retries:
Expand All @@ -48,7 +48,7 @@ def fetch_with_retry_mtls(


def create_mtls_session(
client_cert_path=CLIENT_CERT_PATH, client_key_path=CLIENT_KEY_PATH
client_cert_path=CLIENT_CERT_PATH, client_key_path=CLIENT_KEY_PATH
):
session = requests.Session()
session.cert = (client_cert_path, client_key_path)
Expand Down Expand Up @@ -105,10 +105,10 @@ def get_pdm_document_reference(record_id, client_cert_path=None, client_key_path


def create_and_store_pdm_record(
test_data,
nhs_number: str = "9912003071",
doc_status: str | None = None,
size: int | None = None,
test_data,
nhs_number: str = "9912003071",
doc_status: str | None = None,
size: int | None = None,
):
"""Helper to create metadata and resource for a record."""
record = pdm_data_helper.build_record(
Expand Down
2 changes: 1 addition & 1 deletion lambdas/tests/e2e/api/fhir/test_mtls_routing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import uuid

from lambdas.tests.e2e.api.fhir.conftest import get_pdm_document_reference
from tests.e2e.api.fhir.conftest import get_pdm_document_reference

UNAUTHORISED_CLIENT_CERT_PATH = os.environ.get("UNAUTHORISED_CLIENT_CERT_PATH")
UNAUTHORISED_CLIENT_KEY_PATH = os.environ.get("UNAUTHORISED_CLIENT_KEY_PATH")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import uuid

import pytest
from tests.e2e.helpers.data_helper import PdmDataHelper

from lambdas.tests.e2e.api.fhir.conftest import (
from tests.e2e.api.fhir.conftest import (
PDM_S3_BUCKET,
create_and_store_pdm_record,
get_pdm_document_reference,
)
from tests.e2e.helpers.patient_record_data_helper import PdmDataHelper

pdm_data_helper = PdmDataHelper()

Expand Down Expand Up @@ -44,7 +44,7 @@ def test_file_retrieval(test_data, file_size):
],
)
def test_retrieve_edge_cases(
record_id, expected_status, expected_code, expected_diagnostics
record_id, expected_status, expected_code, expected_diagnostics
):
response = get_pdm_document_reference(record_id)
assert response.status_code == expected_status
Expand Down
12 changes: 6 additions & 6 deletions lambdas/tests/e2e/api/fhir/test_search_patient_fhir_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest

from lambdas.tests.e2e.api.fhir.conftest import (
from tests.e2e.api.fhir.conftest import (
MTLS_ENDPOINT,
PDM_SNOMED,
create_and_store_pdm_record,
create_mtls_session,
)
from lambdas.tests.e2e.conftest import APIM_ENDPOINT
from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
from tests.e2e.conftest import APIM_ENDPOINT
from tests.e2e.helpers.patient_record_data_helper import PdmDataHelper

pdm_data_helper = PdmDataHelper()

Expand Down Expand Up @@ -67,8 +67,8 @@ def test_search_patient_details(test_data):

attachment_url = matching_entry["resource"]["content"][0]["attachment"]["url"]
assert (
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{PDM_SNOMED}~{expected_record_id}"
in attachment_url
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{PDM_SNOMED}~{expected_record_id}"
in attachment_url
)


Expand Down Expand Up @@ -107,7 +107,7 @@ def test_multiple_cancelled_search_patient_details(test_data):
],
)
def test_search_edge_cases(
nhs_number, expected_status, expected_code, expected_diagnostics
nhs_number, expected_status, expected_code, expected_diagnostics
):
response = search_document_reference(nhs_number)
assert response.status_code == expected_status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import pytest
import requests

from lambdas.tests.e2e.api.fhir.conftest import (
from tests.e2e.api.fhir.conftest import (
MTLS_ENDPOINT,
create_mtls_session,
fetch_with_retry_mtls,
)
from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
from tests.e2e.helpers.patient_record_data_helper import PdmDataHelper

pdm_data_helper = PdmDataHelper()

Expand Down Expand Up @@ -91,21 +91,21 @@ def condition(response_json):
"nhs_number,expected_status,expected_code,expected_diagnostics",
[
(
"9999999993",
400,
"VALIDATION_ERROR",
"Failed to parse document upload request data",
"9999999993",
400,
"VALIDATION_ERROR",
"Failed to parse document upload request data",
),
(
"123",
400,
"VALIDATION_ERROR",
"Failed to parse document upload request data",
"123",
400,
"VALIDATION_ERROR",
"Failed to parse document upload request data",
),
],
)
def test_search_edge_cases(
nhs_number, expected_status, expected_code, expected_diagnostics
nhs_number, expected_status, expected_code, expected_diagnostics
):
record = {
"ods": "H81109",
Expand Down Expand Up @@ -173,5 +173,5 @@ def test_create_document_with_invalid_author_returns_error(test_data, author_pay
assert raw_upload_response.status_code == 400
assert response_json["resourceType"] == "OperationOutcome"
assert (
response_json["issue"][0]["details"]["coding"][0]["code"] == "VALIDATION_ERROR"
response_json["issue"][0]["details"]["coding"][0]["code"] == "VALIDATION_ERROR"
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import logging
import os

from lambdas.tests.e2e.api.fhir.conftest import (
from tests.e2e.api.fhir.conftest import (
MTLS_ENDPOINT,
PDM_SNOMED,
create_mtls_session,
fetch_with_retry_mtls,
)
from lambdas.tests.e2e.conftest import APIM_ENDPOINT
from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
from tests.e2e.conftest import APIM_ENDPOINT
from tests.e2e.helpers.patient_record_data_helper import PdmDataHelper

pdm_data_helper = PdmDataHelper()

Expand Down Expand Up @@ -54,8 +54,8 @@ def test_create_document_base64(test_data):
upload_response = raw_upload_response.json()
attachment_url = upload_response["content"][0]["attachment"]["url"]
assert (
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{PDM_SNOMED}~"
in attachment_url
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{PDM_SNOMED}~"
in attachment_url
)

def condition(response_json):
Expand Down
3 changes: 2 additions & 1 deletion lambdas/tests/e2e/api/test_login_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from tests.e2e.helpers.data_helper import LloydGeorgeDataHelper

from tests.e2e.helpers.lloyd_george_mockcis2_helper import LloydGeorgeMockcis2Helper
from tests.e2e.helpers.patient_record_data_helper import LloydGeorgeDataHelper

# Note this is testing a mock, but this test is valuable to ensure the login code is working for other tests

Expand Down
3 changes: 2 additions & 1 deletion lambdas/tests/e2e/api/test_retrieve_document_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

import requests
from syrupy.filters import paths

from tests.e2e.conftest import (
API_ENDPOINT,
API_KEY,
LLOYD_GEORGE_S3_BUCKET,
LLOYD_GEORGE_SNOMED,
)
from tests.e2e.helpers.data_helper import LloydGeorgeDataHelper
from tests.e2e.helpers.patient_record_data_helper import LloydGeorgeDataHelper

data_helper = LloydGeorgeDataHelper()

Expand Down
7 changes: 4 additions & 3 deletions lambdas/tests/e2e/api/test_search_patient_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import requests
from syrupy.filters import paths

from tests.e2e.conftest import API_ENDPOINT, API_KEY, APIM_ENDPOINT, LLOYD_GEORGE_SNOMED
from tests.e2e.helpers.data_helper import LloydGeorgeDataHelper
from tests.e2e.helpers.patient_record_data_helper import LloydGeorgeDataHelper

data_helper = LloydGeorgeDataHelper()

Expand Down Expand Up @@ -33,8 +34,8 @@ def test_search_patient_details(test_data, snapshot_json):

attachment_url = bundle["entry"][0]["resource"]["content"][0]["attachment"]["url"]
assert (
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{LLOYD_GEORGE_SNOMED}~"
in attachment_url
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{LLOYD_GEORGE_SNOMED}~"
in attachment_url
)

assert bundle == snapshot_json(
Expand Down
7 changes: 4 additions & 3 deletions lambdas/tests/e2e/api/test_upload_document_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import requests
from syrupy.filters import paths

from tests.e2e.conftest import (
API_ENDPOINT,
API_KEY,
Expand All @@ -13,7 +14,7 @@
LLOYD_GEORGE_SNOMED,
fetch_with_retry,
)
from tests.e2e.helpers.data_helper import LloydGeorgeDataHelper
from tests.e2e.helpers.patient_record_data_helper import LloydGeorgeDataHelper

data_helper = LloydGeorgeDataHelper()

Expand Down Expand Up @@ -97,8 +98,8 @@ def condition(response_json):

attachment_url = upload_response["content"][0]["attachment"]["url"]
assert (
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{LLOYD_GEORGE_SNOMED}~"
in attachment_url
f"https://{APIM_ENDPOINT}/national-document-repository/FHIR/R4/DocumentReference/{LLOYD_GEORGE_SNOMED}~"
in attachment_url
)

base64_data = retrieve_response["content"][0]["attachment"]["data"]
Expand Down
19 changes: 7 additions & 12 deletions lambdas/tests/e2e/apim/test_apim_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import pytest
import requests
from tests.e2e.helpers.data_helper import PdmDataHelper

from tests.e2e.conftest import PDM_SNOMED
from tests.e2e.helpers.patient_record_data_helper import PdmDataHelper

pdm_data_helper = PdmDataHelper()
PDM_SNOMED = pdm_data_helper.snomed_code
Expand All @@ -16,9 +18,7 @@ def test_ping(nhsd_apim_proxy_url):


@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
def test_app_level3_access_search(
test_data, nhsd_apim_proxy_url, nhsd_apim_auth_headers
):
def test_app_level3_access_search(test_data, nhsd_apim_proxy_url, nhsd_apim_auth_headers):
# Put PDM record
pdm_record = pdm_data_helper.build_record()
test_data.append(pdm_record)
Expand All @@ -28,8 +28,7 @@ def test_app_level3_access_search(

# Search record via APIM
resp = requests.get(
nhsd_apim_proxy_url
+ "/DocumentReference?subject:identifier=https://fhir.nhs.uk/Id/nhs-number%7C9912003071",
nhsd_apim_proxy_url + "/DocumentReference?subject:identifier=https://fhir.nhs.uk/Id/nhs-number%7C9912003071",
headers=nhsd_apim_auth_headers,
)
assert resp.status_code == 200
Expand All @@ -49,9 +48,7 @@ def test_app_level3_access_search(


@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
def test_app_level3_access_retrieve(
test_data, nhsd_apim_proxy_url, nhsd_apim_auth_headers
):
def test_app_level3_access_retrieve(test_data, nhsd_apim_proxy_url, nhsd_apim_auth_headers):
# Put PDM record
pdm_record = pdm_data_helper.build_record()
test_data.append(pdm_record)
Expand All @@ -77,9 +74,7 @@ def test_app_level3_access_retrieve(


@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
def test_app_level3_access_upload(
test_data, nhsd_apim_proxy_url, nhsd_apim_auth_headers
):
def test_app_level3_access_upload(test_data, nhsd_apim_proxy_url, nhsd_apim_auth_headers):
# Build PDM record
sample_pdf_path = os.path.join(os.path.dirname(__file__), "files", "dummy.pdf")
with open(sample_pdf_path, "rb") as f:
Expand Down
Loading
Loading