Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpers/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def get_user_details(labs_id: int | str) -> dict:

async def get_season_rank(htb_uid: int) -> str | None:
"""Get season rank from HTB."""
season_api_url = f"{settings.API_V4_URL}/season/end/{settings.SEASON_ID}/{htb_uid}"
season_api_url = f"{settings.API_V4_URL}/user/achievement/season/{htb_uid}/{settings.SEASON_ID}"

async with get_labs_session() as session:
async with session.get(season_api_url) as r:
Expand Down
32 changes: 31 additions & 1 deletion tests/src/helpers/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,40 @@
import pytest

from src.core import settings
from src.helpers.verification import get_user_details, process_labs_identification
from src.helpers.verification import get_season_rank, get_user_details, process_labs_identification
from tests.helpers import MockRoleManager


class TestGetSeasonRank(unittest.IsolatedAsyncioTestCase):
@pytest.mark.asyncio
async def test_get_season_rank_success(self):
htb_uid = 12345

with aioresponses.aioresponses() as m:
m.get(
f"{settings.API_V4_URL}/user/achievement/season/{htb_uid}/{settings.SEASON_ID}",
status=200,
payload={"data": {"season": {"tier": "Gold"}}},
)

result = await get_season_rank(htb_uid)
self.assertEqual(result, "Gold")

@pytest.mark.asyncio
async def test_get_season_rank_empty_data(self):
htb_uid = 12345

with aioresponses.aioresponses() as m:
m.get(
f"{settings.API_V4_URL}/user/achievement/season/{htb_uid}/{settings.SEASON_ID}",
status=200,
payload={"data": None},
)

result = await get_season_rank(htb_uid)
self.assertIsNone(result)


class TestGetUserDetails(unittest.IsolatedAsyncioTestCase):
@pytest.mark.asyncio
async def test_get_user_details_success(self):
Expand Down