File: test_people.py

package info (click to toggle)
python-xbox-webapi 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,916 kB
  • sloc: python: 4,973; makefile: 79
file content (81 lines) | stat: -rw-r--r-- 2,605 bytes parent folder | download | duplicates (2)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from httpx import Response
import pytest

from tests.common import get_response_json


@pytest.mark.asyncio
async def test_people_friends_own(respx_mock, xbl_client):
    route = respx_mock.get("https://peoplehub.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_friends_own"))
    )
    ret = await xbl_client.people.get_friends_own()

    assert len(ret.people) == 2
    assert route.called


@pytest.mark.asyncio
async def test_people_friends_by_xuid(respx_mock, xbl_client):
    route = respx_mock.get("https://peoplehub.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_friends_by_xuid"))
    )
    ret = await xbl_client.people.get_friends_by_xuid("2669321029139235")

    assert len(ret.people) == 2
    assert route.called


@pytest.mark.asyncio
async def test_profiles_batch(respx_mock, xbl_client):
    route = respx_mock.post("https://peoplehub.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_batch"))
    )
    ret = await xbl_client.people.get_friends_own_batch(
        ["271958441785640", "277923030577271", "266932102913935"]
    )

    assert len(ret.people) == 3

    assert route.called


@pytest.mark.asyncio
async def test_people_recommendations(respx_mock, xbl_client):
    route = respx_mock.get("https://peoplehub.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_recommendations"))
    )
    ret = await xbl_client.people.get_friend_recommendations()

    assert ret.recommendation_summary.friend_of_friend == 20
    assert route.called


@pytest.mark.asyncio
async def test_people_summary_own(respx_mock, xbl_client):
    route = respx_mock.get("https://social.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_summary_own"))
    )
    await xbl_client.people.get_friends_summary_own()

    assert route.called


@pytest.mark.asyncio
async def test_people_summary_by_xuid(respx_mock, xbl_client):
    route = respx_mock.get("https://social.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_summary_by_xuid"))
    )
    await xbl_client.people.get_friends_summary_by_xuid("2669321029139235")

    assert route.called


@pytest.mark.asyncio
async def test_people_summary_by_gamertag(respx_mock, xbl_client):
    route = respx_mock.get("https://social.xboxlive.com").mock(
        return_value=Response(200, json=get_response_json("people_summary_by_gamertag"))
    )
    await xbl_client.people.get_friends_summary_by_gamertag("e")

    assert route.called