From 54fe5afa969978395063bac8d53305f673c800f8 Mon Sep 17 00:00:00 2001 From: Phong Tran <540580+phongse@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:30:11 +0200 Subject: [PATCH 1/2] fix: clues hiscores --- pyosrs/models.py | 14 +++++++------- tests/pyosrs/client_test.py | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/pyosrs/models.py b/pyosrs/models.py index c2abaf4..2c9912a 100644 --- a/pyosrs/models.py +++ b/pyosrs/models.py @@ -54,13 +54,13 @@ class Minigames(BaseModel): class Clues(BaseModel): - all: Minigame = Minigame() - beginner: Minigame = Minigame() - easy: Minigame = Minigame() - medium: Minigame = Minigame() - hard: Minigame = Minigame() - elite: Minigame = Minigame() - master: Minigame = Minigame() + clue_scrolls_all: Minigame = Minigame() + clue_scrolls_beginner: Minigame = Minigame() + clue_scrolls_easy: Minigame = Minigame() + clue_scrolls_medium: Minigame = Minigame() + clue_scrolls_hard: Minigame = Minigame() + clue_scrolls_elite: Minigame = Minigame() + clue_scrolls_master: Minigame = Minigame() class Bosses(BaseModel): diff --git a/tests/pyosrs/client_test.py b/tests/pyosrs/client_test.py index d8c3026..dd6049a 100644 --- a/tests/pyosrs/client_test.py +++ b/tests/pyosrs/client_test.py @@ -63,6 +63,30 @@ async def test_get_hiscore(): assert iron_hyger.combat_level == 126 +@pytest.mark.asyncio +async def test_clues_hiscore(): + hiscore_mock["get_hiscore"].mock( + side_effect=[ + httpx.Response( + status_code=200, text=testing.api_responses.LYNX_TITAN_RESPONSE + ) + ] + ) + async with hiscore_mock: + async with Pyosrs() as client: + lynx_titan = await client.get_hiscore("Lynx Titan") + + assert lynx_titan.clues.dict() == { + "clue_scrolls_all": {"rank": 751176, "score": 22}, + "clue_scrolls_beginner": {"rank": -1, "score": -1}, + "clue_scrolls_easy": {"rank": -1, "score": -1}, + "clue_scrolls_medium": {"rank": -1, "score": -1}, + "clue_scrolls_hard": {"rank": 472813, "score": 22}, + "clue_scrolls_elite": {"rank": -1, "score": -1}, + "clue_scrolls_master": {"rank": -1, "score": -1}, + } + + @pytest.mark.asyncio async def test_get_hiscore_with_invalid_username(): async with hiscore_mock: From ecbb03807ccb833ba34dc63e8cfd4526232fc317 Mon Sep 17 00:00:00 2001 From: Phong Tran <540580+phongse@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:46:41 +0200 Subject: [PATCH 2/2] rename clue keys --- pyosrs/enums.py | 14 +++++++------- pyosrs/models.py | 14 +++++++------- tests/pyosrs/client_test.py | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pyosrs/enums.py b/pyosrs/enums.py index 807021b..065dfb7 100644 --- a/pyosrs/enums.py +++ b/pyosrs/enums.py @@ -53,13 +53,13 @@ class GAME_MODE(Enum): } CLUES_INDEX: Final[Dict[int, Tuple[str, str]]] = { - 29: ("clue_scrolls_all", "Clue Scrolls All"), - 30: ("clue_scrolls_beginner", "Clue Scrolls Beginner"), - 31: ("clue_scrolls_easy", "Clue Scrolls Easy"), - 32: ("clue_scrolls_medium", "Clue Scrolls Medium"), - 33: ("clue_scrolls_hard", "Clue Scrolls Hard"), - 34: ("clue_scrolls_elite", "Clue Scrolls Elite"), - 35: ("clue_scrolls_master", "Clue Scrolls Master"), + 29: ("all", "Clue Scrolls All"), + 30: ("beginner", "Clue Scrolls Beginner"), + 31: ("easy", "Clue Scrolls Easy"), + 32: ("medium", "Clue Scrolls Medium"), + 33: ("hard", "Clue Scrolls Hard"), + 34: ("elite", "Clue Scrolls Elite"), + 35: ("master", "Clue Scrolls Master"), } BOSSES_INDEX: Final[Dict[int, Tuple[str, str]]] = { diff --git a/pyosrs/models.py b/pyosrs/models.py index 2c9912a..c2abaf4 100644 --- a/pyosrs/models.py +++ b/pyosrs/models.py @@ -54,13 +54,13 @@ class Minigames(BaseModel): class Clues(BaseModel): - clue_scrolls_all: Minigame = Minigame() - clue_scrolls_beginner: Minigame = Minigame() - clue_scrolls_easy: Minigame = Minigame() - clue_scrolls_medium: Minigame = Minigame() - clue_scrolls_hard: Minigame = Minigame() - clue_scrolls_elite: Minigame = Minigame() - clue_scrolls_master: Minigame = Minigame() + all: Minigame = Minigame() + beginner: Minigame = Minigame() + easy: Minigame = Minigame() + medium: Minigame = Minigame() + hard: Minigame = Minigame() + elite: Minigame = Minigame() + master: Minigame = Minigame() class Bosses(BaseModel): diff --git a/tests/pyosrs/client_test.py b/tests/pyosrs/client_test.py index dd6049a..96f829d 100644 --- a/tests/pyosrs/client_test.py +++ b/tests/pyosrs/client_test.py @@ -77,13 +77,13 @@ async def test_clues_hiscore(): lynx_titan = await client.get_hiscore("Lynx Titan") assert lynx_titan.clues.dict() == { - "clue_scrolls_all": {"rank": 751176, "score": 22}, - "clue_scrolls_beginner": {"rank": -1, "score": -1}, - "clue_scrolls_easy": {"rank": -1, "score": -1}, - "clue_scrolls_medium": {"rank": -1, "score": -1}, - "clue_scrolls_hard": {"rank": 472813, "score": 22}, - "clue_scrolls_elite": {"rank": -1, "score": -1}, - "clue_scrolls_master": {"rank": -1, "score": -1}, + "all": {"rank": 751176, "score": 22}, + "beginner": {"rank": -1, "score": -1}, + "easy": {"rank": -1, "score": -1}, + "medium": {"rank": -1, "score": -1}, + "hard": {"rank": 472813, "score": 22}, + "elite": {"rank": -1, "score": -1}, + "master": {"rank": -1, "score": -1}, }