37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import time
|
|
from unittest.mock import MagicMock
|
|
|
|
from douyin.fudai.core.fudai_filter_pkg.should_skip import should_skip_fudai_by_config
|
|
|
|
|
|
def _mk_analyser():
|
|
a = MagicMock()
|
|
a._log_kv = MagicMock()
|
|
a.needswitch = True
|
|
a.min_prize_value_yuan = 0.0
|
|
a.min_participants = 0
|
|
a.max_participants = 0
|
|
a.skip_if_countdown_gt_seconds = 118
|
|
a.skip_if_countdown_lt_seconds = 5
|
|
a.button_text_raw = "参与抽奖"
|
|
return a
|
|
|
|
|
|
def test_should_skip_when_countdown_text_missing():
|
|
analyser = _mk_analyser()
|
|
# 倒计时 tuple 存在,但 time_text 为空时应直接跳过,避免默认兜底秒数触发参与
|
|
detail = ("福袋", "", 10, 1, 999.0, (time.time(), time.time() + 120))
|
|
skip, reason = should_skip_fudai_by_config(analyser, detail)
|
|
assert skip is True
|
|
assert reason == "countdown_missing"
|
|
|
|
|
|
def test_should_skip_when_countdown_is_zero():
|
|
analyser = _mk_analyser()
|
|
detail = ("福袋", "00:00", 10, 1, 999.0, (time.time(), time.time()))
|
|
skip, reason = should_skip_fudai_by_config(analyser, detail)
|
|
assert skip is True
|
|
assert reason == "countdown_zero"
|