aboutsummaryrefslogtreecommitdiff
path: root/tests/test_pydora/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_pydora/test_utils.py')
-rw-r--r--tests/test_pydora/test_utils.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/tests/test_pydora/test_utils.py b/tests/test_pydora/test_utils.py
index fc33a40..9d3bc78 100644
--- a/tests/test_pydora/test_utils.py
+++ b/tests/test_pydora/test_utils.py
@@ -10,23 +10,26 @@ from pydora.utils import iterate_forever
10 10
11 11
12class TestIterateForever(TestCase): 12class TestIterateForever(TestCase):
13
14 def setUp(self): 13 def setUp(self):
15 self.transport = Mock(side_effect=[InvalidAuthToken(), None]) 14 self.transport = Mock(side_effect=[InvalidAuthToken(), None])
16 self.client = APIClient(self.transport, None, None, None, None) 15 self.client = APIClient(self.transport, None, None, None, None)
17 self.client._authenticate = Mock() 16 self.client._authenticate = Mock()
18 17
19 def test_handle_missing_params_exception_due_to_missing_ad_tokens(self): 18 def test_handle_missing_params_exception_due_to_missing_ad_tokens(self):
20 with patch.object(APIClient, 'get_playlist') as get_playlist_mock: 19 with patch.object(APIClient, "get_playlist") as get_playlist_mock:
21 admock = patch.object( 20 admock = patch.object(
22 APIClient, 'register_ad', 21 APIClient,
23 side_effect=ParameterMissing("ParameterMissing")) 22 "register_ad",
23 side_effect=ParameterMissing("ParameterMissing"),
24 )
24 25
25 with admock: 26 with admock:
26 station = Station.from_json( 27 station = Station.from_json(
27 self.client, {'stationToken': 'token_mock'}) 28 self.client, {"stationToken": "token_mock"}
29 )
28 ad_mock = AdItem.from_json( 30 ad_mock = AdItem.from_json(
29 self.client, {'station_id': 'id_mock'}) 31 self.client, {"station_id": "id_mock"}
32 )
30 get_playlist_mock.return_value = iter([ad_mock]) 33 get_playlist_mock.return_value = iter([ad_mock])
31 34
32 station_iter = iterate_forever(station.get_playlist) 35 station_iter = iterate_forever(station.get_playlist)
@@ -36,15 +39,19 @@ class TestIterateForever(TestCase):
36 39
37 def test_reraise_missing_params_exception(self): 40 def test_reraise_missing_params_exception(self):
38 plmock = patch.object( 41 plmock = patch.object(
39 APIClient, 'get_playlist', 42 APIClient,
40 side_effect=ParameterMissing("ParameterMissing")) 43 "get_playlist",
44 side_effect=ParameterMissing("ParameterMissing"),
45 )
41 46
42 with plmock as get_playlist_mock: 47 with plmock as get_playlist_mock:
43 with self.assertRaises(ParameterMissing): 48 with self.assertRaises(ParameterMissing):
44 station = Station.from_json( 49 station = Station.from_json(
45 self.client, {'stationToken': 'token_mock'}) 50 self.client, {"stationToken": "token_mock"}
51 )
46 track_mock = PlaylistItem.from_json( 52 track_mock = PlaylistItem.from_json(
47 self.client, {'token': 'token_mock'}) 53 self.client, {"token": "token_mock"}
54 )
48 get_playlist_mock.return_value = iter([track_mock]) 55 get_playlist_mock.return_value = iter([track_mock])
49 56
50 station_iter = iterate_forever(station.get_playlist) 57 station_iter = iterate_forever(station.get_playlist)