@@ -42,10 +42,8 @@ def connect_debug():
4242 return stream .connect (
4343 key ,
4444 secret ,
45- location = 'us-east ' ,
45+ location = 'qa ' ,
4646 timeout = 30 ,
47- base_url = 'https://qa.stream-io-api.com/api/' ,
48- # base_url='http://localhost-api.getstream.io:8000/api/',
4947 )
5048
5149client = connect_debug ()
@@ -120,6 +118,105 @@ def _test_sleep(self, production_wait, local_wait):
120118 sleep_time = local_wait
121119 time .sleep (sleep_time )
122120
121+ def test_collections_url (self ):
122+ feed_url = client .get_full_url (relative_url = 'meta/' , service_name = 'api' )
123+
124+ if self .local_tests :
125+ self .assertEqual (
126+ feed_url , 'http://localhost:8000/api/v1.0/meta/' )
127+ else :
128+ self .assertEqual (
129+ feed_url , 'https://qa-api.stream-io-api.com/api/v1.0/meta/' )
130+
131+ def test_personalization_url (self ):
132+ feed_url = client .get_full_url (relative_url = 'recommended' , service_name = 'personalization' )
133+
134+ if self .local_tests :
135+ self .assertEqual (
136+ feed_url , 'http://localhost:8000/personalization/v1.0/recommended' )
137+ else :
138+ self .assertEqual (
139+ feed_url , 'https://qa-personalization.stream-io-api.com/personalization/v1.0/recommended' )
140+
141+ def test_api_url (self ):
142+ feed_url = client .get_full_url (service_name = 'api' , relative_url = 'feed/' )
143+
144+ if self .local_tests :
145+ self .assertEqual (
146+ feed_url , 'http://localhost:8000/api/v1.0/feed/' )
147+ else :
148+ self .assertEqual (
149+ feed_url , 'https://qa-api.stream-io-api.com/api/v1.0/feed/' )
150+
151+ def test_collections_url_default (self ):
152+ client = stream .connect (
153+ 'key' ,
154+ 'secret' ,
155+ )
156+ feed_url = client .get_full_url (relative_url = 'meta/' , service_name = 'api' )
157+
158+ if not self .local_tests :
159+ self .assertEqual (
160+ feed_url , 'https://api.stream-io-api.com/api/v1.0/meta/' )
161+
162+ def test_personalization_url_default (self ):
163+ client = stream .connect (
164+ 'key' ,
165+ 'secret' ,
166+ )
167+ feed_url = client .get_full_url (relative_url = 'recommended' , service_name = 'personalization' )
168+
169+ if not self .local_tests :
170+ self .assertEqual (
171+ feed_url , 'https://personalization.stream-io-api.com/personalization/v1.0/recommended' )
172+
173+ def test_api_url_default (self ):
174+ client = stream .connect (
175+ 'key' ,
176+ 'secret' ,
177+ )
178+ feed_url = client .get_full_url (service_name = 'api' , relative_url = 'feed/' )
179+
180+ if not self .local_tests :
181+ self .assertEqual (
182+ feed_url , 'https://api.stream-io-api.com/api/v1.0/feed/' )
183+
184+ def test_collections_url_location (self ):
185+ client = stream .connect (
186+ 'key' ,
187+ 'secret' ,
188+ location = 'tokyo' ,
189+ )
190+ feed_url = client .get_full_url (relative_url = 'meta/' , service_name = 'api' )
191+
192+ if not self .local_tests :
193+ self .assertEqual (
194+ feed_url , 'https://tokyo-api.stream-io-api.com/api/v1.0/meta/' )
195+
196+ def test_personalization_url_location (self ):
197+ client = stream .connect (
198+ 'key' ,
199+ 'secret' ,
200+ location = 'tokyo' ,
201+ )
202+ feed_url = client .get_full_url (relative_url = 'recommended' , service_name = 'personalization' )
203+
204+ if not self .local_tests :
205+ self .assertEqual (
206+ feed_url , 'https://tokyo-personalization.stream-io-api.com/personalization/v1.0/recommended' )
207+
208+ def test_api_url_location (self ):
209+ client = stream .connect (
210+ 'key' ,
211+ 'secret' ,
212+ location = 'tokyo' ,
213+ )
214+ feed_url = client .get_full_url (service_name = 'api' , relative_url = 'feed/' )
215+
216+ if not self .local_tests :
217+ self .assertEqual (
218+ feed_url , 'https://tokyo-api.stream-io-api.com/api/v1.0/feed/' )
219+
123220 def test_update_activities_create (self ):
124221 activities = [{
125222 'actor' : 'user:1' ,
@@ -181,13 +278,14 @@ def test_heroku_no_location(self):
181278 self .assertEqual (
182279 client .api_secret , 'twc5ywfste5bm2ngqkzs7ukxk3pn96yweghjrxcmcrarnt3j4dqj3tucbhym5wfd' )
183280 self .assertEqual (client .app_id , '669' )
281+ feed_url = client .get_full_url ('api' , 'feed/' )
184282
185283 if self .local_tests :
186284 self .assertEqual (
187- client . base_url , 'http://localhost:8000/api/' )
285+ feed_url , 'http://localhost:8000/api/v1.0/feed /' )
188286 else :
189287 self .assertEqual (
190- client . base_url , 'https://api.stream-io-api.com/api/' )
288+ feed_url , 'https://api.stream-io-api.com/api/v1.0/feed /' )
191289
192290 def test_heroku_location_compat (self ):
193291 url = 'https://ahj2ndz7gsan:gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy@us-east.getstream.io/?app_id=1'
@@ -197,12 +295,14 @@ def test_heroku_location_compat(self):
197295 self .assertEqual (
198296 client .api_secret , 'gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy' )
199297
298+ feed_url = client .get_full_url ('api' , 'feed/' )
200299 if self .local_tests :
201300 self .assertEqual (
202- client . base_url , 'http://localhost:8000/api/' )
301+ feed_url , 'http://localhost:8000/api/v1.0/feed /' )
203302 else :
204303 self .assertEqual (
205- client .base_url , 'https://us-east-api.stream-io-api.com/api/' )
304+ feed_url , 'https://us-east-api.stream-io-api.com/api/v1.0/feed/' )
305+
206306 self .assertEqual (client .app_id , '1' )
207307
208308 def test_heroku_location (self ):
@@ -213,12 +313,13 @@ def test_heroku_location(self):
213313 self .assertEqual (
214314 client .api_secret , 'gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy' )
215315
316+ feed_url = client .get_full_url ('api' , 'feed/' )
216317 if self .local_tests :
217318 self .assertEqual (
218- client . base_url , 'http://localhost:8000/api/' )
319+ feed_url , 'http://localhost:8000/api/v1.0/feed /' )
219320 else :
220321 self .assertEqual (
221- client . base_url , 'https://us-east-api.stream-io-api.com/api/' )
322+ feed_url , 'https://us-east-api.stream-io-api.com/api/v1.0/feed /' )
222323 self .assertEqual (client .app_id , '1' )
223324
224325 def test_heroku_overwrite (self ):
@@ -232,12 +333,13 @@ def test_heroku_overwrite(self):
232333 def test_location_support (self ):
233334 client = stream .connect ('a' , 'b' , 'c' , location = 'us-east' )
234335
235- full_location = 'https://us-east-api.stream-io-api.com/api/'
336+ full_location = 'https://us-east-api.stream-io-api.com/api/v1.0/feed/ '
236337 if self .local_tests :
237- full_location = 'http://localhost:8000/api/'
338+ full_location = 'http://localhost:8000/api/v1.0/feed/ '
238339
239340 self .assertEqual (client .location , 'us-east' )
240- self .assertEqual (client .base_url , full_location )
341+ feed_url = client .get_full_url ('api' , 'feed/' )
342+ self .assertEqual (feed_url , full_location )
241343
242344 # test a wrong location, can only work on non-local test running
243345 if not self .local_tests :
0 commit comments