attend_choujiang 中加入粉丝团门槛分支占了 1057 行(520-1576), 内含 OCR 识别按钮位置 + 多次点击 + 详情页恢复递归等复杂逻辑。 该分支只依赖 analyser 和 attend_button_text 两个参数,自包含性强。 整段提取到 douyin/fudai/core/fudai_attend_fansclub.handle_fansclub_branch, 原方法只剩 elif 调用。粉丝团模块本身是 1075 行,但与其他分支解耦后 未来可针对粉丝团逻辑做独立优化、独立测试。 冒烟测试覆盖 import + 签名 + 公开 API,1034 → 1038 用例全过。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""单元测试:douyin/fudai/core/fudai_attend_fansclub.py
|
|
|
|
只做最小冒烟:能 import + 函数签名正确。
|
|
完整业务测试需要大量 OCR / ADB / 截图桩,性价比低。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import inspect
|
|
|
|
from douyin.fudai.core import fudai_attend_fansclub
|
|
|
|
|
|
def test_module_import():
|
|
assert fudai_attend_fansclub is not None
|
|
|
|
|
|
def test_handle_fansclub_branch_signature():
|
|
fn = fudai_attend_fansclub.handle_fansclub_branch
|
|
sig = inspect.signature(fn)
|
|
params = list(sig.parameters.keys())
|
|
assert params == ["analyser", "attend_button_text"]
|
|
|
|
|
|
def test_handle_fansclub_branch_callable():
|
|
assert callable(fudai_attend_fansclub.handle_fansclub_branch)
|
|
|
|
|
|
def test_module_only_exports_one_public_fn():
|
|
"""保持 API 最小化"""
|
|
public = [
|
|
x for x in dir(fudai_attend_fansclub)
|
|
if not x.startswith("_") and not x[0].isupper()
|
|
]
|
|
# 排除 import 进来的模块
|
|
own = [x for x in public if x not in {"os", "time", "path_config", "annotations"}]
|
|
assert "handle_fansclub_branch" in own
|