refactor(fudai): 拆出 needswitch 诊断日志(2429→2390,-39 行)
把 run_once_basic 中"needswitch 配置 + 第一个预约详情"的诊断日志(48 行) 抽到 fudai_run_blocks.log_needswitch_check_details。纯日志辅助函数。 新增 2 个单元测试覆盖正常队列与空队列。1146 → 1148 用例全过。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
970e9043cb
commit
28f91b2aaf
3 files changed
+79
-40
No files matched your search
@@ -697,3 +697,41 @@ def test_completed_reset_zero_room_pos_no_swipes():
|
||||
swipe = MagicMock()
|
||||
assert fudai_run_blocks.handle_all_reservations_completed_reset(a, swipe) is True
|
||||
swipe.assert_not_called()
|
||||
|
||||
|
||||
# ---- log_needswitch_check_details ---- #
|
||||
|
||||
def test_log_needswitch_with_reservation_logs_first_detail():
|
||||
a = MagicMock()
|
||||
a.reservations = [
|
||||
{
|
||||
"future_ts": time.time() + 100,
|
||||
"prize_value_yuan": 5.0,
|
||||
"pos_seen": 3,
|
||||
}
|
||||
]
|
||||
a.room_pos = 7
|
||||
fudai_run_blocks.log_needswitch_check_details(a, True)
|
||||
call = next(
|
||||
c for c in a._log_kv.call_args_list
|
||||
if len(c.args) >= 2 and "检查预约回退条件" in c.args[1]
|
||||
)
|
||||
assert call.kwargs["needswitch_cfg"] is True
|
||||
assert call.kwargs["reservations_count"] == 1
|
||||
info = call.kwargs["first_reservation"]
|
||||
assert info["pos_seen"] == 3
|
||||
assert info["current_room_pos"] == 7
|
||||
assert info["value"] == 5.0
|
||||
|
||||
|
||||
def test_log_needswitch_empty_queue_logs_zero_count():
|
||||
a = MagicMock()
|
||||
a.reservations = []
|
||||
fudai_run_blocks.log_needswitch_check_details(a, False)
|
||||
call = next(
|
||||
c for c in a._log_kv.call_args_list
|
||||
if len(c.args) >= 2 and "检查预约回退条件" in c.args[1]
|
||||
)
|
||||
assert call.kwargs["needswitch_cfg"] is False
|
||||
assert call.kwargs["reservations_count"] == 0
|
||||
assert call.kwargs["first_reservation"] == {}
|
||||
Reference in new issue
Block a user