test: набор pytest-тестов под site/ (unit + интеграционные + безопасность)

This commit is contained in:
“Naeel”
2026-08-26 16:47:30 +03:00
parent 9a8ae0a5a3
commit 8f8fabf959
13 changed files with 796 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
"""Интеграционные тесты db/spec_current.py."""
import json
from db import spec_current, documents, spec_events
class TestListByContract:
def test_empty(self, db):
assert spec_current.list_by_contract("nope") == []
def test_ordered_by_name(self, db):
ops = [
{"action": "ADD", "new_row": {"name": "Б", "price": 2}},
{"action": "ADD", "new_row": {"name": "А", "price": 1}},
]
spec_events.apply_ops("c1", "s1", "d1", ops, "pid", {})
rows = spec_current.list_by_contract("c1")
assert [r["name"] for r in rows] == ["А", "Б"]
class TestGetElementsJson:
def test_none(self, db):
assert spec_current.get_elements_json("missing") is None
def test_parsed(self, db):
d = documents.insert("f.docx", "m", "raw", batch_id="b1")
documents.set_parsed(d["id"], [{"type": "paragraph", "text": "x"}])
ej = spec_current.get_elements_json(d["id"])
assert ej is not None
parsed = json.loads(ej)
assert parsed[0]["text"] == "x"