File: test_profile.py

package info (click to toggle)
python-xbox-webapi 2.1.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,900 kB
  • sloc: python: 4,973; makefile: 79
file content (42 lines) | stat: -rw-r--r-- 1,213 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from httpx import Response
import pytest

from tests.common import get_response_json


@pytest.mark.asyncio
async def test_profile_by_xuid(respx_mock, xbl_client):
    route = respx_mock.get("https://profile.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("profile_by_xuid"))
    )
    ret = await xbl_client.profile.get_profile_by_xuid("2669321029139235")

    assert len(ret.profile_users) == 1

    assert route.called


@pytest.mark.asyncio
async def test_profile_by_gamertag(respx_mock, xbl_client):
    route = respx_mock.get("https://profile.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("profile_by_gamertag"))
    )
    ret = await xbl_client.profile.get_profile_by_gamertag("e")

    assert len(ret.profile_users) == 1

    assert route.called


@pytest.mark.asyncio
async def test_profiles_batch(respx_mock, xbl_client):
    route = respx_mock.post("https://profile.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("profile_batch"))
    )
    ret = await xbl_client.profile.get_profiles(
        ["2669321029139235", "2584878536129841"]
    )

    assert len(ret.profile_users) == 2

    assert route.called