This commit is contained in:
felinae98
2021-08-01 16:15:55 +08:00
parent 4f3325d988
commit 8e86fc7f02
6 changed files with 17 additions and 11 deletions
+4
View File
@@ -28,8 +28,12 @@ def arknights_list_1():
async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, arknights_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')
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')))
target = ''
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
assert(ak_list_router.called)
+4 -4
View File
@@ -259,12 +259,12 @@ def mock_status_change(plugin_module: 'nonebot_hk_reporter'):
else:
return {'s': False}
def compare_status(self, target, old_status, new_status) -> Optional['RawPost']:
def compare_status(self, target, old_status, new_status) -> list['RawPost']:
if old_status['s'] == False and new_status['s'] == True:
return {'text': 'on', 'cat': 1}
return [{'text': 'on', 'cat': 1}]
elif old_status['s'] == True and new_status['s'] == False:
return {'text': 'off', 'cat': 2}
return None
return [{'text': 'off', 'cat': 2}]
return []
async def parse(self, raw_post) -> 'Post':
return plugin_module.post.Post('mock_status', raw_post['text'], '')