mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
update ncm_artist ncm_radio
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
from httpx import Response
|
||||
from nonebug.app import App
|
||||
@@ -10,6 +12,10 @@ def bing_dy_list():
|
||||
return get_json("bilibili_bing_list.json")["data"]["cards"]
|
||||
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.bilibili import Bilibili
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bilibili(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
@@ -46,3 +52,20 @@ async def test_dynamic_forward(bilibili, bing_dy_list):
|
||||
+ "\n--------------\n"
|
||||
+ "#明日方舟#\n【新增服饰】\n//殿堂上的游禽 - 星极\n塞壬唱片偶像企划《闪耀阶梯》特供服饰/殿堂上的游禽。星极自费参加了这项企划,尝试着用大众能接受的方式演绎天空之上的故事。\n\n_____________\n谦逊留给观众,骄傲发自歌喉,此夜,唯我璀璨。 "
|
||||
)
|
||||
|
||||
|
||||
async def test_parse_target(bilibili: "Bilibili"):
|
||||
from nonebot_bison.platform.platform import Platform
|
||||
|
||||
res = await bilibili.parse_target(
|
||||
"https://space.bilibili.com/161775300?from=search&seid=130517740606234234234&spm_id_from=333.337.0.0"
|
||||
)
|
||||
assert res == "161775300"
|
||||
res2 = await bilibili.parse_target(
|
||||
"space.bilibili.com/161775300?from=search&seid=130517740606234234234&spm_id_from=333.337.0.0"
|
||||
)
|
||||
assert res2 == "161775300"
|
||||
with pytest.raises(Platform.ParseTargetException):
|
||||
await bilibili.parse_target(
|
||||
"https://www.bilibili.com/video/BV1qP4y1g738?spm_id_from=333.999.0.0"
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
import respx
|
||||
@@ -7,6 +8,9 @@ from nonebug.app import App
|
||||
|
||||
from .utils import get_json
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ncm_artist import NcmArtist
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ncm_artist(app: App):
|
||||
@@ -48,3 +52,16 @@ async def test_fetch_new(ncm_artist, ncm_artist_0, ncm_artist_1, dummy_user_subi
|
||||
assert post.target_type == "ncm-artist"
|
||||
assert post.text == "新专辑发布:Y1K"
|
||||
assert post.url == "https://music.163.com/#/album?id=131074504"
|
||||
|
||||
|
||||
async def test_parse_target(ncm_artist: "NcmArtist"):
|
||||
from nonebot_bison.platform.platform import Platform
|
||||
|
||||
res = await ncm_artist.parse_target("32540734")
|
||||
assert res == "32540734"
|
||||
res = await ncm_artist.parse_target("https://music.163.com/#/artist?id=32540734")
|
||||
assert res == "32540734"
|
||||
res = await ncm_artist.parse_target("music.163.com/#/artist?id=32540734")
|
||||
assert res == "32540734"
|
||||
with pytest.raises(Platform.ParseTargetException):
|
||||
await ncm_artist.parse_target("music.163.com/#/rad?id=32540734")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
import respx
|
||||
@@ -7,6 +8,9 @@ from nonebug.app import App
|
||||
|
||||
from .utils import get_json
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ncm_radio import NcmRadio
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ncm_radio(app: App):
|
||||
@@ -53,3 +57,14 @@ async def test_fetch_new(ncm_radio, ncm_radio_0, ncm_radio_1, dummy_user_subinfo
|
||||
"http://p1.music.126.net/H5em5xUNIYXcjJhOmeaSqQ==/109951166647436789.jpg"
|
||||
]
|
||||
assert post.target_name == "《明日方舟》游戏原声OST"
|
||||
|
||||
|
||||
async def test_parse_target(ncm_radio: "NcmRadio"):
|
||||
res = await ncm_radio.parse_target("https://music.163.com/#/djradio?id=793745436")
|
||||
assert res == "793745436"
|
||||
res = await ncm_radio.parse_target("music.163.com/#/djradio?id=793745436")
|
||||
assert res == "793745436"
|
||||
res = await ncm_radio.parse_target("793745436")
|
||||
assert res == "793745436"
|
||||
with pytest.raises(ncm_radio.ParseTargetException):
|
||||
await ncm_radio.parse_target("music.163.com/#/alm?id=793745436")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import typing
|
||||
from datetime import datetime
|
||||
|
||||
import feedparser
|
||||
@@ -9,6 +10,9 @@ from pytz import timezone
|
||||
|
||||
from .utils import get_file, get_json
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.weibo import Weibo
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def weibo(app: App):
|
||||
@@ -125,3 +129,16 @@ def test_chaohua_tag(weibo):
|
||||
tags = weibo.get_tags(test_post)
|
||||
assert "刚出生的小羊驼长啥样" in tags
|
||||
assert "小羊驼三三超话" in tags
|
||||
|
||||
|
||||
async def test_parse_target(weibo: "Weibo"):
|
||||
from nonebot_bison.platform.platform import Platform
|
||||
|
||||
res = await weibo.parse_target("https://weibo.com/u/6441489862")
|
||||
assert res == "6441489862"
|
||||
res = await weibo.parse_target("weibo.com/u/6441489862")
|
||||
assert res == "6441489862"
|
||||
res = await weibo.parse_target("6441489862")
|
||||
assert res == "6441489862"
|
||||
with pytest.raises(Platform.ParseTargetException):
|
||||
await weibo.parse_target("https://weibo.com/arknights")
|
||||
|
||||
Reference in New Issue
Block a user