Files
smeta-web/tests/test_fgis_zone_scan.py
T
anorandClaude Code 2d56ab2511 feat(обход): ежедневный скан зон ФГИС с ожиданиями и журналом
Отдельный файл ожиданий, «нет» только по 404 портала, сетевой сбой в «не проверено»,
общий flock с недельным обходом, горизонт два квартала, одна строка журнала.
Четыре проверки планировщика.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-22 16:36:05 +10:00

31 lines
1.4 KiB
Python
Raw 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.
"""Планировщик ожиданий ежедневного обхода зон (22.11.2026)."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import fgis_zone_scan as z # noqa: E402
def p(i, name): return {"id": i, "name": name}
PORTAL = {(320, 245): [p(421, "1 квартал 2025 г."), p(422, "2 квартал 2025 г."),
p(423, "3 квартал 2025 г."), p(424, "4 квартал 2025 г."),
p(425, "1 квартал 2026 г."), p(426, "2 квартал 2026 г.")]}
def test_new_period_added_when_not_loaded():
adds, rem = z.plan([], PORTAL, known={(320, 245, 425)}, horizon=2)
assert any(a["period"] == "2026-Q2" for a in adds)
assert not any(a["period"] == "2026-Q1" for a in adds)
def test_expectation_not_duplicated():
ex = [{"subject_id": 320, "zone_id": 245, "period": "2026-Q2"}]
adds, _ = z.plan(ex, PORTAL, known={(320, 245, 425)}, horizon=2)
assert not [a for a in adds if a["period"] == "2026-Q2"]
def test_old_expectation_removed_by_horizon():
ex = [{"subject_id": 320, "zone_id": 245, "period": "2024-Q4"}]
_, rem = z.plan(ex, PORTAL, known=set(), horizon=2)
assert ex[0] in rem
def test_zone_gone_removes_all_its_expectations():
ex = [{"subject_id": 999, "zone_id": 1, "period": "2025-Q1"}]
_, rem = z.plan(ex, PORTAL, known=set(), horizon=2)
assert ex[0] in rem