update arknights

This commit is contained in:
felinae98 2021-11-17 22:46:09 +08:00
parent 4aae3a8c6f
commit 7cbf509635
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 12 additions and 45 deletions

View File

@ -23,17 +23,27 @@ def arknights_list_0():
def arknights_list_1():
return get_json('arknights_list_1.json')
@pytest.fixture(scope='module')
def monster_siren_list_0():
return get_json('monster-siren_list_0.json')
@pytest.fixture(scope='module')
def monster_siren_list_1():
return get_json('monster-siren_list_1.json')
@pytest.mark.asyncio
@respx.mock
async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, arknights_list_1):
async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, arknights_list_1, monster_siren_list_0, monster_siren_list_1):
ak_list_router = respx.get("https://ak-conf.hypergryph.com/config/prod/announce_meta/IOS/announcement.meta.json")
detail_router = respx.get("https://ak-fs.hypergryph.com/announce/IOS/announcement/675.html")
version_router = respx.get('https://ak-conf.hypergryph.com/config/prod/official/IOS/version')
preannouncement_router = respx.get('https://ak-conf.hypergryph.com/config/prod/announce_meta/IOS/preannouncement.meta.json')
monster_siren_router = respx.get("https://monster-siren.hypergryph.com/api/news")
ak_list_router.mock(return_value=Response(200, json=arknights_list_0))
detail_router.mock(return_value=Response(200, text=get_file('arknights-detail-675.html')))
version_router.mock(return_value=Response(200, json=get_json('arknights-version-0.json')))
preannouncement_router.mock(return_value=Response(200, json=get_json('arknights-pre-0.json')))
monster_siren_router.mock(return_value=Response(200, json=monster_siren_list_0))
target = ''
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
assert(ak_list_router.called)
@ -51,4 +61,5 @@ async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, arknig
assert(post.target_name == '明日方舟游戏内公告')
assert(len(post.pics) == 1)
assert(post.pics == ['https://ak-fs.hypergryph.com/announce/images/20210623/e6f49aeb9547a2278678368a43b95b07.jpg'])
print(res3[0][1])
r = await post.generate_messages()

View File

@ -1,44 +0,0 @@
import pytest
import typing
import respx
from httpx import Response
import feedparser
if typing.TYPE_CHECKING:
import sys
sys.path.append('./src/plugins')
import nonebot_bison
from .utils import get_json, get_file
@pytest.fixture
def monster_siren(plugin_module: 'nonebot_bison'):
return plugin_module.platform.platform_manager['monster-siren']
@pytest.fixture(scope='module')
def monster_siren_list_0():
return get_json('monster-siren_list_0.json')
@pytest.fixture(scope='module')
def monster_siren_list_1():
return get_json('monster-siren_list_1.json')
@pytest.mark.asyncio
@respx.mock
async def test_fetch_new(monster_siren, dummy_user_subinfo, monster_siren_list_0, monster_siren_list_1):
ak_list_router = respx.get("https://monster-siren.hypergryph.com/api/news")
ak_list_router.mock(return_value=Response(200, json=monster_siren_list_0))
target = ''
res = await monster_siren.fetch_new_post(target, [dummy_user_subinfo])
assert(ak_list_router.called)
assert(len(res) == 0)
mock_data = monster_siren_list_1
ak_list_router.mock(return_value=Response(200, json=mock_data))
res3 = await monster_siren.fetch_new_post(target, [dummy_user_subinfo])
assert(len(res3[0][1]) == 1)
post = res3[0][1][0]
assert(post.target_type == 'monster-siren')
assert(post.text == '#D.D.D.PHOTO')
assert(post.url == 'https://monster-siren.hypergryph.com/info/241303')
assert(post.target_name == '塞壬唱片新闻')
assert(len(post.pics) == 0)