@@ -77,6 +77,7 @@ def test_search_returns_albums_and_artists_and_tracks(
77
77
params = {
78
78
'q' : '"ABBA"' ,
79
79
'limit' : 50 ,
80
+ 'market' : 'GB' ,
80
81
'type' : 'album,artist,track' })
81
82
82
83
assert 'Searching Spotify for: "ABBA"' in caplog .text ()
@@ -124,6 +125,7 @@ def test_sets_api_limit_to_album_count_when_max(
124
125
params = {
125
126
'q' : '"ABBA"' ,
126
127
'limit' : 6 ,
128
+ 'market' : 'GB' ,
127
129
'type' : 'album,artist,track' })
128
130
129
131
assert len (result .albums ) == 6
@@ -144,6 +146,7 @@ def test_sets_api_limit_to_artist_count_when_max(
144
146
params = {
145
147
'q' : '"ABBA"' ,
146
148
'limit' : 6 ,
149
+ 'market' : 'GB' ,
147
150
'type' : 'album,artist,track' })
148
151
149
152
assert len (result .artists ) == 6
@@ -164,6 +167,7 @@ def test_sets_api_limit_to_track_count_when_max(
164
167
params = {
165
168
'q' : '"ABBA"' ,
166
169
'limit' : 6 ,
170
+ 'market' : 'GB' ,
167
171
'type' : 'album,artist,track' })
168
172
169
173
assert len (result .tracks ) == 6
@@ -183,9 +187,26 @@ def test_sets_types_parameter(
183
187
params = {
184
188
'q' : '"ABBA"' ,
185
189
'limit' : 50 ,
190
+ 'market' : 'GB' ,
186
191
'type' : 'album,artist' })
187
192
188
193
194
+ def test_sets_market_parameter_from_user_country (
195
+ web_client_mock , web_search_mock_large , provider , session_mock ):
196
+ session_mock .user_country = 'SE'
197
+ web_client_mock .get .return_value = web_search_mock_large
198
+
199
+ provider .search ({'any' : ['ABBA' ]})
200
+
201
+ web_client_mock .get .assert_called_once_with (
202
+ 'https://api.spotify.com/v1/search' ,
203
+ params = {
204
+ 'q' : '"ABBA"' ,
205
+ 'limit' : 50 ,
206
+ 'market' : 'SE' ,
207
+ 'type' : 'album,artist,track' })
208
+
209
+
189
210
def test_handles_empty_response (web_client_mock , provider ):
190
211
web_client_mock .get .return_value = {}
191
212
0 commit comments