fix: 修复补跑历史日期的静默空转与日报日期错位 (P0-3/P0-4)
- run_step: 补跑保护——历史日期跳过 crawler(首页只含当天内容)并告警,复用已有 raw 数据 - run_step: report 步骤改用传入的 date_str,不再硬编码 date.today() - 新增 4 个补跑相关测试,修正 3 个既有测试适配新行为 - 全量 259 passed(3 个 crawler 基线失败与本次无关)
This commit is contained in:
+10
-3
@@ -56,9 +56,12 @@ def test_pipeline_result_partial_failure() -> None:
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
def test_run_step_success() -> None:
|
||||
# crawler 补跑保护:仅当天日期才执行子进程,故用今天的日期
|
||||
from datetime import date
|
||||
today = date.today().strftime("%Y%m%d")
|
||||
with patch("subprocess.run", return_value=_mock_proc(returncode=0,
|
||||
stderr="INFO | 完成: 成功 20/20")):
|
||||
sr = run_step("crawler", "20260616")
|
||||
sr = run_step("crawler", today)
|
||||
assert sr.success is True
|
||||
assert sr.exit_code == 0
|
||||
|
||||
@@ -109,6 +112,8 @@ def test_run_pipeline_all_success() -> None:
|
||||
|
||||
def test_run_pipeline_continues_on_failure() -> None:
|
||||
"""中间步骤失败,后续继续执行(不阻断)。"""
|
||||
from datetime import date
|
||||
today = date.today().strftime("%Y%m%d") # crawler 补跑保护:需当天日期才执行
|
||||
call_count = {"n": 0}
|
||||
|
||||
def _side_effect(*args, **kwargs):
|
||||
@@ -118,7 +123,7 @@ def test_run_pipeline_continues_on_failure() -> None:
|
||||
return _mock_proc(returncode=0, stderr="ok")
|
||||
|
||||
with patch("subprocess.run", side_effect=_side_effect):
|
||||
result = run_pipeline("20260616", steps=["crawler", "extractor", "dedup", "llm"])
|
||||
result = run_pipeline(today, steps=["crawler", "extractor", "dedup", "llm"])
|
||||
assert len(result.steps) == 4
|
||||
# extractor 失败,但后续仍执行
|
||||
assert result.steps[1].success is False
|
||||
@@ -126,7 +131,9 @@ def test_run_pipeline_continues_on_failure() -> None:
|
||||
|
||||
|
||||
def test_run_pipeline_custom_steps() -> None:
|
||||
from datetime import date
|
||||
today = date.today().strftime("%Y%m%d")
|
||||
with patch("subprocess.run", return_value=_mock_proc(returncode=0, stderr="ok")):
|
||||
result = run_pipeline("20260616", steps=["crawler", "extractor"])
|
||||
result = run_pipeline(today, steps=["crawler", "extractor"])
|
||||
assert len(result.steps) == 2
|
||||
assert result.all_success is True
|
||||
|
||||
Reference in New Issue
Block a user