2022-05-30 09:21:21 +00:00
|
|
|
import unittest
|
|
|
|
from unittest import IsolatedAsyncioTestCase
|
|
|
|
|
2022-06-28 15:44:10 +00:00
|
|
|
from model.apihelper.hyperion import Hyperion
|
2022-05-30 09:21:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestGame(IsolatedAsyncioTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2022-06-01 03:46:26 +00:00
|
|
|
self.hyperion = Hyperion()
|
2022-05-30 09:21:21 +00:00
|
|
|
|
|
|
|
async def test_get_strategy(self):
|
|
|
|
test_collection_id_list = [839176, 839179, 839181]
|
|
|
|
test_result = ["温迪", "胡桃", "雷电将军"]
|
|
|
|
|
|
|
|
async def get_post_id(_collection_id: int, character_name: str) -> str:
|
2022-06-01 03:46:26 +00:00
|
|
|
post_full_in_collection = await self.hyperion.get_post_full_in_collection(_collection_id)
|
2022-05-30 09:21:21 +00:00
|
|
|
if post_full_in_collection.error:
|
|
|
|
raise RuntimeError(f"获取收藏信息错误,错误信息为:{post_full_in_collection.message}")
|
|
|
|
for post_data in post_full_in_collection.data["posts"]:
|
|
|
|
topics = post_data["topics"]
|
|
|
|
for topic in topics:
|
|
|
|
if character_name == topic["name"]:
|
|
|
|
return topic["name"]
|
|
|
|
return ""
|
|
|
|
|
2022-06-09 12:14:07 +00:00
|
|
|
for index, _ in enumerate(test_collection_id_list):
|
2022-05-30 09:21:21 +00:00
|
|
|
second = test_result[index]
|
|
|
|
first = await get_post_id(test_collection_id_list[index], second)
|
|
|
|
self.assertEqual(first, second)
|
|
|
|
|
|
|
|
async def asyncTearDown(self) -> None:
|
2022-06-01 03:46:26 +00:00
|
|
|
await self.hyperion.close()
|
2022-05-30 09:21:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2022-05-30 09:52:59 +00:00
|
|
|
unittest.main()
|