diff options
author | jcass <john.cass77@gmail.com> | 2015-12-29 06:52:33 +0200 |
---|---|---|
committer | jcass <john.cass77@gmail.com> | 2015-12-29 06:52:33 +0200 |
commit | d26ea7a236dc9def54508bbb86712400e59666ed (patch) | |
tree | ba23f019990ffb6b0273eb338cb8cb138d6720e6 | |
parent | 6ca4d689b863aa1caed7d51f8b45951e508fe8bc (diff) | |
download | pydora-d26ea7a236dc9def54508bbb86712400e59666ed.tar.bz2 pydora-d26ea7a236dc9def54508bbb86712400e59666ed.tar.xz pydora-d26ea7a236dc9def54508bbb86712400e59666ed.zip |
Remove logger, align naming convention for test parameters.
-rw-r--r-- | pandora/transport.py | 6 | ||||
-rw-r--r-- | tests/test_pandora/test_client.py | 12 | ||||
-rw-r--r-- | tests/test_pandora/test_transport.py | 2 | ||||
-rw-r--r-- | tests/test_pydora/test_utils.py | 10 |
4 files changed, 12 insertions, 18 deletions
diff --git a/pandora/transport.py b/pandora/transport.py index d942ae5..5fef39e 100644 --- a/pandora/transport.py +++ b/pandora/transport.py | |||
@@ -23,8 +23,6 @@ from .errors import PandoraException | |||
23 | 23 | ||
24 | DEFAULT_API_HOST = "tuner.pandora.com/services/json/" | 24 | DEFAULT_API_HOST = "tuner.pandora.com/services/json/" |
25 | 25 | ||
26 | logger = logging.getLogger(__name__) | ||
27 | |||
28 | 26 | ||
29 | def retries(max_tries, exceptions=(Exception,)): | 27 | def retries(max_tries, exceptions=(Exception,)): |
30 | """Function decorator implementing retrying logic. | 28 | """Function decorator implementing retrying logic. |
@@ -234,13 +232,9 @@ class APITransport(object): | |||
234 | self._start_request(method) | 232 | self._start_request(method) |
235 | 233 | ||
236 | url = self._build_url(method) | 234 | url = self._build_url(method) |
237 | log_data = data | ||
238 | data = self._build_data(method, data) | 235 | data = self._build_data(method, data) |
239 | params = self._build_params(method) | 236 | params = self._build_params(method) |
240 | logger.info('TRANSPORT: \nMETHOD: {}\nPARAMS: {}\nDATA: {}\nURL: {}' | ||
241 | .format(method, params, log_data, url)) | ||
242 | result = self._make_http_request(url, data, params) | 237 | result = self._make_http_request(url, data, params) |
243 | logger.info('TRANSPORT: \nRESULT: {}\n'.format(result)) | ||
244 | 238 | ||
245 | return self._parse_response(result) | 239 | return self._parse_response(result) |
246 | 240 | ||
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py index 69fb632..58fca74 100644 --- a/tests/test_pandora/test_client.py +++ b/tests/test_pandora/test_client.py | |||
@@ -64,12 +64,12 @@ class TestCallingAPIClient(TestCase): | |||
64 | client = APIClient(transport, None, None, None, None) | 64 | client = APIClient(transport, None, None, None, None) |
65 | client._authenticate = Mock() | 65 | client._authenticate = Mock() |
66 | 66 | ||
67 | client.get_playlist('mock_token') | 67 | client.get_playlist('token_mock') |
68 | 68 | ||
69 | playlist_mock.assert_has_calls([call("station.getPlaylist", | 69 | playlist_mock.assert_has_calls([call("station.getPlaylist", |
70 | audioAdPodCapable=True, | 70 | audioAdPodCapable=True, |
71 | includeTrackLength=True, | 71 | includeTrackLength=True, |
72 | stationToken='mock_token', | 72 | stationToken='token_mock', |
73 | xplatformAdCapable=True)]) | 73 | xplatformAdCapable=True)]) |
74 | 74 | ||
75 | 75 | ||
@@ -103,11 +103,11 @@ class TestGettingAds(TestCase): | |||
103 | client = APIClient(transport, None, None, None, None) | 103 | client = APIClient(transport, None, None, None, None) |
104 | client._authenticate = Mock() | 104 | client._authenticate = Mock() |
105 | 105 | ||
106 | ad_item = client.get_ad_item('mock_id', 'mock_token') | 106 | ad_item = client.get_ad_item('id_mock', 'token_mock') |
107 | assert ad_item.station_id == 'mock_id' | 107 | assert ad_item.station_id == 'id_mock' |
108 | 108 | ||
109 | ad_metadata_mock.assert_has_calls([call("ad.getAdMetadata", | 109 | ad_metadata_mock.assert_has_calls([call("ad.getAdMetadata", |
110 | adToken='mock_token', | 110 | adToken='token_mock', |
111 | returnAdTrackingTokens=True, | 111 | returnAdTrackingTokens=True, |
112 | supportAudioAds=True)]) | 112 | supportAudioAds=True)]) |
113 | 113 | ||
@@ -117,4 +117,4 @@ class TestGettingAds(TestCase): | |||
117 | client = APIClient(transport, None, None, None, None) | 117 | client = APIClient(transport, None, None, None, None) |
118 | client.get_ad_metadata = Mock() | 118 | client.get_ad_metadata = Mock() |
119 | 119 | ||
120 | self.assertRaises(ParameterMissing, client.get_ad_item, '', 'mock_token') | 120 | self.assertRaises(ParameterMissing, client.get_ad_item, '', 'token_mock') |
diff --git a/tests/test_pandora/test_transport.py b/tests/test_pandora/test_transport.py index 59d4cea..6596a0e 100644 --- a/tests/test_pandora/test_transport.py +++ b/tests/test_pandora/test_transport.py | |||
@@ -18,7 +18,7 @@ class TestTransport(TestCase): | |||
18 | 18 | ||
19 | time.sleep = Mock() | 19 | time.sleep = Mock() |
20 | client.transport._make_http_request = Mock( | 20 | client.transport._make_http_request = Mock( |
21 | side_effect=SysCallError("mock_error")) | 21 | side_effect=SysCallError("error_mock")) |
22 | client.transport._start_request = Mock() | 22 | client.transport._start_request = Mock() |
23 | 23 | ||
24 | client("method") | 24 | client("method") |
diff --git a/tests/test_pydora/test_utils.py b/tests/test_pydora/test_utils.py index e5a81b5..ae6fa0b 100644 --- a/tests/test_pydora/test_utils.py +++ b/tests/test_pydora/test_utils.py | |||
@@ -18,8 +18,8 @@ class TestIterateForever(TestCase): | |||
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 | with patch.object(APIClient, 'register_ad', side_effect=ParameterMissing("ParameterMissing")): |
20 | 20 | ||
21 | station = Station.from_json(self.client, {'stationToken': 'mock_token'}) | 21 | station = Station.from_json(self.client, {'stationToken': 'token_mock'}) |
22 | ad_mock = AdItem.from_json(self.client, {'station_id': 'mock_id'}) | 22 | ad_mock = AdItem.from_json(self.client, {'station_id': 'id_mock'}) |
23 | get_playlist_mock.return_value=iter([ad_mock]) | 23 | get_playlist_mock.return_value=iter([ad_mock]) |
24 | 24 | ||
25 | station_iter = iterate_forever(station.get_playlist) | 25 | station_iter = iterate_forever(station.get_playlist) |
@@ -31,9 +31,9 @@ class TestIterateForever(TestCase): | |||
31 | with patch.object(APIClient, 'get_playlist', side_effect=ParameterMissing("ParameterMissing")) as get_playlist_mock: | 31 | with patch.object(APIClient, 'get_playlist', side_effect=ParameterMissing("ParameterMissing")) as get_playlist_mock: |
32 | with self.assertRaises(ParameterMissing): | 32 | with self.assertRaises(ParameterMissing): |
33 | 33 | ||
34 | station = Station.from_json(self.client, {'stationToken': 'mock_token'}) | 34 | station = Station.from_json(self.client, {'stationToken': 'token_mock'}) |
35 | mock_track = PlaylistItem.from_json(self.client, {'token': 'mock_token'}) | 35 | track_mock = PlaylistItem.from_json(self.client, {'token': 'token_mock'}) |
36 | get_playlist_mock.return_value=iter([mock_track]) | 36 | get_playlist_mock.return_value=iter([track_mock]) |
37 | 37 | ||
38 | station_iter = iterate_forever(station.get_playlist) | 38 | station_iter = iterate_forever(station.get_playlist) |
39 | station_iter.next() | 39 | station_iter.next() |