mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-24 23:33:32 +00:00
✨ Add recognizes the region of a genshin player ID for a game biz
This commit is contained in:
parent
f61f2951a5
commit
5f5ce47a8e
@ -115,3 +115,12 @@ def recognize_server(player_id: int, game: Game) -> str:
|
||||
if game == Game.STARRAIL:
|
||||
return recognize_starrail_server(player_id)
|
||||
raise ValueError(f"{game} is not a valid game")
|
||||
|
||||
|
||||
def recognize_genshin_game_biz(game_uid: int) -> str:
|
||||
"""Recognizes the region of a player ID for a game biz.
|
||||
|
||||
Returns:
|
||||
str: The game biz the player ID belongs to.
|
||||
"""
|
||||
return "hk4e_cn" if game_uid < 600000000 else "hk4e_global"
|
||||
|
@ -5,7 +5,7 @@ import pytest_asyncio
|
||||
|
||||
from simnet.client.components.auth import AuthClient
|
||||
from simnet.utils.enum_ import Region
|
||||
from simnet.utils.player import recognize_genshin_server
|
||||
from simnet.utils.player import recognize_genshin_server, recognize_genshin_game_biz
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from simnet.client.cookies import Cookies
|
||||
@ -25,8 +25,11 @@ async def auth_client(account_id: int, region: "Region", cookies: "Cookies"):
|
||||
class TestAuthClient:
|
||||
@staticmethod
|
||||
async def test_get_hk4e_token_by_cookie_token(auth_client: "AuthClient", genshin_player_id: int):
|
||||
if genshin_player_id is None:
|
||||
pytest.skip("Test case test_get_hk4e_token_by_cookie_token skipped: No genshin player id set.")
|
||||
game_biz = recognize_genshin_game_biz(genshin_player_id)
|
||||
await auth_client.get_hk4e_token_by_cookie_token(
|
||||
"hk4e_cn", recognize_genshin_server(genshin_player_id), player_id=genshin_player_id
|
||||
game_biz, recognize_genshin_server(genshin_player_id), player_id=genshin_player_id
|
||||
)
|
||||
hk4e_token = auth_client.client.cookies.get("e_hk4e_token")
|
||||
assert hk4e_token is not None
|
||||
|
Loading…
Reference in New Issue
Block a user