1717import aiounittest
1818
1919import mock
20- from tests .unit .v1 .test__helpers import AsyncMock
21-
22-
23- class MockAsyncIter :
24- def __init__ (self , count ):
25- self .count = count
26-
27- async def __aiter__ (self , ** _ ):
28- for i in range (self .count ):
29- yield i
20+ from tests .unit .v1 .test__helpers import AsyncMock , AsyncIter
3021
3122
3223class TestAsyncCollectionReference (aiounittest .AsyncTestCase ):
@@ -258,7 +249,7 @@ async def test_list_documents_w_page_size(self):
258249 async def test_get (self , query_class ):
259250 import warnings
260251
261- query_class .return_value .stream .return_value = MockAsyncIter ( 3 )
252+ query_class .return_value .stream .return_value = AsyncIter ( range ( 3 ) )
262253
263254 collection = self ._make_one ("collection" )
264255 with warnings .catch_warnings (record = True ) as warned :
@@ -280,7 +271,7 @@ async def test_get(self, query_class):
280271 async def test_get_with_transaction (self , query_class ):
281272 import warnings
282273
283- query_class .return_value .stream .return_value = MockAsyncIter ( 3 )
274+ query_class .return_value .stream .return_value = AsyncIter ( range ( 3 ) )
284275
285276 collection = self ._make_one ("collection" )
286277 transaction = mock .sentinel .txn
@@ -301,7 +292,7 @@ async def test_get_with_transaction(self, query_class):
301292 @mock .patch ("google.cloud.firestore_v1.async_query.AsyncQuery" , autospec = True )
302293 @pytest .mark .asyncio
303294 async def test_stream (self , query_class ):
304- query_class .return_value .stream .return_value = MockAsyncIter ( 3 )
295+ query_class .return_value .stream .return_value = AsyncIter ( range ( 3 ) )
305296
306297 collection = self ._make_one ("collection" )
307298 stream_response = collection .stream ()
@@ -316,7 +307,7 @@ async def test_stream(self, query_class):
316307 @mock .patch ("google.cloud.firestore_v1.async_query.AsyncQuery" , autospec = True )
317308 @pytest .mark .asyncio
318309 async def test_stream_with_transaction (self , query_class ):
319- query_class .return_value .stream .return_value = MockAsyncIter ( 3 )
310+ query_class .return_value .stream .return_value = AsyncIter ( range ( 3 ) )
320311
321312 collection = self ._make_one ("collection" )
322313 transaction = mock .sentinel .txn
0 commit comments