mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 12:02:16 +00:00
8f424bf0d4
♻️ 重构插件系统 ⚙️ 重写插件 🎨 改进代码结构 📝 完善文档 Co-authored-by: zhxy-CN <admin@owo.cab> Co-authored-by: 洛水居室 <luoshuijs@outlook.com> Co-authored-by: xtaodada <xtao@xtaolink.cn> Co-authored-by: Li Chuangbo <im@chuangbo.li>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import unittest
|
|
from unittest import IsolatedAsyncioTestCase
|
|
|
|
from modules.apihelper.hyperion import Hyperion
|
|
|
|
|
|
class TestGame(IsolatedAsyncioTestCase):
|
|
|
|
def setUp(self):
|
|
self.hyperion = Hyperion()
|
|
|
|
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:
|
|
post_full_in_collection = await self.hyperion.get_post_full_in_collection(_collection_id)
|
|
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 ""
|
|
|
|
for index, _ in enumerate(test_collection_id_list):
|
|
second = test_result[index]
|
|
first = await get_post_id(test_collection_id_list[index], second)
|
|
self.assertEqual(first, second)
|
|
|
|
async def asyncTearDown(self) -> None:
|
|
await self.hyperion.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|