Skip to content

Commit ca9d59b

Browse files
author
Theresa Klumpp
committed
Issue #212: Create method: analyse_pdf_to_fhir
- Add test
1 parent fe33888 commit ca9d59b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_pipeline.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,37 @@ def callback(request, _content):
393393
assert result == b"This is a test."
394394

395395

396+
def test_analyse_pdf_to_fhir(client, requests_mock):
397+
def callback(request, _content):
398+
doc_text = request.text.read().decode("utf-8")
399+
return {"payload": {"text": doc_text}}
400+
401+
requests_mock.get(
402+
f"{API_BASE}/buildInfo",
403+
headers={"Content-Type": "application/json"},
404+
json={
405+
"payload": {
406+
"specVersion": "7.4.0-SNAPSHOT",
407+
"buildNumber": "branch: main f2731e315ee137cf94c48e5f2fa431777fe49cef",
408+
"platformVersion": "8.17.0",
409+
},
410+
"errorMessages": [],
411+
},
412+
)
413+
414+
requests_mock.post(
415+
f"{API_BASE}/textanalysis/projects/{PROJECT_NAME}/pipelines/discharge/analyseText",
416+
headers={"Content-Type": MEDIA_TYPE_FHIR_JSON},
417+
json=callback,
418+
)
419+
420+
pdf1_path = Path(TEST_DIRECTORY) / "resources" / "texts" / "text1.txt"
421+
pipeline = Pipeline(Project(client, PROJECT_NAME), "discharge")
422+
423+
result = pipeline.analyse_pdf_to_fhir(pdf1_path)
424+
assert result["payload"]["text"] == "This is a test."
425+
426+
396427
def test_analyse_text_to_fhir(client_version_7_3_platform_8_17, requests_mock):
397428

398429
def callback(request, _content):

0 commit comments

Comments
 (0)