yutto/tests/test_api/test_collection.py

30 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
import aiohttp
import pytest
from yutto._typing import BvId, MId, SeriesId
from yutto.api.collection import get_collection_details
from yutto.utils.fetcher import Fetcher
from yutto.utils.funcutils import as_sync
@pytest.mark.api
@as_sync
async def test_get_collection_details():
# 测试页面https://space.bilibili.com/6762654/channel/collectiondetail?sid=39879&ctype=0
series_id = SeriesId("39879")
mid = MId("6762654")
async with aiohttp.ClientSession(
headers=Fetcher.headers,
cookies=Fetcher.cookies,
trust_env=Fetcher.trust_env,
timeout=aiohttp.ClientTimeout(total=5),
) as session:
collection_details = await get_collection_details(session, series_id=series_id, mid=mid)
title = collection_details["title"]
avids = [page["avid"] for page in collection_details["pages"]]
assert title == "傻开心整活"
assert BvId("BV1er4y1H7tQ") in avids
assert BvId("BV1Yi4y1C7u6") in avids