@@ -161,6 +161,21 @@ def test_iterate():
161161 assert list (client .products .all ()) == return_value
162162 assert client .response .headers ['X-Custom-Header' ] == 'value'
163163
164+ with ConnectClientMocker ('http://localhost' ) as mocker :
165+ mocker .products .all ().mock (return_value = [])
166+
167+ client = ConnectClient ('api_key' , endpoint = 'http://localhost' )
168+
169+ assert list (client .products .all ()) == []
170+
171+ with ConnectClientMocker ('http://localhost' ) as mocker :
172+ mocker .products .all ().mock (return_value = [], headers = {'X-Custom-Header' : 'value' })
173+
174+ client = ConnectClient ('api_key' , endpoint = 'http://localhost' )
175+
176+ assert list (client .products .all ()) == []
177+ assert client .response .headers ['X-Custom-Header' ] == 'value'
178+
164179 with ConnectClientMocker ('http://localhost' ) as mocker :
165180 mocker .products .all ().mock (return_value = return_value )
166181
@@ -267,6 +282,26 @@ def test_slicing(total, start, stop):
267282 assert client .response .headers ['X-Custom-Header' ] == 'value'
268283
269284
285+ def test_slicing_no_results ():
286+
287+ with ConnectClientMocker ('http://localhost' ) as mocker :
288+ mocker .products .all ()[0 :3 ].mock (return_value = [])
289+
290+ client = ConnectClient ('api_key' , endpoint = 'http://localhost' )
291+
292+ assert list (client .products .all ()[0 :3 ]) == []
293+
294+ with ConnectClientMocker ('http://localhost' ) as mocker :
295+ mocker .products .all ()[0 :3 ].mock (
296+ return_value = [], headers = {'X-Custom-Header' : 'value' },
297+ )
298+
299+ client = ConnectClient ('api_key' , endpoint = 'http://localhost' )
300+
301+ assert list (client .products .all ()[0 :3 ]) == []
302+ assert client .response .headers ['X-Custom-Header' ] == 'value'
303+
304+
270305def test_count ():
271306 with ConnectClientMocker ('http://localhost' ) as mocker :
272307 mocker .products .all ().count (return_value = 123 )
0 commit comments