feat(ext): Фаза 4/5 — охват всех источников/документов + все регионы

fgis_client: opendata_list/meta/download (15 датасетов: КСР/ФСНБ/СПСРП/оплата труда/9 ПССР),
bim_leaf_docs (дерево писем-индексов), download_by_guid, all_subject_ids. xsd_client: скрейп
.zip-схем экспертизы (html.parser, fail-loud на 0 ссылок). ext_pull: pull_opendata/bim/xsd,
--source opendata/bim/xsd/all-sources, --regions all (все 86). ext_check: check_opendata
(lastChangeDate)/check_bim(guid)/check_xsd(ссылки) + режим all-regions — чекер мониторит ВСЁ.
10 новых тестов.
This commit is contained in:
anor
2026-07-18 10:04:17 +10:00
parent 8aef1a1f42
commit c5e210c918
6 changed files with 405 additions and 15 deletions
+29
View File
@@ -15,6 +15,15 @@ import fgis_client as fc # noqa: E402
import pravo_client as pc # noqa: E402
@pytest.fixture(autouse=True)
def _mock_new_sources(monkeypatch):
"""По умолчанию opendata/bim/xsd не дают находок (не ходят в сеть). Тесты переопределяют."""
import xsd_client
monkeypatch.setattr(fc, "opendata_list", lambda client=None: [])
monkeypatch.setattr(fc, "bim_leaf_docs", lambda client=None: [])
monkeypatch.setattr(xsd_client, "schema_links", lambda client=None: [])
@pytest.fixture
def _tmp(monkeypatch, tmp_path):
monkeypatch.setenv("EXT_SNAPSHOT_DIR", str(tmp_path))
@@ -143,6 +152,26 @@ def test_rollback_reports_again(_tmp, monkeypatch):
assert any(f["source"] == "fgis_split_form" and "426" in f["message"] for f in rep["findings"])
def test_new_sources_detected_and_deduped(_tmp, monkeypatch):
"""opendata (по lastChangeDate), bim (по guid), xsd (по ссылке) — находки + дедуп на 2-м прогоне."""
import xsd_client
_mock_fgis(monkeypatch, latest=426)
_mock_pravo(monkeypatch, [])
monkeypatch.setattr(fc, "opendata_list",
lambda client=None: [{"id": 2, "datasetName": "КСР", "lastChangeDate": "2026-05-20"}])
monkeypatch.setattr(fc, "bim_leaf_docs",
lambda client=None: [{"guid": "G1", "name": "письмо 1 кв", "filePath": "/x.pdf"}])
monkeypatch.setattr(xsd_client, "schema_links", lambda client=None: ["/a/KAC.zip"])
with es.update_state() as st:
st["sources"]["fgis_split_form"] = {"323/191": {"period_id": 426}}
rep = ec.run_check(regions=[323], notify=False)
srcs = {f["source"] for f in rep["findings"]}
assert {"fgis_opendata", "fgis_bim", "xsd_schema"} <= srcs
# второй прогон — те же не повторяются (дедуп)
rep2 = ec.run_check(regions=[323], notify=False)
assert not [f for f in rep2["findings"] if f["source"] in ("fgis_opendata", "fgis_bim", "xsd_schema")]
def test_notify_called_only_with_findings(_tmp, monkeypatch):
_mock_fgis(monkeypatch, latest=426)
_mock_pravo(monkeypatch, [])