-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create integration test for the FHIR converter (#826)
- Loading branch information
1 parent
fdac67e
commit 1ff2cdf
Showing
7 changed files
with
162 additions
and
2 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
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,22 @@ | ||
import pytest | ||
import os | ||
from testcontainers.compose import DockerCompose | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def setup(request): | ||
print("Setting up tests...") | ||
compose_path = os.path.join(os.path.dirname(__file__), "./") | ||
compose_file_name = "docker-compose.yaml" | ||
fhir_converter = DockerCompose(compose_path, compose_file_name=compose_file_name) | ||
converter_url = "http://0.0.0.0:8080" | ||
|
||
fhir_converter.start() | ||
fhir_converter.wait_for(converter_url) | ||
print("FHIR Converter ready to test!") | ||
|
||
def teardown(): | ||
print("Tests finished! Tearing down.") | ||
fhir_converter.stop() | ||
|
||
request.addfinalizer(teardown) |
8 changes: 8 additions & 0 deletions
8
containers/fhir-converter/tests/integration/docker-compose.yaml
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,8 @@ | ||
version: '3.3' | ||
|
||
services: | ||
fhir-converter-service: | ||
build: | ||
context: ../.. | ||
ports: | ||
- "8080:8080" |
84 changes: 84 additions & 0 deletions
84
containers/fhir-converter/tests/integration/test_FHIR-Converter.py
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,84 @@ | ||
import httpx | ||
import pytest | ||
from pathlib import Path | ||
|
||
CONVERTER_URL = "http://0.0.0.0:8080" | ||
CONVERT_TO_FHIR = CONVERTER_URL + "/convert-to-fhir" | ||
|
||
|
||
@pytest.mark.integration | ||
def test_health_check(setup): | ||
health_check_response = httpx.get(CONVERTER_URL) | ||
assert health_check_response.status_code == 200 | ||
|
||
|
||
@pytest.mark.integration | ||
def test_vxu_conversion(setup): | ||
input_data = open( | ||
Path(__file__).parent.parent.parent / "assets" / "sample_request.hl7" | ||
).read() | ||
request = { | ||
"input_data": input_data, | ||
"input_type": "vxu", | ||
"root_template": "VXU_V04", | ||
} | ||
vxu_conversion_response = httpx.post(CONVERT_TO_FHIR, json=request) | ||
|
||
assert vxu_conversion_response.status_code == 200 | ||
assert ( | ||
vxu_conversion_response.json()["response"]["FhirResource"]["resourceType"] | ||
== "Bundle" | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
def test_ecr_conversion(setup): | ||
input_data = open( | ||
Path(__file__).parent.parent.parent.parent.parent | ||
/ "tests" | ||
/ "assets" | ||
/ "fhir-converter" | ||
/ "ccda" | ||
/ "ccda_sample.xml" | ||
).read() | ||
request = {"input_data": input_data, "input_type": "ecr", "root_template": "EICR"} | ||
ecr_conversion_response = httpx.post(CONVERT_TO_FHIR, json=request) | ||
|
||
assert ecr_conversion_response.status_code == 200 | ||
assert ( | ||
ecr_conversion_response.json()["response"]["FhirResource"]["resourceType"] | ||
== "Bundle" | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
def test_ecr_conversion_with_rr(setup): | ||
rr_data = open( | ||
Path(__file__).parent.parent.parent.parent.parent | ||
/ "tests" | ||
/ "assets" | ||
/ "fhir-converter" | ||
/ "rr_extraction" | ||
/ "CDA_RR.xml" | ||
).read() | ||
input_data = open( | ||
Path(__file__).parent.parent.parent.parent.parent | ||
/ "tests" | ||
/ "assets" | ||
/ "fhir-converter" | ||
/ "rr_extraction" | ||
/ "CDA_eICR.xml" | ||
).read() | ||
request = { | ||
"input_data": input_data, | ||
"input_type": "ecr", | ||
"root_template": "EICR", | ||
"rr_data": rr_data, | ||
} | ||
ecr_conversion_response = httpx.post(CONVERT_TO_FHIR, json=request) | ||
|
||
assert ecr_conversion_response.status_code == 200 | ||
assert ( | ||
ecr_conversion_response.json()["response"]["FhirResource"]["resourceType"] | ||
== "Bundle" | ||
) |
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] | ||
markers = | ||
integration : run all integration tests |