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.py68
1 files changed, 67 insertions, 1 deletions
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py
index 6c61355..d24ea28 100644
--- a/tests/test_pandora/test_client.py
+++ b/tests/test_pandora/test_client.py
@@ -1,7 +1,7 @@
1from unittest import TestCase 1from unittest import TestCase
2 2
3from pandora import errors 3from pandora import errors
4from pandora.models.pandora import AdItem 4from pandora.models.pandora import AdItem, AdditionalAudioUrl
5from pandora.client import APIClient, BaseAPIClient 5from pandora.client import APIClient, BaseAPIClient
6from pandora.py2compat import Mock, call, patch 6from pandora.py2compat import Mock, call, patch
7from tests.test_pandora.test_models import TestAdItem 7from tests.test_pandora.test_models import TestAdItem
@@ -87,6 +87,7 @@ class TestCallingAPIClient(TestCase):
87 client.get_playlist('token_mock') 87 client.get_playlist('token_mock')
88 88
89 playlist_mock.assert_has_calls([call("station.getPlaylist", 89 playlist_mock.assert_has_calls([call("station.getPlaylist",
90 additionalAudioUrl='',
90 audioAdPodCapable=True, 91 audioAdPodCapable=True,
91 includeTrackLength=True, 92 includeTrackLength=True,
92 stationToken='token_mock', 93 stationToken='token_mock',
@@ -186,3 +187,68 @@ class TestCreatingGenreStation(TestCase):
186 client = APIClient(Mock(), None, None, None, None) 187 client = APIClient(Mock(), None, None, None, None)
187 station = client.get_genre_stations() 188 station = client.get_genre_stations()
188 self.assertEqual(station.checksum, "foo") 189 self.assertEqual(station.checksum, "foo")
190
191
192class TestAdditionalUrls(TestCase):
193
194 def test_non_iterable_string(self):
195 with self.assertRaises(TypeError):
196 transport = Mock(side_effect=[errors.InvalidAuthToken(), None])
197
198 client = APIClient(transport, None, None, None, None)
199 client._authenticate = Mock()
200
201 client.get_playlist('token_mock', additional_urls='')
202
203 def test_non_iterable_other(self):
204 with self.assertRaises(TypeError):
205 transport = Mock(side_effect=[errors.InvalidAuthToken(), None])
206
207 client = APIClient(transport, None, None, None, None)
208 client._authenticate = Mock()
209
210 client.get_playlist('token_mock',
211 additional_urls=AdditionalAudioUrl.HTTP_32_WMA)
212
213 def test_without_enum(self):
214 with patch.object(APIClient, '__call__') as playlist_mock:
215 transport = Mock(side_effect=[errors.InvalidAuthToken(), None])
216
217 client = APIClient(transport, None, None, None, None)
218 client._authenticate = Mock()
219
220 urls = ['HTTP_128_MP3',
221 'HTTP_24_AACPLUS_ADTS']
222
223 desired = 'HTTP_128_MP3,HTTP_24_AACPLUS_ADTS'
224
225 client.get_playlist('token_mock', additional_urls=urls)
226
227 playlist_mock.assert_has_calls([call("station.getPlaylist",
228 additionalAudioUrl=desired,
229 audioAdPodCapable=True,
230 includeTrackLength=True,
231 stationToken='token_mock',
232 xplatformAdCapable=True)])
233
234
235 def test_with_enum(self):
236 with patch.object(APIClient, '__call__') as playlist_mock:
237 transport = Mock(side_effect=[errors.InvalidAuthToken(), None])
238
239 client = APIClient(transport, None, None, None, None)
240 client._authenticate = Mock()
241
242 urls = [AdditionalAudioUrl.HTTP_128_MP3,
243 AdditionalAudioUrl.HTTP_24_AACPLUS_ADTS]
244
245 desired = 'HTTP_128_MP3,HTTP_24_AACPLUS_ADTS'
246
247 client.get_playlist('token_mock', additional_urls=urls)
248
249 playlist_mock.assert_has_calls([call("station.getPlaylist",
250 additionalAudioUrl=desired,
251 audioAdPodCapable=True,
252 includeTrackLength=True,
253 stationToken='token_mock',
254 xplatformAdCapable=True)])