forked from andrew0/SiriusXM
-
Notifications
You must be signed in to change notification settings - Fork 11
/
conftest.py
41 lines (28 loc) · 1.1 KB
/
conftest.py
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
import asyncio
import json
import pathlib
from unittest.mock import MagicMock
import pytest
from sxm import SXMClient
BASE_DIR = pathlib.Path(__file__).parent.absolute()
SAMPLE_DIR = BASE_DIR / "tests" / "sample_data"
@pytest.fixture
def xm_channels_response():
with open(SAMPLE_DIR / "xm_channels.json", "r") as json_file:
xm_channels_response = json.load(json_file)
return xm_channels_response["moduleList"]["modules"][0]["moduleResponse"][
"contentData"
]["channelListing"]["channels"]
@pytest.fixture
def xm_live_channel_response():
with open(SAMPLE_DIR / "xm_live_channel.json", "r") as json_file:
xm_live_channel_response = json.load(json_file)
return xm_live_channel_response
@pytest.fixture
def sxm_client(xm_channels_response, xm_live_channel_response):
sxm = SXMClient("user", "password", region="US")
get_channels = MagicMock(return_value=xm_channels_response)
sxm.get_channels = get_channels
sxm.get_now_playing = MagicMock(return_value=xm_live_channel_response)
sxm.async_client.get_channels = asyncio.coroutine(get_channels)
return sxm