Skip to content

Commit 999d521

Browse files
committed
tests: Add case for /process_bulk_file
Signed-off-by: Phoevos Kalemkeris <[email protected]>
1 parent 5f3b63a commit 999d521

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"Patient diagnosed with kidney failure",
3+
"Patient diagnosed with kidney failure again, what a week"
4+
]

tests/integration/test_api.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
import pytest
24
from fastapi.testclient import TestClient
35

@@ -22,6 +24,9 @@
2224
wait_for_task_completion,
2325
)
2426

27+
TEST_ASSETS_DIR = Path("tests/integration/assets")
28+
MULTI_TEXT_FILE_PATH = TEST_ASSETS_DIR / "multi_text_file.json"
29+
2530

2631
@pytest.fixture(scope="module", autouse=True)
2732
def setup(request: pytest.FixtureRequest, cleanup_cms: bool):
@@ -242,3 +247,39 @@ def test_process_bulk(client: TestClient, config: Config, test_model_service_ip:
242247
assert annotation["label_name"] == "Loss Of Kidney Function"
243248

244249
verify_results_match_api_info(client, task, res)
250+
251+
252+
def test_process_bulk_file(client: TestClient, config: Config, test_model_service_ip: str):
253+
with open(MULTI_TEXT_FILE_PATH, "rb") as f:
254+
response = client.post(
255+
f"/models/{test_model_service_ip}/process_bulk_file",
256+
files=[("multi_text_file", f)],
257+
)
258+
response_json = validate_api_response(response, expected_status_code=200, return_json=True)
259+
260+
tm: TaskManager = config.task_manager
261+
verify_task_submitted_successfully(response_json["uuid"], tm)
262+
263+
task = wait_for_task_completion(response_json["uuid"], tm, expected_status=Status.SUCCEEDED)
264+
265+
key = f"{task.uuid}_{MULTI_TEXT_FILE_PATH.name}"
266+
with open(MULTI_TEXT_FILE_PATH, "rb") as f:
267+
expected_payload = f.read()
268+
verify_task_payload_in_object_store(key, expected_payload, config.task_object_store_manager)
269+
270+
verify_queue_is_empty(config.queue_manager)
271+
272+
res, parsed = download_result_object(task.result, config.results_object_store_manager)
273+
274+
assert len(parsed) == 2
275+
276+
for doc in parsed:
277+
assert "text" in doc
278+
assert "annotations" in doc
279+
assert len(doc["annotations"]) == 1
280+
281+
annotation = doc["annotations"][0]
282+
verify_annotation_contains_keys(annotation, ANNOTATION_FIELDS_JSON)
283+
assert annotation["label_name"] == "Loss Of Kidney Function"
284+
285+
verify_results_match_api_info(client, task, res)

0 commit comments

Comments
 (0)