mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-06 20:06:12 +08:00
🐛 修复B站订阅没有动态的用户时报错的问题(第二次)
This commit is contained in:
parent
4a36c47b92
commit
147f858a31
@ -100,7 +100,7 @@ class Bilibili(NewMessage):
|
|||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
res_dict = res.json()
|
res_dict = res.json()
|
||||||
if res_dict["code"] == 0:
|
if res_dict["code"] == 0:
|
||||||
return res_dict["data"].get("cards")
|
return res_dict["data"].get("cards", [])
|
||||||
else:
|
else:
|
||||||
raise ApiError(res.request.url)
|
raise ApiError(res.request.url)
|
||||||
|
|
||||||
|
@ -27,6 +27,20 @@ def bilibili(app: App):
|
|||||||
return platform_manager["bilibili"](ProcessContext(), AsyncClient())
|
return platform_manager["bilibili"](ProcessContext(), AsyncClient())
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def without_dynamic(app: App):
|
||||||
|
return {
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"has_more": 0,
|
||||||
|
"next_offset": 0,
|
||||||
|
"_gt_": 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_video_forward(bilibili, bing_dy_list):
|
async def test_video_forward(bilibili, bing_dy_list):
|
||||||
post = await bilibili.parse(bing_dy_list[1])
|
post = await bilibili.parse(bing_dy_list[1])
|
||||||
@ -58,6 +72,21 @@ async def test_dynamic_forward(bilibili, bing_dy_list):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
@respx.mock
|
||||||
|
async def test_fetch_new_without_dynamic(bilibili, dummy_user_subinfo, without_dynamic):
|
||||||
|
post_router = respx.get(
|
||||||
|
"https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=161775300&offset=0&need_top=0"
|
||||||
|
)
|
||||||
|
post_router.mock(return_value=Response(200, json=without_dynamic))
|
||||||
|
bilibili_main_page_router = respx.get("https://www.bilibili.com/")
|
||||||
|
bilibili_main_page_router.mock(return_value=Response(200))
|
||||||
|
target = "161775300"
|
||||||
|
res = await bilibili.fetch_new_post(target, [dummy_user_subinfo])
|
||||||
|
assert post_router.called
|
||||||
|
assert len(res) == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@respx.mock
|
@respx.mock
|
||||||
async def test_fetch_new(bilibili, dummy_user_subinfo):
|
async def test_fetch_new(bilibili, dummy_user_subinfo):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user