2023-05-08 01:21:32 +00:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
import pytest_asyncio
|
|
|
|
|
|
|
|
from simnet.client.components.chronicle.genshin import GenshinBattleChronicleClient
|
|
|
|
from simnet.models.genshin.chronicle.stats import FullGenshinUserStats, Stats
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from simnet.client.cookies import Cookies
|
2023-12-27 07:09:24 +00:00
|
|
|
from simnet.utils.enums import Region
|
2023-05-08 01:21:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest_asyncio.fixture
|
2023-05-12 03:01:53 +00:00
|
|
|
async def genshin_client(genshin_player_id: int, account_id: int, region: "Region", cookies: "Cookies"):
|
2023-05-12 03:36:03 +00:00
|
|
|
if genshin_player_id is None:
|
2023-05-12 03:53:07 +00:00
|
|
|
pytest.skip("Test case test_genshin_battle_chronicle_client skipped: No genshin player id set.")
|
2023-05-08 01:21:32 +00:00
|
|
|
async with GenshinBattleChronicleClient(
|
|
|
|
player_id=genshin_player_id,
|
|
|
|
cookies=cookies,
|
|
|
|
account_id=account_id,
|
2023-05-12 03:01:53 +00:00
|
|
|
region=region,
|
2023-05-08 01:21:32 +00:00
|
|
|
) as client_instance:
|
|
|
|
yield client_instance
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
class TestGenshinBattleChronicleClient:
|
|
|
|
@staticmethod
|
|
|
|
async def test_get_battle_chronicle(genshin_client: GenshinBattleChronicleClient):
|
|
|
|
user = await genshin_client.get_genshin_user()
|
|
|
|
assert user.stats.days_active >= 0
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def test_get_full_genshin_user(genshin_client: GenshinBattleChronicleClient):
|
|
|
|
user = await genshin_client.get_full_genshin_user()
|
|
|
|
assert isinstance(user, FullGenshinUserStats)
|
|
|
|
assert isinstance(user.stats, Stats)
|
|
|
|
|
|
|
|
@staticmethod
|
2023-05-12 03:01:53 +00:00
|
|
|
async def test_get_partial_genshin_user(genshin_client: GenshinBattleChronicleClient):
|
2023-05-08 01:21:32 +00:00
|
|
|
user = await genshin_client.get_partial_genshin_user()
|
|
|
|
assert user.stats.days_active >= 0
|
2023-05-11 08:39:04 +00:00
|
|
|
|
|
|
|
@staticmethod
|
2023-05-12 03:01:53 +00:00
|
|
|
async def test_get_genshin_characters(genshin_client: GenshinBattleChronicleClient):
|
2023-05-11 08:39:04 +00:00
|
|
|
characters = await genshin_client.get_genshin_characters()
|
|
|
|
assert len(characters) > 0
|
|
|
|
for character in characters:
|
|
|
|
assert character.id
|
|
|
|
assert character.level
|
2024-07-01 15:03:26 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def test_get_genshin_imaginarium_theater(genshin_client: GenshinBattleChronicleClient):
|
|
|
|
data = await genshin_client.get_genshin_imaginarium_theater()
|
|
|
|
assert len(data.data) > 0
|