From 9115a0e7afaa928ed4f51b821af3f11dcd9aaddf Mon Sep 17 00:00:00 2001 From: viktot14-ai Date: Wed, 9 Sep 2026 23:01:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=20parse-doc=20=D1=83?= =?UTF-8?q?=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B5=20=D1=81=20=D1=84=D0=B8=D1=87=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/tests/test_parse_doc_api.py | 73 ----------------------------- 1 file changed, 73 deletions(-) delete mode 100644 backend/tests/test_parse_doc_api.py diff --git a/backend/tests/test_parse_doc_api.py b/backend/tests/test_parse_doc_api.py deleted file mode 100644 index d2d9c29..0000000 --- a/backend/tests/test_parse_doc_api.py +++ /dev/null @@ -1,73 +0,0 @@ - -from io import BytesIO -import zipfile - -from backend.main import app -from fastapi.testclient import TestClient - -client = TestClient(app) - - -def build_docx(paragraphs: list[str]) -> BytesIO: - document_xml = """ - - - {paras} - - - - - - -""" - paras = "\n".join(f"{paragraph}" for paragraph in paragraphs) - buffer = BytesIO() - with zipfile.ZipFile(buffer, 'w', compression=zipfile.ZIP_DEFLATED) as archive: - archive.writestr('[Content_Types].xml', """ - - - - - -""") - archive.writestr('_rels/.rels', """ - - - -""") - archive.writestr('word/document.xml', document_xml.format(paras=paras)) - buffer.seek(0) - buffer.name = 'sample-report.docx' - return buffer - - -def test_admin_parse_doc_extracts_case_preview_from_docx() -> None: - file_obj = build_docx([ - 'Case ID: 124', - 'Age: 16', - 'Gender: female', - 'Status: analyzed', - 'Found alive: yes', - 'Found distance km: 3.5', - 'Who found: Search team 4', - 'Notes: Found near the logging road', - ]) - - response = client.post( - '/api/v1/admin/parse-doc', - files={'file': ('sample-report.docx', file_obj, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')}, - ) - - assert response.status_code == 200 - payload = response.json() - assert payload['parsed'] is True - assert payload['filename'] == 'sample-report.docx' - assert payload['preview']['case_id'] == '124' - assert payload['preview']['case']['age'] == 16 - assert payload['preview']['case']['gender'] == 'female' - assert payload['preview']['case']['status'] == 'analyzed' - assert payload['preview']['case']['found_alive'] is True - assert payload['preview']['case']['found_distance_km'] == 3.5 - assert payload['preview']['case']['who_found'] == 'Search team 4' - assert payload['preview']['case']['notes'] == 'Found near the logging road' - assert 'Case ID: 124' in payload['raw_text']