chore: auto release commit (2026-09-15 00:57:09)
All checks were successful
技能自动化发布 / release (push) Successful in 5s
All checks were successful
技能自动化发布 / release (push) Successful in 5s
This commit is contained in:
@@ -1271,6 +1271,101 @@ def test_enqueue_download_tasks_safe_empty_list() -> tuple[bool, str]:
|
||||
return True, "空列表 no-op OK"
|
||||
|
||||
|
||||
# ---------- v1.1.19: _wait_for_url_stable + login flow ----------
|
||||
|
||||
|
||||
class _FakePage:
|
||||
"""v1.1.19 login flow 测试用的简易 page mock。
|
||||
|
||||
- .url: 字符串
|
||||
- 支持外部修改 .url 模拟用户登录跳转
|
||||
"""
|
||||
|
||||
def __init__(self, initial_url: str = "about:blank") -> None:
|
||||
self.url = initial_url
|
||||
self.goto_calls: list[str] = []
|
||||
self.reload_calls: int = 0
|
||||
self.click_calls: int = 0
|
||||
|
||||
|
||||
def test_wait_for_url_stable_immediate_match() -> tuple[bool, str]:
|
||||
"""_wait_for_url_stable: URL 已含目标 + 稳定 → 立即返回 True。"""
|
||||
from service.platform_collector import _wait_for_url_stable
|
||||
|
||||
page = _FakePage("https://example.com/app/contracts")
|
||||
if not _wait_for_url_stable(page, "/app/", max_wait_sec=5):
|
||||
return False, "URL 已含 /app/ 应立即返回 True"
|
||||
if page.goto_calls or page.reload_calls:
|
||||
return False, f"不应触发 goto/reload: {page.goto_calls}/{page.reload_calls}"
|
||||
return True, "URL 已含 /app/ 立即返回 OK"
|
||||
|
||||
|
||||
def test_wait_for_url_stable_transition() -> tuple[bool, str]:
|
||||
"""_wait_for_url_stable: URL 经历 login → /app/ 过渡,等稳定后返回 True。"""
|
||||
import threading
|
||||
import time as _time
|
||||
|
||||
from service.platform_collector import _wait_for_url_stable
|
||||
|
||||
page = _FakePage("https://example.com/login")
|
||||
|
||||
def flip_to_app():
|
||||
_time.sleep(0.6)
|
||||
page.url = "https://example.com/app/home"
|
||||
|
||||
threading.Thread(target=flip_to_app, daemon=True).start()
|
||||
if not _wait_for_url_stable(page, "/app/", max_wait_sec=5):
|
||||
return False, f"应等 URL 稳定到 /app/,但超时(最终 URL={page.url})"
|
||||
return True, f"URL 过渡后稳定 OK(最终 URL={page.url})"
|
||||
|
||||
|
||||
def test_wait_for_url_stable_timeout() -> tuple[bool, str]:
|
||||
"""_wait_for_url_stable: URL 始终未跳到目标 → 超时返回 False。"""
|
||||
from service.platform_collector import _wait_for_url_stable
|
||||
|
||||
page = _FakePage("https://example.com/login")
|
||||
if _wait_for_url_stable(page, "/app/", max_wait_sec=2):
|
||||
return False, "URL 永远含 login,应超时返回 False"
|
||||
return True, "超时返回 False OK"
|
||||
|
||||
|
||||
def test_wait_for_manual_login_no_goto() -> tuple[bool, str]:
|
||||
"""_wait_for_manual_login: 等待期间 **不应** 触发 goto / reload / click。"""
|
||||
import threading
|
||||
import time as _time
|
||||
|
||||
from service import platform_collector as pc
|
||||
|
||||
# platform_collector 在 import 时已经把常量复制到模块 globals;
|
||||
# 直接覆盖模块属性最稳。缩短 HUMAN_POLL_INTERVAL 和 URL_STABLE_REQUIRED_S,
|
||||
# 让 fake_user 0.8s 翻 URL + 0.3s 稳定窗口能凑进 wait_sec=5。
|
||||
orig_poll = pc.HUMAN_POLL_INTERVAL
|
||||
orig_stable = pc.URL_STABLE_REQUIRED_S
|
||||
pc.HUMAN_POLL_INTERVAL = 0.3
|
||||
pc.URL_STABLE_REQUIRED_S = 0.3
|
||||
try:
|
||||
page = _FakePage("https://example.com/login")
|
||||
|
||||
def fake_user_login():
|
||||
_time.sleep(0.8)
|
||||
page.url = "https://example.com/app/home"
|
||||
|
||||
threading.Thread(target=fake_user_login, daemon=True).start()
|
||||
try:
|
||||
pc._wait_for_manual_login(page, wait_sec=5)
|
||||
except Exception as e:
|
||||
return False, f"应等用户登录成功,但抛异常: {e}"
|
||||
|
||||
if page.goto_calls:
|
||||
return False, f"等待期间不应 goto: {page.goto_calls}"
|
||||
if page.reload_calls:
|
||||
return False, f"等待期间不应 reload: {page.reload_calls}"
|
||||
return True, "等用户登录期间无打断 OK"
|
||||
finally:
|
||||
pc.HUMAN_POLL_INTERVAL = orig_poll
|
||||
pc.URL_STABLE_REQUIRED_S = orig_stable
|
||||
|
||||
|
||||
# ---------- v1.1.18: show-config / logs-list ----------
|
||||
|
||||
|
||||
@@ -1540,6 +1635,10 @@ def main() -> int:
|
||||
_run("download_tasks/enqueue_safe_idempotent", test_enqueue_download_tasks_safe_idempotent)
|
||||
_run("download_tasks/enqueue_safe_fk_failure", test_enqueue_download_tasks_safe_fk_failure)
|
||||
_run("download_tasks/enqueue_safe_empty_list", test_enqueue_download_tasks_safe_empty_list)
|
||||
_run("login_flow/wait_url_stable_immediate", test_wait_for_url_stable_immediate_match)
|
||||
_run("login_flow/wait_url_stable_transition", test_wait_for_url_stable_transition)
|
||||
_run("login_flow/wait_url_stable_timeout", test_wait_for_url_stable_timeout)
|
||||
_run("login_flow/wait_manual_login_no_goto", test_wait_for_manual_login_no_goto)
|
||||
_run("show_config/masks_tokens", test_show_config_masks_tokens)
|
||||
_run("show_config/skips_empty", test_show_config_skips_empty)
|
||||
_run("show_config/skips_comments", test_show_config_skips_comments)
|
||||
|
||||
Reference in New Issue
Block a user