aboutsummaryrefslogtreecommitdiff
path: root/tests/test_pandora/test_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_pandora/test_client.py')
-rw-r--r--tests/test_pandora/test_client.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py
index 8d93e4c..f88b755 100644
--- a/tests/test_pandora/test_client.py
+++ b/tests/test_pandora/test_client.py
@@ -65,13 +65,12 @@ class TestCallingAPIClient(TestCase):
65 transport.assert_has_calls([call("method"), call("method")]) 65 transport.assert_has_calls([call("method"), call("method")])
66 66
67 def test_playlist_fetches_ads(self): 67 def test_playlist_fetches_ads(self):
68 fake_playlist = { "items": [ 68 fake_playlist = {"items": [
69 { "songName": "test" }, 69 {"songName": "test"},
70 { "adToken": "foo" }, 70 {"adToken": "foo"},
71 { "songName": "test" }, 71 {"songName": "test"},
72 ]} 72 ]}
73 with patch.object( 73 with patch.object(APIClient, '__call__', return_value=fake_playlist):
74 APIClient, '__call__', return_value=fake_playlist) as mock:
75 client = APIClient(Mock(), None, None, None, None) 74 client = APIClient(Mock(), None, None, None, None)
76 client._authenticate = Mock() 75 client._authenticate = Mock()
77 76
@@ -88,10 +87,10 @@ class TestCallingAPIClient(TestCase):
88 client.get_playlist('token_mock') 87 client.get_playlist('token_mock')
89 88
90 playlist_mock.assert_has_calls([call("station.getPlaylist", 89 playlist_mock.assert_has_calls([call("station.getPlaylist",
91 audioAdPodCapable=True, 90 audioAdPodCapable=True,
92 includeTrackLength=True, 91 includeTrackLength=True,
93 stationToken='token_mock', 92 stationToken='token_mock',
94 xplatformAdCapable=True)]) 93 xplatformAdCapable=True)])
95 94
96 95
97class TestGettingQualities(TestCase): 96class TestGettingQualities(TestCase):
@@ -118,8 +117,10 @@ class TestGettingQualities(TestCase):
118class TestGettingAds(TestCase): 117class TestGettingAds(TestCase):
119 118
120 def test_get_ad_item_(self): 119 def test_get_ad_item_(self):
121 with patch.object(APIClient, '__call__', 120 metamock = patch.object(
122 return_value=TestAdItem.JSON_DATA) as ad_metadata_mock: 121 APIClient, '__call__', return_value=TestAdItem.JSON_DATA)
122
123 with metamock as ad_metadata_mock:
123 transport = Mock(side_effect=[errors.InvalidAuthToken(), None]) 124 transport = Mock(side_effect=[errors.InvalidAuthToken(), None])
124 125
125 client = APIClient(transport, None, None, None, None) 126 client = APIClient(transport, None, None, None, None)
@@ -129,10 +130,9 @@ class TestGettingAds(TestCase):
129 assert ad_item.station_id == 'id_mock' 130 assert ad_item.station_id == 'id_mock'
130 assert ad_item.ad_token == 'token_mock' 131 assert ad_item.ad_token == 'token_mock'
131 132
132 ad_metadata_mock.assert_has_calls([call("ad.getAdMetadata", 133 ad_metadata_mock.assert_has_calls([
133 adToken='token_mock', 134 call("ad.getAdMetadata", adToken='token_mock',
134 returnAdTrackingTokens=True, 135 returnAdTrackingTokens=True, supportAudioAds=True)])
135 supportAudioAds=True)])
136 136
137 def test_get_ad_item_with_no_station_id_specified_raises_exception(self): 137 def test_get_ad_item_with_no_station_id_specified_raises_exception(self):
138 transport = Mock(side_effect=[errors.InvalidAuthToken(), None]) 138 transport = Mock(side_effect=[errors.InvalidAuthToken(), None])
@@ -175,7 +175,7 @@ class TestCreatingGenreStation(TestCase):
175 def test_has_initial_checksum(self): 175 def test_has_initial_checksum(self):
176 fake_data = { 176 fake_data = {
177 "categories": [ 177 "categories": [
178 { "categoryName": "foo", "stations": [] }, 178 {"categoryName": "foo", "stations": []},
179 ], 179 ],
180 180
181 # Not actually part of the genre station response but is needed to 181 # Not actually part of the genre station response but is needed to