- 新增 XQ0042 抖音平台核对、XQ0041 新美大平台核对插件的 UI 源码与打包脚本 - 重构续签电子签、服务岗转正不通过电子签等插件的版本与配置 - 删除旧版考勤异常处理、微盟数据导出等冗余插件文件 - 修复出勤积分更新插件的 OPM 推送判断逻辑 - 优化壳子插件页面的 iframe 滚动条样式
89 lines
3.5 KiB
Python
89 lines
3.5 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""XQ0042 抖音平台核对 插件冒烟自测(本机 .venv 执行,全链路)。
|
||
|
||
链路:插件加载 → run() → 复用/等待登录 → 超阈值清理导出记录(限流)→
|
||
导出核销明细 + 提现记录 → 轮询生成 → 下载落盘。
|
||
|
||
用法(仓库根目录执行):
|
||
.venv\\Scripts\\python.exe tests\\xq0042_抖音\\xq0042_plugin_smoke.py [开始日期] [结束日期]
|
||
|
||
默认导出 2026-10-27 这一天(核销时间与提现时间取同一区间)。
|
||
"""
|
||
import importlib
|
||
import json
|
||
import os
|
||
import sys
|
||
|
||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||
sys.path.insert(0, os.path.join(REPO_ROOT, 'desktop', 'electron-shell', 'python'))
|
||
sys.path.insert(0, os.path.join(REPO_ROOT, 'plugins', 'XQ0001-0100'))
|
||
|
||
RESULTS = []
|
||
|
||
|
||
def check(name, ok, detail=''):
|
||
RESULTS.append((name, bool(ok), detail))
|
||
print(f"[{'PASS' if ok else 'FAIL'}] {name}" + (f' -> {detail}' if detail else ''), flush=True)
|
||
|
||
|
||
class Ctx:
|
||
def log(self, msg, level='INFO'):
|
||
print(f'[{level}] {msg}', flush=True)
|
||
|
||
def progress(self, pct):
|
||
print(f'[进度] {pct}%', flush=True)
|
||
|
||
|
||
def main():
|
||
day_from = sys.argv[1] if len(sys.argv) > 1 else '2026-10-27'
|
||
day_to = sys.argv[2] if len(sys.argv) > 2 else day_from
|
||
|
||
pkg = importlib.import_module('XQ0042 抖音平台核对')
|
||
cfg = importlib.import_module('XQ0042 抖音平台核对.config')
|
||
plugin = next((p for p in pkg.PLUGINS if p.id == 'xq0042'), None)
|
||
check('插件已注册到 PLUGINS(id=xq0042)', plugin is not None)
|
||
if plugin is None:
|
||
sys.exit(1)
|
||
|
||
result = plugin.run({
|
||
'date_from': day_from, 'date_to': day_to,
|
||
'withdraw_from': day_from, 'withdraw_to': day_to,
|
||
'export_verify': True, 'export_withdraw': True,
|
||
'record_limit_verify': cfg.RECORD_LIMIT_VERIFY,
|
||
'record_limit_withdraw': cfg.RECORD_LIMIT_WITHDRAW,
|
||
}, Ctx()) or {}
|
||
|
||
check('run() 未抛异常并返回结果', bool(result), '')
|
||
print('返回:', json.dumps(result, ensure_ascii=False, indent=2), flush=True)
|
||
|
||
detail = result.get('detail') or {}
|
||
exports = detail.get('results') or {}
|
||
check('登录成功', '登录成功' in str(detail.get('login')) or '复用' in str(detail.get('login')),
|
||
str(detail.get('login')))
|
||
|
||
for kind in ('核销明细', '提现记录'):
|
||
item = exports.get(kind) or {}
|
||
path = item.get('path') or ''
|
||
check(f'{kind}导出成功', item.get('ok') is True, str(item.get('message')))
|
||
check(f'{kind}文件已落盘', bool(path) and os.path.isfile(path), path)
|
||
check(f'{kind}文件大小正常', item.get('size', 0) > 1024, str(item.get('size')))
|
||
|
||
for name, path in (('Cookies', cfg.COOKIE_FILE), ('storage', cfg.TOKEN_FILE),
|
||
('登录摘要', cfg.META_FILE)):
|
||
check(f'登录态{name}已落盘', os.path.isfile(path), path)
|
||
|
||
if os.path.isfile(cfg.META_FILE):
|
||
meta = json.loads(open(cfg.META_FILE, encoding='utf-8').read())
|
||
check('Cookie 数 > 0', meta.get('cookie_count', 0) > 0, str(meta.get('cookie_count')))
|
||
check('会话票据 Cookie 命中', bool(meta.get('has_session_cookie')),
|
||
str(meta.get('ticket_cookies')))
|
||
|
||
failed = [r for r in RESULTS if not r[1]]
|
||
print('=' * 60)
|
||
print(f'共 {len(RESULTS)} 项检查,通过 {len(RESULTS) - len(failed)} 项,失败 {len(failed)} 项')
|
||
sys.exit(1 if failed else 0)
|
||
|
||
|
||
if __name__ == '__main__':
|
||
main()
|