🎨 删除旧单元测试并修改部分测试

This commit is contained in:
洛水居室 2022-09-02 14:59:18 +08:00
parent 7095d975ac
commit 462013ac1e
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
3 changed files with 6 additions and 28 deletions

View File

@ -44,6 +44,9 @@ class ArtifactOcrRate:
def __init__(self): def __init__(self):
self.client = httpx.AsyncClient(headers=self.HEADERS) self.client = httpx.AsyncClient(headers=self.HEADERS)
async def close(self):
await self.client.aclose()
async def get_artifact_attr(self, photo_byte): async def get_artifact_attr(self, photo_byte):
b64_str = b64encode(photo_byte).decode() b64_str = b64encode(photo_byte).decode()
req = await self.client.post(self.OCR_URL, json={"image": b64_str}, timeout=8) req = await self.client.post(self.OCR_URL, json={"image": b64_str}, timeout=8)

View File

@ -21,6 +21,9 @@ class TestArtifact(IsolatedAsyncioTestCase):
{'type': 'cd', 'name': '暴击伤害', 'value': '10.9%'}]} {'type': 'cd', 'name': '暴击伤害', 'value': '10.9%'}]}
await self.artifact_rate.rate_artifact(artifact_attr) await self.artifact_rate.rate_artifact(artifact_attr)
async def asyncTearDown(self) -> None:
await self.artifact_rate.close()
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -1,28 +0,0 @@
import json
import unittest
from models.base import GameItem
from models.game.artifact import ArtifactInfo
class TestBase(unittest.TestCase):
def test_game_item(self):
test_dict = {"item_id": 0, "name": "攻击力", "type": "atk", "value": 2333}
test_json = json.dumps(test_dict)
test_game_item = GameItem(0, "攻击力", "atk", 2333)
new_json = test_game_item.to_json()
self.assertEqual(new_json, test_json)
def test_artifact(self):
test_dict = {"item_id": 0, "name": "测试花", "pos": "测试属性", "star": 2333,
"sub_item": [{"item_id": 0, "name": "攻击力", "type": "atk", "value": 2333}],
"main_item": {"item_id": 0, "name": "攻击力", "type": "atk", "value": 2333}, "level": 2333}
test_json = json.dumps(test_dict)
test_game_item = GameItem(0, "攻击力", "atk", 2333)
test_artifact = ArtifactInfo(0, "测试花", 2333, test_game_item, "测试属性", 2333, [test_game_item])
new_json = test_artifact.to_json()
self.assertEqual(test_json, new_json)
if __name__ == '__main__':
unittest.main()