- sites/spiders: Haidan/HDDolby/RousiPro/SunnyPT/TNode/TorrentLeech/Yema (+mTorrent wrapper), specialized SiteAdapter, indirect download resolved at download time - sites/user-parsers: SiteParserBase + all 20 MP SiteSchema parsers (lxml XPath via xpath+xmldom), refreshSiteUserData with schema fallback - sites/definitions: zod SiteDefinition schemas, 23 MovieClaw v0.27.0 (MIT) definitions via scripts/mp-sync/movieclaw-import.mjs, registry getSiteDefinition/listSiteDefinitions, NOTICE - scripts/mp-sync: ledger.json (upstream sha256), check.mjs, build-ledger.mjs; docs/porting/mp-sync-ledger.md - license-and-provenance: add copied-mit kind, re-anchor MovieClaw rows to v0.27.0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { createMockFetch, UNIT3D_USER_DETAIL, UNIT3D_USER_INDEX, UNIT3D_USER_SEEDING } from "@umt/testkit";
|
|
import { describe, expect, it } from "vitest";
|
|
import { runParser } from "./testing.ts";
|
|
import { Unit3dSiteUserInfo } from "./unit3d.ts";
|
|
|
|
const GiB = 1024 ** 3;
|
|
|
|
describe("Unit3dSiteUserInfo(MP unit3d.py)", () => {
|
|
it("用户名来自 settings 链接;流量/等级/注册日期/做种列按 thead 定位", async () => {
|
|
const m = createMockFetch({
|
|
"/": { body: UNIT3D_USER_INDEX },
|
|
"/users/carol": { body: UNIT3D_USER_DETAIL },
|
|
"/index.php": { body: UNIT3D_USER_INDEX },
|
|
"/users/carol/active": { body: UNIT3D_USER_SEEDING },
|
|
});
|
|
const info = await runParser(Unit3dSiteUserInfo, { fetch: m.fetch });
|
|
expect(info).toMatchObject({
|
|
schema: "Unit3d",
|
|
username: "carol",
|
|
userLevel: "Elite",
|
|
joinAt: "2020-02-03 04:05:06",
|
|
bonus: 5678.9,
|
|
upload: 2 * 1024 ** 4,
|
|
download: 500 * GiB,
|
|
ratio: 4.1,
|
|
seeding: 2,
|
|
seedingSize: 4 * GiB,
|
|
seedingInfo: [
|
|
[9, 3 * GiB],
|
|
[1, GiB],
|
|
],
|
|
});
|
|
expect(m.requests.find((r) => r.url.pathname === "/users/carol/active")!.url.searchParams.get("seeding")).toBe(
|
|
"include",
|
|
);
|
|
});
|
|
|
|
it("首页取不到内容(HTTP 404):未登录并记录请求失败", async () => {
|
|
const m = createMockFetch({});
|
|
const info = await runParser(Unit3dSiteUserInfo, { fetch: m.fetch });
|
|
expect(info.username).toBeNull();
|
|
expect(info.errMsg).toContain("未检测到已登陆");
|
|
expect(info.raw.http_errors).toEqual([expect.stringContaining("HTTP 404")]);
|
|
});
|
|
});
|