- 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]>
48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { createMockFetch, SUNNYPT_USER_ERROR, SUNNYPT_USER_MESSAGES, SUNNYPT_USER_PROFILE } from "@umt/testkit";
|
|
import { describe, expect, it } from "vitest";
|
|
import { SunnyPTSiteUserInfo } from "./sunnypt.ts";
|
|
import { runParser } from "./testing.ts";
|
|
|
|
const API = "https://api.sunnypt.top/api/v1/mp";
|
|
|
|
describe("SunnyPTSiteUserInfo(MP sunnypt.py)", () => {
|
|
it("profile + 未读消息分页(不标记已读)", async () => {
|
|
const m = createMockFetch({
|
|
[`GET ${API}/profile`]: { body: SUNNYPT_USER_PROFILE },
|
|
[`GET ${API}/messages?unread_only=true&page=1`]: { body: SUNNYPT_USER_MESSAGES },
|
|
});
|
|
const info = await runParser(SunnyPTSiteUserInfo, {
|
|
fetch: m.fetch,
|
|
url: "https://sunnypt.top/",
|
|
apikey: "sk",
|
|
fetchMessages: true,
|
|
});
|
|
expect(info).toMatchObject({
|
|
schema: "SunnyPT",
|
|
userId: "12",
|
|
username: "kate",
|
|
userLevel: "Elite User",
|
|
joinAt: "2023-04-05 06:07:08",
|
|
upload: 4000,
|
|
download: 2000,
|
|
ratio: 2,
|
|
bonus: 88.8,
|
|
seeding: 7,
|
|
seedingSize: 7000,
|
|
leeching: 1,
|
|
leechingSize: 100,
|
|
messageUnread: 1,
|
|
messageUnreadContents: [{ head: "通知", date: "2026-09-20 08:00:00", content: "内容" }],
|
|
});
|
|
expect(m.requests[0]!.headers["x-api-key"]).toBe("sk");
|
|
expect(m.requests.every((r) => r.method === "GET")).toBe(true);
|
|
});
|
|
|
|
it("API 错误:errMsg 为站点 msg", async () => {
|
|
const m = createMockFetch({ [`GET ${API}/profile`]: { body: SUNNYPT_USER_ERROR } });
|
|
const info = await runParser(SunnyPTSiteUserInfo, { fetch: m.fetch, url: "https://sunnypt.top/", apikey: "x" });
|
|
expect(info.userId).toBeNull();
|
|
expect(info.errMsg).toBe("API Key 无效");
|
|
});
|
|
});
|