avoid back exit during reservation direct attend
This commit is contained in:
1 parent
e41796d43a
commit
df46d723c3
4 files changed
+64
-58
No files matched your search
@@ -65,6 +65,7 @@ class FakeAnalyser:
|
||||
# FudaiClickExecutor 可能用 operation
|
||||
class _Op:
|
||||
def __init__(self):
|
||||
self.click = MagicMock(return_value=None)
|
||||
self.click_back = MagicMock(return_value=None)
|
||||
self.delay = MagicMock(return_value=None)
|
||||
|
||||
@@ -428,6 +429,29 @@ class TestFudaiDetector:
|
||||
assert d.detect_by_icon_fallback_template(Image.open(sample).convert("RGB")) is None
|
||||
|
||||
|
||||
def test_coupon_guard_uses_click_close_during_reservation_direct_attend():
|
||||
from douyin.fudai.douyin_fudai_finder_pkg.finder import (
|
||||
is_coupon_popup_before_fudai_click,
|
||||
)
|
||||
|
||||
analyser = FakeAnalyser()
|
||||
analyser._current_attending_reservation_fudai = True
|
||||
pic = Image.new("RGB", (1080, 2400), "white")
|
||||
|
||||
with patch(
|
||||
"douyin.detection.pixel.popups.detect_coupon_popup_background",
|
||||
return_value=(True, {"method": "mock_coupon"}),
|
||||
):
|
||||
detected = is_coupon_popup_before_fudai_click(analyser, pic)
|
||||
|
||||
assert detected is True
|
||||
analyser.operation.click_back.assert_not_called()
|
||||
analyser.operation.click.assert_called_once_with("test_device", 540, 2006)
|
||||
assert analyser._log_kv.call_args.kwargs["skipped_reason"] == (
|
||||
"reservation_direct_attend_coupon_click_close"
|
||||
)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# FudaiClickExecutor
|
||||
# ============================================================
|
||||
|
||||
@@ -229,33 +229,6 @@ def test_direct_attend_icon_not_found_does_not_enter_detail_handler():
|
||||
assert marker_logs
|
||||
|
||||
|
||||
def test_direct_attend_keeps_reservation_after_coupon_guard_close():
|
||||
from douyin.reservation.douyin_reservation_handler_pkg.direct_attend import (
|
||||
handle_reservation_direct_attend,
|
||||
)
|
||||
|
||||
analyser = _mk_analyser()
|
||||
analyser._current_attending_reservation_fudai = True
|
||||
analyser.reservation_direct_attend_max_failures = 1
|
||||
|
||||
def _finder(_analyser, *_args, **_kwargs):
|
||||
_analyser._last_coupon_guard_back_ts = time.time()
|
||||
return False
|
||||
|
||||
with patch(
|
||||
"douyin.core.douyin_flow_control.find_and_open_fudai_detail",
|
||||
side_effect=_finder,
|
||||
):
|
||||
handle_reservation_direct_attend(analyser)
|
||||
|
||||
analyser._handle_in_fudai_detail.assert_not_called()
|
||||
assert analyser.reservation_after_action_pending is False
|
||||
assert analyser._current_attending_reservation_fudai is False
|
||||
assert analyser.reservations
|
||||
assert not hasattr(analyser, "_reservation_direct_attend_failures")
|
||||
assert _has_log_reason(analyser, "coupon_popup_closed_before_fudai_click")
|
||||
|
||||
|
||||
def test_direct_attend_empty_reservations_clears_flags_without_detail_handler():
|
||||
from douyin.reservation.douyin_reservation_handler_pkg.direct_attend import (
|
||||
handle_reservation_direct_attend,
|
||||
|
||||
Reference in new issue
Block a user