44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
import priemka_check as pc # noqa: E402
|
|
|
|
|
|
def setup(tmp_path, monkeypatch, verdikt="ГОТОВ К ПОДАЧЕ", sec=100, report=True, codes=None):
|
|
case = tmp_path / "delo"
|
|
case.mkdir()
|
|
local = tmp_path / "priemka.local"
|
|
local.write_text(json.dumps({"case": str(case), "limit_s": 1800}), encoding="utf-8")
|
|
if report:
|
|
copy = tmp_path / "delo-priemka-20261008-0900"
|
|
out = copy / ".agent/next"
|
|
out.mkdir(parents=True)
|
|
(out / "priemka.json").write_text(json.dumps({
|
|
"verdikt": verdikt, "sekundy": sec,
|
|
"dokumenty": [{"md": "GOTOVO/a.md", "docx": "GOTOVO/a.docx", "draft": ".agent/drafts/a.md"}]}), encoding="utf-8")
|
|
monkeypatch.setattr(pc, "pribory", lambda c, d: codes or {"document_guard": 0, "final_document": 0, "verdict_check": 0})
|
|
return local
|
|
|
|
|
|
def test_green(tmp_path, monkeypatch):
|
|
assert pc.check(setup(tmp_path, monkeypatch)) == []
|
|
|
|
|
|
def test_late(tmp_path, monkeypatch):
|
|
assert any("время" in p for p in pc.check(setup(tmp_path, monkeypatch, sec=1801)))
|
|
|
|
|
|
def test_not_ready(tmp_path, monkeypatch):
|
|
assert any("вердикт" in p for p in pc.check(setup(tmp_path, monkeypatch, verdikt="ТРЕБУЕТ ПРАВОК")))
|
|
|
|
|
|
def test_no_report(tmp_path, monkeypatch):
|
|
assert any("нет priemka.json" in p for p in pc.check(setup(tmp_path, monkeypatch, report=False)))
|
|
|
|
|
|
def test_red_instrument(tmp_path, monkeypatch):
|
|
local = setup(tmp_path, monkeypatch, codes={"document_guard": 1})
|
|
assert any("приборы" in p for p in pc.check(local))
|