diff options
Diffstat (limited to 'tests/test_pydora/test_utils.py')
-rw-r--r-- | tests/test_pydora/test_utils.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/test_pydora/test_utils.py b/tests/test_pydora/test_utils.py index 5334ff6..9900913 100644 --- a/tests/test_pydora/test_utils.py +++ b/tests/test_pydora/test_utils.py | |||
@@ -16,11 +16,16 @@ class TestIterateForever(TestCase): | |||
16 | 16 | ||
17 | def test_handle_missing_params_exception_due_to_missing_ad_tokens(self): | 17 | def test_handle_missing_params_exception_due_to_missing_ad_tokens(self): |
18 | with patch.object(APIClient, 'get_playlist') as get_playlist_mock: | 18 | with patch.object(APIClient, 'get_playlist') as get_playlist_mock: |
19 | with patch.object(APIClient, 'register_ad', side_effect=ParameterMissing("ParameterMissing")): | 19 | admock = patch.object( |
20 | APIClient, 'register_ad', | ||
21 | side_effect=ParameterMissing("ParameterMissing")) | ||
20 | 22 | ||
21 | station = Station.from_json(self.client, {'stationToken': 'token_mock'}) | 23 | with admock: |
22 | ad_mock = AdItem.from_json(self.client, {'station_id': 'id_mock'}) | 24 | station = Station.from_json( |
23 | get_playlist_mock.return_value=iter([ad_mock]) | 25 | self.client, {'stationToken': 'token_mock'}) |
26 | ad_mock = AdItem.from_json( | ||
27 | self.client, {'station_id': 'id_mock'}) | ||
28 | get_playlist_mock.return_value = iter([ad_mock]) | ||
24 | 29 | ||
25 | station_iter = iterate_forever(station.get_playlist) | 30 | station_iter = iterate_forever(station.get_playlist) |
26 | 31 | ||
@@ -28,12 +33,17 @@ class TestIterateForever(TestCase): | |||
28 | self.assertEqual(ad_mock, next_track) | 33 | self.assertEqual(ad_mock, next_track) |
29 | 34 | ||
30 | def test_reraise_missing_params_exception(self): | 35 | def test_reraise_missing_params_exception(self): |
31 | with patch.object(APIClient, 'get_playlist', side_effect=ParameterMissing("ParameterMissing")) as get_playlist_mock: | 36 | plmock = patch.object( |
32 | with self.assertRaises(ParameterMissing): | 37 | APIClient, 'get_playlist', |
38 | side_effect=ParameterMissing("ParameterMissing")) | ||
33 | 39 | ||
34 | station = Station.from_json(self.client, {'stationToken': 'token_mock'}) | 40 | with plmock as get_playlist_mock: |
35 | track_mock = PlaylistItem.from_json(self.client, {'token': 'token_mock'}) | 41 | with self.assertRaises(ParameterMissing): |
36 | get_playlist_mock.return_value=iter([track_mock]) | 42 | station = Station.from_json( |
43 | self.client, {'stationToken': 'token_mock'}) | ||
44 | track_mock = PlaylistItem.from_json( | ||
45 | self.client, {'token': 'token_mock'}) | ||
46 | get_playlist_mock.return_value = iter([track_mock]) | ||
37 | 47 | ||
38 | station_iter = iterate_forever(station.get_playlist) | 48 | station_iter = iterate_forever(station.get_playlist) |
39 | next(station_iter) | 49 | next(station_iter) |