Files
smeta-web/tests/test_arp_server.py
anorandClaude Opus 4.8 99e46407a1 test: script-probe тесты собираются pytest'ом — skip без данных вместо 7 collection-errors
Тела 7 серверных probe-скриптов обёрнуты в тест-функции с гейтом:
skip при отсутствии корпуса (/home/mcp-user/…), для mask_integration —
при отсутствии живой БД (файл+схема, гейт ДО import main); модуль-левел
sys.exit заменён на assert fails==0. Гейт formats стоит до импорта
claude_bridge_glm (цепочка тянет pymorphy2). __main__-гвард сохраняет
запуск скриптом на dev2; на сервере с корпусом проверки едут как раньше
(доказано на mask_integration с инициализированной БД: 1 passed).
Полный прогон: 373→374 passed, errors 12→5.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 23:09:08 +10:00

39 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Real-тест parse_arp_file на настоящем .arp (гонять на dev2; без корпуса — skip)."""
import shutil
import tempfile
import zipfile
from pathlib import Path
import pytest
from gge_tools import parse_arp_file
SRC = Path("/home/mcp-user/smeta-web-data/smeta/b1f47437-2254-4267-a584-4d2ea050e100/11900.zip")
def test_arp_real():
if not SRC.exists():
pytest.skip("нет реальных данных корпуса (гонять на dev2)")
tmp = Path(tempfile.mkdtemp())
with zipfile.ZipFile(SRC) as z:
name = next(n for n in z.namelist() if n.lower().endswith(".arp"))
p = tmp / "s.arp"
p.write_bytes(z.read(name))
r = parse_arp_file(p)
assert "error" not in r, r
print(f" code={r['code']} | total={r['total']} | positions={r['positions_count']}")
assert r["code"] == "00-02-7-00-01Р", r["code"] # реальный якорь (не только непустота)
assert abs(r["total"] - 6105760.71) < 0.01, r["total"] # ловит съезд индекса поля итога
assert r["positions_count"] > 0, r
p0 = r["positions"][0]
assert p0["code"] and p0["name"] and p0["unit"], p0
assert p0["total"] > 0, p0 # ловит съезд индекса стоимости позиции
print(f" пример: {p0}")
shutil.rmtree(tmp, ignore_errors=True)
print("ALL PASS")
if __name__ == "__main__":
test_arp_real()