⬆️ 升级dev工具依赖

💄 auto fix by pre-commit hooks
This commit is contained in:
Azide
2023-07-18 20:54:21 +08:00
committed by felinae98
parent bf788ff72a
commit fc699d80ce
8 changed files with 127 additions and 139 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ def bilibili(app: App):
return platform_manager["bilibili"](ProcessContext(), AsyncClient())
@pytest.fixture
@pytest.fixture()
def without_dynamic(app: App):
return {
"code": 0,
+4 -10
View File
@@ -1,7 +1,7 @@
from copy import deepcopy
import pytest
import respx
import pytest
from nonebug.app import App
from httpx import Response, AsyncClient
@@ -31,9 +31,7 @@ def dummy_only_open_user_subinfo(app: App):
async def test_fetch_bililive_no_room(bili_live, dummy_only_open_user_subinfo):
mock_bili_live_status = get_json("bili_live_status.json")
mock_bili_live_status["data"] = []
bili_live_router = respx.get(
"https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids?uids[]=13164144"
)
bili_live_router = respx.get("https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids?uids[]=13164144")
bili_live_router.mock(return_value=Response(200, json=mock_bili_live_status))
bilibili_main_page_router = respx.get("https://www.bilibili.com/")
@@ -51,9 +49,7 @@ async def test_fetch_first_live(bili_live, dummy_only_open_user_subinfo):
mock_bili_live_status = get_json("bili_live_status.json")
empty_bili_live_status = deepcopy(mock_bili_live_status)
empty_bili_live_status["data"] = []
bili_live_router = respx.get(
"https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids?uids[]=13164144"
)
bili_live_router = respx.get("https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids?uids[]=13164144")
bili_live_router.mock(return_value=Response(200, json=empty_bili_live_status))
bilibili_main_page_router = respx.get("https://www.bilibili.com/")
@@ -74,9 +70,7 @@ async def test_fetch_first_live(bili_live, dummy_only_open_user_subinfo):
assert post.text == "[开播] 【Zc】从0挑战到15肉鸽!目前10难度"
assert post.url == "https://live.bilibili.com/3044248"
assert post.target_name == "魔法Zc目录 其他单机"
assert post.pics == [
"https://i0.hdslb.com/bfs/live/new_room_cover/fd357f0f3cbbb48e9acfbcda616b946c2454c56c.jpg"
]
assert post.pics == ["https://i0.hdslb.com/bfs/live/new_room_cover/fd357f0f3cbbb48e9acfbcda616b946c2454c56c.jpg"]
assert post.compress is True
+21 -25
View File
@@ -1,20 +1,20 @@
import typing
import xml.etree.ElementTree as ET
from datetime import datetime
import xml.etree.ElementTree as ET
import pytest
import pytz
import respx
from httpx import AsyncClient, Response
import pytest
from nonebug.app import App
from httpx import Response, AsyncClient
from .utils import get_file
if typing.TYPE_CHECKING:
from nonebot_bison.platform.rss import Rss
pass
@pytest.fixture
@pytest.fixture()
def dummy_user(app: App):
from nonebot_bison.types import User
@@ -22,7 +22,7 @@ def dummy_user(app: App):
return user
@pytest.fixture
@pytest.fixture()
def user_info_factory(app: App, dummy_user):
from nonebot_bison.types import UserSubInfo
@@ -32,34 +32,30 @@ def user_info_factory(app: App, dummy_user):
return _user_info
@pytest.fixture
@pytest.fixture()
def rss(app: App):
from nonebot_bison.platform import platform_manager
from nonebot_bison.utils import ProcessContext
from nonebot_bison.platform import platform_manager
return platform_manager["rss"](ProcessContext(), AsyncClient())
@pytest.fixture
@pytest.fixture()
def update_time_feed_1():
file = get_file("rss-twitter-ArknightsStaff.xml")
root = ET.fromstring(file)
item = root.find("channel/item")
current_time = datetime.now(pytz.timezone("GMT")).strftime(
"%a, %d %b %Y %H:%M:%S %Z"
)
current_time = datetime.now(pytz.timezone("GMT")).strftime("%a, %d %b %Y %H:%M:%S %Z")
pubdate_elem = item.find("pubDate")
pubdate_elem.text = current_time
return ET.tostring(root, encoding="unicode")
@pytest.fixture
@pytest.fixture()
def update_time_feed_2():
file = get_file("rss-ruanyifeng.xml")
root = ET.fromstring(file)
current_time = datetime.now(pytz.timezone("GMT")).strftime(
"%a, %d %b %Y %H:%M:%S %Z"
)
current_time = datetime.now(pytz.timezone("GMT")).strftime("%a, %d %b %Y %H:%M:%S %Z")
published_element = root.find(".//{*}published")
published_element.text = current_time
return ET.tostring(root, encoding="unicode")
@@ -74,9 +70,7 @@ async def test_fetch_new_1(
):
## 标题重复的情况
rss_router = respx.get("https://rsshub.app/twitter/user/ArknightsStaff")
rss_router.mock(
return_value=Response(200, text=get_file("rss-twitter-ArknightsStaff-0.xml"))
)
rss_router.mock(return_value=Response(200, text=get_file("rss-twitter-ArknightsStaff-0.xml")))
target = "https://rsshub.app/twitter/user/ArknightsStaff"
res1 = await rss.fetch_new_post(target, [user_info_factory([], [])])
assert len(res1) == 0
@@ -88,7 +82,9 @@ async def test_fetch_new_1(
assert post1.url == "https://twitter.com/ArknightsStaff/status/1659091539023282178"
assert (
post1.text
== "【#統合戦略】 引き続き新テーマ「ミヅキと紺碧の樹」の新要素及びシステムの変更点を一部ご紹介します! 今回は「灯火」、「ダイス」、「記号認識」、「鍵」についてです。詳細は添付の画像をご確認ください。#アークナイツ https://t.co/ARmptV0Zvu"
== "【#統合戦略】 引き続き新テーマ「ミヅキと紺碧の樹」の新要素及びシステムの変更点を一部ご紹介します!"
" 今回は「灯火」、「ダイス」、「記号認識」、「鍵」についてです。詳細は添付の画像をご確認ください。"
"#アークナイツ https://t.co/ARmptV0Zvu"
)
@@ -111,16 +107,16 @@ async def test_fetch_new_2(
assert len(res2[0][1]) == 1
post1 = res2[0][1][0]
assert post1.url == "http://www.ruanyifeng.com/blog/2023/05/weekly-issue-255.html"
assert post1.text == "科技爱好者周刊(第 255 期):对待 AI 的正确态度\n\n这里记录每周值得分享的科技内容,周五发布。..."
assert (
post1.text == "科技爱好者周刊(第 255 期):对待 AI 的正确态度\n\n这里记录每周值得分享的科技内容,周五发布。..."
)
@pytest.fixture
@pytest.fixture()
def update_time_feed_3():
file = get_file("rss-github-atom.xml")
root = ET.fromstring(file)
current_time = datetime.now(pytz.timezone("GMT")).strftime(
"%a, %d %b %Y %H:%M:%S %Z"
)
current_time = datetime.now(pytz.timezone("GMT")).strftime("%a, %d %b %Y %H:%M:%S %Z")
published_element = root.findall(".//{*}updated")[1]
published_element.text = current_time
return ET.tostring(root, encoding="unicode")