diff options
author | Mike Crute <mike@crute.us> | 2018-09-01 04:03:32 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2018-09-01 04:20:05 +0000 |
commit | 18b843f6fee09298ccfa3a85198f9194011b732f (patch) | |
tree | 01a80c4d157da0e015e919a9a6b7e71bafcd2251 | |
parent | 3de319435697e65a3b5d8570adc3ddaf88ee857f (diff) | |
download | pydora-18b843f6fee09298ccfa3a85198f9194011b732f.tar.bz2 pydora-18b843f6fee09298ccfa3a85198f9194011b732f.tar.xz pydora-18b843f6fee09298ccfa3a85198f9194011b732f.zip |
create_station returns a Station model
related: #57
-rw-r--r-- | pandora/client.py | 5 | ||||
-rw-r--r-- | tests/test_pandora/test_client.py | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/pandora/client.py b/pandora/client.py index 0eaa977..01b7654 100644 --- a/pandora/client.py +++ b/pandora/client.py | |||
@@ -199,6 +199,8 @@ class APIClient(BaseAPIClient): | |||
199 | 199 | ||
200 | def create_station(self, search_token=None, artist_token=None, | 200 | def create_station(self, search_token=None, artist_token=None, |
201 | track_token=None): | 201 | track_token=None): |
202 | from .models.pandora import Station | ||
203 | |||
202 | kwargs = {} | 204 | kwargs = {} |
203 | 205 | ||
204 | if search_token: | 206 | if search_token: |
@@ -210,7 +212,8 @@ class APIClient(BaseAPIClient): | |||
210 | else: | 212 | else: |
211 | raise KeyError("Must pass a type of token") | 213 | raise KeyError("Must pass a type of token") |
212 | 214 | ||
213 | return self("station.createStation", **kwargs) | 215 | return Station.from_json(self, |
216 | self("station.createStation", **kwargs)) | ||
214 | 217 | ||
215 | def delete_feedback(self, feedback_id): # pragma: no cover | 218 | def delete_feedback(self, feedback_id): # pragma: no cover |
216 | return self("station.deleteFeedback", | 219 | return self("station.deleteFeedback", |
diff --git a/tests/test_pandora/test_client.py b/tests/test_pandora/test_client.py index f88b755..6c61355 100644 --- a/tests/test_pandora/test_client.py +++ b/tests/test_pandora/test_client.py | |||
@@ -147,19 +147,19 @@ class TestGettingAds(TestCase): | |||
147 | class TestCreatingStation(TestCase): | 147 | class TestCreatingStation(TestCase): |
148 | 148 | ||
149 | def test_using_search_token(self): | 149 | def test_using_search_token(self): |
150 | client = APIClient(Mock(), None, None, None, None) | 150 | client = APIClient(Mock(return_value={}), None, None, None, None) |
151 | client.create_station(search_token="foo") | 151 | client.create_station(search_token="foo") |
152 | client.transport.assert_called_with( | 152 | client.transport.assert_called_with( |
153 | "station.createStation", musicToken="foo") | 153 | "station.createStation", musicToken="foo") |
154 | 154 | ||
155 | def test_using_artist_token(self): | 155 | def test_using_artist_token(self): |
156 | client = APIClient(Mock(), None, None, None, None) | 156 | client = APIClient(Mock(return_value={}), None, None, None, None) |
157 | client.create_station(artist_token="foo") | 157 | client.create_station(artist_token="foo") |
158 | client.transport.assert_called_with( | 158 | client.transport.assert_called_with( |
159 | "station.createStation", trackToken="foo", musicType="artist") | 159 | "station.createStation", trackToken="foo", musicType="artist") |
160 | 160 | ||
161 | def test_using_track_token(self): | 161 | def test_using_track_token(self): |
162 | client = APIClient(Mock(), None, None, None, None) | 162 | client = APIClient(Mock(return_value={}), None, None, None, None) |
163 | client.create_station(track_token="foo") | 163 | client.create_station(track_token="foo") |
164 | client.transport.assert_called_with( | 164 | client.transport.assert_called_with( |
165 | "station.createStation", trackToken="foo", musicType="song") | 165 | "station.createStation", trackToken="foo", musicType="song") |