fix(ext): БИМ-письма качать по filePath (guid файла), не по guid узла дерева
Живой обход поймал: у БИМ-узла NormLegalDocPublished guid — это идентичность УЗЛА дерева, а скачивание идёт по ОТДЕЛЬНОМУ guid файла в поле filePath. pull_bim качал по guid узла → 403 Forbidden на все письма. Проверено вживую: download по filePath → PDF 3.96МБ, по guid узла → 403. Снапшот по-прежнему кладём под guid узла (стабильная идентичность письма для инкрементального дедупа), но GetFileContent зовём с filePath. Регресс-тест проверяет, что download зовётся с filePath, а не с node guid. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+14
-10
@@ -64,26 +64,30 @@ def test_pull_salary_saves_json(monkeypatch, tmp_path):
|
||||
assert json.loads(snap.read_text())["items"][0]["code"] == "1-100-1"
|
||||
|
||||
|
||||
def test_pull_bim_poison_letter_skipped_tail_downloaded(monkeypatch, tmp_path):
|
||||
"""Одно «ядовитое» письмо (FetchError) НЕ блокирует хвост: L2 качается, а частичный сбой
|
||||
сигналится PartialPullError (несёт успехи) → ненулевой exit у CLI. Fable-фикс #2/(a)."""
|
||||
def test_pull_bim_downloads_by_filepath_not_node_guid(monkeypatch, tmp_path):
|
||||
"""БИМ качается по filePath (guid ФАЙЛА), НЕ по guid УЗЛА дерева — тот даёт 403 (реальный баг,
|
||||
пойман на живом обходе). Плюс: ядовитое письмо пропускается, хвост докачан, частичный сбой →
|
||||
PartialPullError (exit 1). Ключ снапшота — по guid узла (стабильная идентичность письма)."""
|
||||
import ext_fetch
|
||||
monkeypatch.setenv("EXT_SNAPSHOT_DIR", str(tmp_path))
|
||||
monkeypatch.setattr(fc, "bim_leaf_docs", lambda client=None: [
|
||||
{"guid": "L1", "name": "битое", "filePath": "/1.pdf"},
|
||||
{"guid": "L2", "name": "ок", "filePath": "/2.pdf"}])
|
||||
{"guid": "node1", "name": "битое", "filePath": "file1"},
|
||||
{"guid": "node2", "name": "ок", "filePath": "file2"}])
|
||||
called = []
|
||||
def dl(guid, dest, client=None, expect_min_size=500):
|
||||
if guid == "L1":
|
||||
raise ext_fetch.FetchError("удалено上游 → HTML")
|
||||
called.append(guid)
|
||||
if guid == "file1":
|
||||
raise ext_fetch.FetchError("403 Forbidden")
|
||||
Path(dest).write_bytes(b"PDF-" + b"z" * 600)
|
||||
return {"path": str(dest), "size": 604, "sha256": es.sha256_file(dest)}
|
||||
monkeypatch.setattr(fc, "download_by_guid", dl)
|
||||
import pytest
|
||||
with pytest.raises(ep.PartialPullError) as ei:
|
||||
ep.pull_bim()
|
||||
assert [r["key"] for r in ei.value.results] == ["bim/L2"] # хвост докачан
|
||||
assert (tmp_path / "snapshots/fgis/bim_letters/L2/meta.json").exists()
|
||||
assert ep._drain(ep.pull_bim) == 1 # CLI видит ненулевой exit
|
||||
assert set(called) == {"file1", "file2"} # по filePath, НЕ по node guid
|
||||
assert [r["key"] for r in ei.value.results] == ["bim/node2"] # ключ по guid узла
|
||||
assert (tmp_path / "snapshots/fgis/bim_letters/node2/meta.json").exists()
|
||||
assert ep._drain(ep.pull_bim) == 1 # CLI видит ненулевой exit
|
||||
|
||||
|
||||
def test_solo_run_creates_missing_ext_dir(monkeypatch, tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user