aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcass <john.cass77@gmail.com>2016-01-02 22:55:07 +0200
committerjcass <john.cass77@gmail.com>2016-01-02 22:55:07 +0200
commit9259bdab02ac2aa0dc46893f65214e1834f37d2d (patch)
tree4d4c02029fc6e61ad4643d6f571d83088533a7f8
parentbcbe294e8143f2a28b38e4d93e53f142bca5e3b0 (diff)
downloadpydora-9259bdab02ac2aa0dc46893f65214e1834f37d2d.tar.bz2
pydora-9259bdab02ac2aa0dc46893f65214e1834f37d2d.tar.xz
pydora-9259bdab02ac2aa0dc46893f65214e1834f37d2d.zip
Add ad_token to AdItem definition.
-rw-r--r--pandora/client.py8
-rw-r--r--pandora/models/pandora.py1
-rw-r--r--tests/test_pandora/test_client.py1
-rw-r--r--tests/test_pandora/test_models.py2
4 files changed, 8 insertions, 4 deletions
diff --git a/pandora/client.py b/pandora/client.py
index 3cc2538..4e27208 100644
--- a/pandora/client.py
+++ b/pandora/client.py
@@ -266,10 +266,10 @@ class APIClient(BaseAPIClient):
266 "defined, got: '{}'" 266 "defined, got: '{}'"
267 .format(station_id)) 267 .format(station_id))
268 268
269 ad_metadata = self.get_ad_metadata(ad_token) 269 ad_item = AdItem.from_json(self, self.get_ad_metadata(ad_token))
270 ad_metadata["stationId"] = station_id 270 ad_item.station_id = station_id
271 271 ad_item.ad_token = ad_token
272 return AdItem.from_json(self, ad_metadata) 272 return ad_item
273 273
274 def get_ad_metadata(self, ad_token): 274 def get_ad_metadata(self, ad_token):
275 return self("ad.getAdMetadata", 275 return self("ad.getAdMetadata",
diff --git a/pandora/models/pandora.py b/pandora/models/pandora.py
index 75c971b..ae60740 100644
--- a/pandora/models/pandora.py
+++ b/pandora/models/pandora.py
@@ -221,6 +221,7 @@ class AdItem(PlaylistModel):
221 image_url = Field("imageUrl") 221 image_url = Field("imageUrl")
222 click_through_url = Field("clickThroughUrl") 222 click_through_url = Field("clickThroughUrl")
223 station_id = Field("stationId") 223 station_id = Field("stationId")
224 ad_token = Field("adToken")
224 225
225 @property 226 @property
226 def is_ad(self): 227 def is_ad(self):
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py
index 58fca74..cf486e0 100644
--- a/tests/test_pandora/test_client.py
+++ b/tests/test_pandora/test_client.py
@@ -105,6 +105,7 @@ class TestGettingAds(TestCase):
105 105
106 ad_item = client.get_ad_item('id_mock', 'token_mock') 106 ad_item = client.get_ad_item('id_mock', 'token_mock')
107 assert ad_item.station_id == 'id_mock' 107 assert ad_item.station_id == 'id_mock'
108 assert ad_item.ad_token == 'token_mock'
108 109
109 ad_metadata_mock.assert_has_calls([call("ad.getAdMetadata", 110 ad_metadata_mock.assert_has_calls([call("ad.getAdMetadata",
110 adToken='token_mock', 111 adToken='token_mock',
diff --git a/tests/test_pandora/test_models.py b/tests/test_pandora/test_models.py
index 538cee5..495bb8e 100644
--- a/tests/test_pandora/test_models.py
+++ b/tests/test_pandora/test_models.py
@@ -225,6 +225,8 @@ class TestAdItem(TestCase):
225 api_client_mock = Mock(spec=APIClient) 225 api_client_mock = Mock(spec=APIClient)
226 api_client_mock.default_audio_quality = APIClient.HIGH_AUDIO_QUALITY 226 api_client_mock.default_audio_quality = APIClient.HIGH_AUDIO_QUALITY
227 self.result = AdItem.from_json(api_client_mock, self.JSON_DATA) 227 self.result = AdItem.from_json(api_client_mock, self.JSON_DATA)
228 self.result.station_id = 'station_id_mock'
229 self.result.ad_token = 'token_mock'
228 230
229 def test_is_ad_is_true(self): 231 def test_is_ad_is_true(self):
230 assert self.result.is_ad is True 232 assert self.result.is_ad is True