refactor(fudai): 拆出 _handle_in_fudai_detail 详情为None早返回(3687→3663,-24 行)
handle_detail_is_none:detail==None 时清除任务数量标志 + 写完成日志 + 早返回。 新增 3 个单元测试,1068 → 1071 用例全过。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
18c6f7b025
commit
b6cd3ac8a3
3 files changed
+70
-26
No files matched your search
@@ -61,3 +61,35 @@ def test_close_detail_failure_does_not_break():
|
||||
result = fudai_detail_blocks.handle_too_many_consecutive_failures(a)
|
||||
assert result is True
|
||||
a.swipe_up_to_next_live.assert_called_once()
|
||||
|
||||
|
||||
# ---- handle_detail_is_none ---- #
|
||||
|
||||
import time as _time
|
||||
|
||||
|
||||
def test_detail_is_none_returns_true_and_clears_task_count():
|
||||
a = MagicMock()
|
||||
a._log_kv = MagicMock()
|
||||
a._fudai_detail_task_count_from_stage = 5
|
||||
result = fudai_detail_blocks.handle_detail_is_none(a, _time.time() - 1.0)
|
||||
assert result is True
|
||||
assert a._fudai_detail_task_count_from_stage is None
|
||||
|
||||
|
||||
def test_detail_is_none_logs_completion():
|
||||
a = MagicMock()
|
||||
a._log_kv = MagicMock()
|
||||
fudai_detail_blocks.handle_detail_is_none(a, _time.time() - 0.5)
|
||||
# 至少调用了 3 次:详情为None / 清除标志 / 完成日志
|
||||
assert a._log_kv.call_count >= 2
|
||||
|
||||
|
||||
def test_detail_is_none_swallows_log_exceptions():
|
||||
"""_log_kv 抛错也不应传播"""
|
||||
a = MagicMock()
|
||||
a._log_kv.side_effect = RuntimeError("boom")
|
||||
a._fudai_detail_task_count_from_stage = 5
|
||||
# 应当不抛错
|
||||
result = fudai_detail_blocks.handle_detail_is_none(a, _time.time())
|
||||
assert result is True
|
||||
Reference in new issue
Block a user