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_invalid_format():
|
|
analyser = _mk_analyser()
|
|
detail = ("福袋", "60:37", 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_invalid"
|
|
|
|
|
|
def test_button_unable_should_be_primary_reason_even_with_countdown_gt():
|
|
analyser = _mk_analyser()
|
|
analyser.button_text_raw = "活动已结束"
|
|
detail = ("福袋", "05:49", 10, 1, 999.0, (time.time(), time.time() + 349))
|
|
skip, reason = should_skip_fudai_by_config(analyser, detail)
|
|
assert skip is True
|
|
assert reason == "button_unable_to_participate"
|