"""douyin/other 模块单元测试。 覆盖: - douyin_high_value_room: _normalize_room_title 纯函数 - douyin_popups: 弹窗检测函数签名验证 - douyin_lottery: 抽奖函数签名验证 """ from __future__ import annotations import pytest class TestNormalizeRoomTitle: """_normalize_room_title 纯函数测试。""" def test_removes_trailing_numbers(self): from douyin.other.douyin_high_value_room import _normalize_room_title result = _normalize_room_title("王媛媛2") assert "2" not in result or result == "王媛媛" def test_removes_spaces(self): from douyin.other.douyin_high_value_room import _normalize_room_title result = _normalize_room_title("王 媛 媛") assert " " not in result def test_removes_common_words(self): from douyin.other.douyin_high_value_room import _normalize_room_title result = _normalize_room_title("王媛媛直播中") assert "直播中" not in result def test_empty_string(self): from douyin.other.douyin_high_value_room import _normalize_room_title result = _normalize_room_title("") assert result == "" def test_none_input(self): from douyin.other.douyin_high_value_room import _normalize_room_title result = _normalize_room_title(None) assert result == "" def test_removes_newlines(self): from douyin.other.douyin_high_value_room import _normalize_room_title result = _normalize_room_title("王媛媛\n直播") assert "\n" not in result class TestHighValueRoomFunctions: """douyin_high_value_room 模块函数测试。""" def test_touch_high_value_room_exists(self): from douyin.other.douyin_high_value_room import touch_high_value_room assert callable(touch_high_value_room) def test_get_revisit_candidates_exists(self): from douyin.other.douyin_high_value_room import get_revisit_candidates assert callable(get_revisit_candidates) def test_should_trigger_revisit_exists(self): from douyin.other.douyin_high_value_room import should_trigger_revisit assert callable(should_trigger_revisit) def test_execute_room_revisit_exists(self): from douyin.other.douyin_high_value_room import execute_room_revisit assert callable(execute_room_revisit) class TestDouyinPopups: """douyin_popups 模块测试。""" def test_check_coupon_popup_exists(self): from douyin.other.douyin_popups import check_coupon_popup assert callable(check_coupon_popup) def test_check_shopping_redpacket_popup_exists(self): from douyin.other.douyin_popups import check_shopping_redpacket_popup assert callable(check_shopping_redpacket_popup) def test_handle_lottery_result_popup_exists(self): from douyin.other.douyin_popups import handle_lottery_result_popup assert callable(handle_lottery_result_popup) class TestDouyinLottery: """douyin_lottery 模块测试。""" def test_wait_for_lottery_result_exists(self): from douyin.other.douyin_lottery import wait_for_lottery_result assert callable(wait_for_lottery_result) def test_process_lottery_result_exists(self): from douyin.other.douyin_lottery import process_lottery_result assert callable(process_lottery_result) class TestDouyinGuaji: """douyin_guaji 模块测试。""" def test_fudai_guaji_class_exists(self): from douyin.other.douyin_guaji import fudai_guaji assert fudai_guaji is not None class TestDouyinLiveRoom: """douyin_live_room 模块测试。""" def test_module_importable(self): from douyin.other import douyin_live_room assert douyin_live_room is not None class TestDouyinRobot: """douyin_robot 模块测试。""" def test_module_importable(self): from douyin.other import douyin_robot assert douyin_robot is not None class TestDouyinYanghaoShimConsistency: """验证 yanghao shim 与子模块导出一致。""" def test_yanghao_recommend_flow_same_object(self): from douyin.other.douyin_yanghao import yanghao_recommend_flow as f1 from douyin.other.douyin_yanghao_pkg import yanghao_recommend_flow as f2 assert f1 is f2 def test_yanghao_wait_same_object(self): from douyin.other.douyin_yanghao import yanghao_wait as f1 from douyin.other.douyin_yanghao_pkg import yanghao_wait as f2 assert f1 is f2 def test_yanghao_get_recommend_seconds_same_object(self): from douyin.other.douyin_yanghao import yanghao_get_recommend_seconds as f1 from douyin.other.douyin_yanghao_pkg import yanghao_get_recommend_seconds as f2 assert f1 is f2 class TestOtherModules: """other 子模块存在性测试。""" def test_douyin_guaji_importable(self): from douyin.other import douyin_guaji assert douyin_guaji is not None def test_douyin_high_value_room_importable(self): from douyin.other import douyin_high_value_room assert douyin_high_value_room is not None def test_douyin_live_room_importable(self): from douyin.other import douyin_live_room assert douyin_live_room is not None def test_douyin_lottery_importable(self): from douyin.other import douyin_lottery assert douyin_lottery is not None def test_douyin_popups_importable(self): from douyin.other import douyin_popups assert douyin_popups is not None def test_douyin_robot_importable(self): from douyin.other import douyin_robot assert douyin_robot is not None def test_douyin_yanghao_importable(self): from douyin.other import douyin_yanghao assert douyin_yanghao is not None