refactor: удалён мёртвый legacy-код загрузки напрямую (/upload, /unzip-upload, _check_ext, _unzip, ALLOWED, константы фронта); загрузка только через ВМ (/api/upload_refs)
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
"""Интеграционные тесты HTTP-эндпоинтов (Flask test client)."""
|
||||
import io
|
||||
import zipfile
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -45,40 +42,6 @@ class TestSpecCurrent:
|
||||
assert data["rows"] == []
|
||||
|
||||
|
||||
class TestUpload:
|
||||
def test_no_file(self, client):
|
||||
r = client.post("/upload", data={})
|
||||
assert r.status_code == 400
|
||||
|
||||
def test_unsupported_ext(self, client):
|
||||
data = {"files": (io.BytesIO(b"x"), "test.exe")}
|
||||
r = client.post("/upload", data=data, content_type="multipart/form-data")
|
||||
assert r.status_code == 400
|
||||
|
||||
def test_docx_creates_document(self, client):
|
||||
data = {"files": (io.BytesIO(b"not a real docx"), "test.docx")}
|
||||
r = client.post("/upload", data=data, content_type="multipart/form-data")
|
||||
assert r.status_code == 200
|
||||
j = r.get_json()
|
||||
assert j["ok"] is True
|
||||
assert j["doc_id"]
|
||||
|
||||
|
||||
class TestUnzipUpload:
|
||||
def test_unzip(self, client):
|
||||
buf = io.BytesIO()
|
||||
with zipfile.ZipFile(buf, "w") as zf:
|
||||
zf.writestr("a.docx", b"hello")
|
||||
zf.writestr("b.pdf", b"world")
|
||||
buf.seek(0)
|
||||
data = {"files": (buf, "test.zip")}
|
||||
r = client.post("/unzip-upload", data=data, content_type="multipart/form-data")
|
||||
assert r.status_code == 200
|
||||
j = r.get_json()
|
||||
assert j["ok"] is True
|
||||
assert len(j["files"]) == 2
|
||||
|
||||
|
||||
class TestGroups:
|
||||
def test_missing_batch(self, client):
|
||||
r = client.get("/api/groups")
|
||||
|
||||
Reference in New Issue
Block a user