test: набор pytest-тестов под site/ (unit + интеграционные + безопасность)
This commit is contained in:
@@ -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"
|
||||
Reference in New Issue
Block a user