Repository: googleapis/python-firestore

Issue:
Raise Test Coverage 
In order to expedite merging in a new microgenerated surface, coverage was dropped from 100% to 97%.
https://github.com/googleapis/python-firestore/tree/v2-staging
https://github.com/googleapis/python-firestore/pull/91

This work item tracks raising it back up again.

```
Name                                                                                  Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------------------------------------------------------------------------------------
google/cloud/__init__.py                                                                  6      6      0      0     0%   15-22
google/cloud/firestore.py                                                                26      0      0      0   100%
google/cloud/firestore_admin_v1/__init__.py                                              23      0      0      0   100%
google/cloud/firestore_admin_v1/services/__init__.py                                      0      0      0      0   100%
google/cloud/firestore_admin_v1/services/firestore_admin/__init__.py                      3      0      0      0   100%
google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py                137      2     38      0    99%   882-883
google/cloud/firestore_admin_v1/services/firestore_admin/client.py                      195      2     64      0    99%   1030-1031
google/cloud/firestore_admin_v1/services/firestore_admin/pagers.py                       82      0     20      0   100%
google/cloud/firestore_admin_v1/services/firestore_admin/transports/__init__.py           9      0      0      0   100%
google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py              45      0      8      0   100%
google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py              90      0     30      0   100%
google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc_asyncio.py      90      0     28      0   100%
google/cloud/firestore_admin_v1/types/__init__.py                                         6      0      0      0   100%
google/cloud/firestore_admin_v1/types/field.py                                           12      0      0      0   100%
google/cloud/firestore_admin_v1/types/firestore_admin.py                                 48      0      0      0   100%
google/cloud/firestore_admin_v1/types/index.py                                           28      0      0      0   100%
google/cloud/firestore_admin_v1/types/location.py                                         4      0      0      0   100%
google/cloud/firestore_admin_v1/types/operation.py                                       57      0      0      0   100%
google/cloud/firestore_v1/__init__.py                                                    27      0      0      0   100%
google/cloud/firestore_v1/_helpers.py                                                   396      5    222      8    98%   585->586, 586, 592->595, 617->618, 618, 794->799, 818->819, 819, 826->827, 827, 868->873, 875->878, 878
google/cloud/firestore_v1/base_batch.py                                                  26      0      4      0   100%
google/cloud/firestore_v1/base_client.py                                                131      2     38      1    98%   164->167, 167, 481
google/cloud/firestore_v1/base_collection.py                                             75      0     12      0   100%
google/cloud/firestore_v1/base_document.py                                              106      1     20      0    99%   460
google/cloud/firestore_v1/base_query.py                                                 279     19    128      0    93%   787-824
google/cloud/firestore_v1/batch.py                                                       16      0      2      0   100%
google/cloud/firestore_v1/client.py                                                      34      1      6      1    95%   244->245, 245
google/cloud/firestore_v1/collection.py                                                  29      0      4      0   100%
google/cloud/firestore_v1/document.py                                                    57      1      8      1    97%   373->374, 374
google/cloud/firestore_v1/field_path.py                                                 138      2     56      0    99%   19-20
google/cloud/firestore_v1/order.py                                                      129      0     54      0   100%
google/cloud/firestore_v1/query.py                                                       23      0      6      0   100%
google/cloud/firestore_v1/services/__init__.py                                            0      0      0      0   100%
google/cloud/firestore_v1/services/firestore/__init__.py                                  3      0      0      0   100%
google/cloud/firestore_v1/services/firestore/async_client.py                            155      2     30      0    99%   1060-1061
google/cloud/firestore_v1/services/firestore/client.py                                  200      2     56      0    99%   1171-1172
google/cloud/firestore_v1/services/firestore/pagers.py                                   82      0     20      0   100%
google/cloud/firestore_v1/services/firestore/transports/__init__.py                       9      0      0      0   100%
google/cloud/firestore_v1/services/firestore/transports/base.py                          53      0      8      0   100%
google/cloud/firestore_v1/services/firestore/transports/grpc.py                         113      0     40      0   100%
google/cloud/firestore_v1/services/firestore/transports/grpc_asyncio.py                 113      0     38      0   100%
google/cloud/firestore_v1/transaction.py                                                126      0     28      0   100%
google/cloud/firestore_v1/transforms.py                                                  39      0     10      0   100%
google/cloud/firestore_v1/types/__init__.py                                               6      0      0      0   100%
google/cloud/firestore_v1/types/common.py                                                16      0      0      0   100%
google/cloud/firestore_v1/types/document.py                                              27      0      0      0   100%
google/cloud/firestore_v1/types/firestore.py                                            157      1      0      0    99%   1019
google/cloud/firestore_v1/types/query.py                                                 62      0      0      0   100%
google/cloud/firestore_v1/types/write.py                                                 45      0      0      0   100%
google/cloud/firestore_v1/watch.py                                                      325      3     78      2    99%   397->exit, 524->525, 525-527
google/cloud/firestore_v1beta1/__init__.py                                               63      0      0      0   100%
google/cloud/firestore_v1beta1/_helpers.py                                              387      5    216      8    98%   537->538, 538, 544->547, 569->570, 570, 746->751, 770->771, 771, 778->779, 779, 820->825, 827->830, 830
google/cloud/firestore_v1beta1/batch.py                                                  37      0      6      0   100%
google/cloud/firestore_v1beta1/client.py                                                119      0     26      0   100%
google/cloud/firestore_v1beta1/collection.py                                            100      0     14      0   100%
google/cloud/firestore_v1beta1/document.py                                              149      0     24      0   100%
google/cloud/firestore_v1beta1/field_path.py                                            135      2     56      0    99%   19-20
google/cloud/firestore_v1beta1/order.py                                                 129      0     54      0   100%
google/cloud/firestore_v1beta1/query.py                                                 257      0    116      0   100%
google/cloud/firestore_v1beta1/services/__init__.py                                       0      0      0      0   100%
google/cloud/firestore_v1beta1/services/firestore/__init__.py                             3      0      0      0   100%
google/cloud/firestore_v1beta1/services/firestore/async_client.py                       140      2     30      0    99%   942-943
google/cloud/firestore_v1beta1/services/firestore/client.py                             185      2     56      0    99%   1055-1056
google/cloud/firestore_v1beta1/services/firestore/pagers.py                              42      0     10      0   100%
google/cloud/firestore_v1beta1/services/firestore/transports/__init__.py                  9      0      0      0   100%
google/cloud/firestore_v1beta1/services/firestore/transports/base.py                     49      0      8      0   100%
google/cloud/firestore_v1beta1/services/firestore/transports/grpc.py                    103      0     36      0   100%
google/cloud/firestore_v1beta1/services/firestore/transports/grpc_asyncio.py            103      0     34      0   100%
google/cloud/firestore_v1beta1/transaction.py                                           116      0     24      0   100%
google/cloud/firestore_v1beta1/transforms.py                                             24      0      6      0   100%
google/cloud/firestore_v1beta1/types/__init__.py                                          6      0      0      0   100%
google/cloud/firestore_v1beta1/types/common.py                                           16      0      0      0   100%
google/cloud/firestore_v1beta1/types/document.py                                         27      0      0      0   100%
google/cloud/firestore_v1beta1/types/firestore.py                                       138      1      0      0    99%   909
google/cloud/firestore_v1beta1/types/query.py                                            62      0      0      0   100%
google/cloud/firestore_v1beta1/types/write.py                                            44      0      0      0   100%
google/cloud/firestore_v1beta1/watch.py                                                 310      3     74      2    99%   383->exit, 507->508, 508-510
tests/unit/__init__.py                                                                    0      0      0      0   100%
tests/unit/test_firestore_shim.py                                                        10      0      2      0   100%
tests/unit/v1/__init__.py                                                                 0      0      0      0   100%
tests/unit/v1/_test_cross_language.py                                                   199    199     80      0     0%   17-518
tests/unit/v1/test__helpers.py                                                         1545      0     32      0   100%
tests/unit/v1/test_base_batch.py                                                         98      0      0      0   100%
tests/unit/v1/test_base_client.py                                                       213      0      0      0   100%
tests/unit/v1/test_base_collection.py                                                   226      0      0      0   100%
tests/unit/v1/test_base_document.py                                                     290      0      2      0   100%
tests/unit/v1/test_base_query.py                                                        942      1     20      1    99%   24->25, 25
tests/unit/v1/test_batch.py                                                              81      0      0      0   100%
tests/unit/v1/test_client.py                                                            270      3      4      0    98%   211-213
tests/unit/v1/test_collection.py                                                        186      0     10      0   100%
tests/unit/v1/test_document.py                                                          275      3     30      0    98%   430-432
tests/unit/v1/test_field_path.py                                                        355      0      8      0   100%
tests/unit/v1/test_order.py                                                             143      2     12      2    97%   31->32, 32, 215->216, 216
tests/unit/v1/test_query.py                                                             196      1      2      1    99%   26->27, 27
tests/unit/v1/test_transaction.py                                                       574      0      0      0   100%
tests/unit/v1/test_transforms.py                                                         78      0      8      0   100%
tests/unit/v1/test_watch.py                                                             667      0      4      0   100%
tests/unit/v1beta1/__init__.py                                                            0      0      0      0   100%
tests/unit/v1beta1/_test_cross_language.py                                              192    192     78      0     0%   15-503
tests/unit/v1beta1/test__helpers.py                                                    1298      0     32      0   100%
tests/unit/v1beta1/test_batch.py                                                        158      0      0      0   100%
tests/unit/v1beta1/test_client.py                                                       398      0      4      0   100%
tests/unit/v1beta1/test_collection.py                                                   375      0     12      0   100%
tests/unit/v1beta1/test_document.py                                                     525      0     32      0   100%
tests/unit/v1beta1/test_field_path.py                                                   351      0      8      0   100%
tests/unit/v1beta1/test_order.py                                                        143      2     12      2    97%   31->32, 32, 215->216, 216
tests/unit/v1beta1/test_query.py                                                       1004      1     20      1    99%   26->27, 27
tests/unit/v1beta1/test_transaction.py                                                  546      0      0      0   100%
tests/unit/v1beta1/test_transforms.py                                                    40      0      2      0   100%
tests/unit/v1beta1/test_watch.py                                                        565      1      2      0    99%   849
---------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                 18554    469   2262     30    97%
Coverage failure: total of 97 is less than fail-under=100
```

Discussion:

Patch:
diff --git a/google/cloud/firestore_v1/_helpers.py b/google/cloud/firestore_v1/_helpers.py
index fb2f73c..c1213e2 100644
--- a/google/cloud/firestore_v1/_helpers.py
+++ b/google/cloud/firestore_v1/_helpers.py
@@ -644,20 +644,6 @@ class DocumentExtractorForMerge(DocumentExtractor):
         self.transform_merge = []
         self.merge = []
 
-    @property
-    def has_updates(self):
-        # for whatever reason, the conformance tests want to see the parent
-        # of nested transform paths in the update mask
-        # (see set-st-merge-nonleaf-alone.textproto)
-        update_paths = set(self.data_merge)
-
-        for transform_path in self.transform_paths:
-            if len(transform_path.parts) > 1:
-                parent_fp = FieldPath(*transform_path.parts[:-1])
-                update_paths.add(parent_fp)
-
-        return bool(update_paths)
-
     def _apply_merge_all(self) -> None:
         self.data_merge = sorted(self.field_paths + self.deleted_fields)
         # TODO: other transforms
@@ -771,8 +757,7 @@ class DocumentExtractorForMerge(DocumentExtractor):
             if field_path not in self.transform_merge
         ]
 
-        if mask_paths or allow_empty_mask:
-            return common.DocumentMask(field_paths=mask_paths)
+        return common.DocumentMask(field_paths=mask_paths)
 
 
 def pbs_for_set_with_merge(
@@ -794,10 +779,8 @@ def pbs_for_set_with_merge(
     extractor = DocumentExtractorForMerge(document_data)
     extractor.apply_merge(merge)
 
-    merge_empty = not document_data
-    allow_empty_mask = merge_empty or extractor.transform_paths
+    set_pb = extractor.get_update_pb(document_path)
 
-    set_pb = extractor.get_update_pb(document_path, allow_empty_mask=allow_empty_mask)
     if extractor.transform_paths:
         field_transform_pbs = extractor.get_field_transform_pbs(document_path)
         set_pb.update_transforms.extend(field_transform_pbs)
diff --git a/google/cloud/firestore_v1/async_client.py b/google/cloud/firestore_v1/async_client.py
index 8233fd5..512025f 100644
--- a/google/cloud/firestore_v1/async_client.py
+++ b/google/cloud/firestore_v1/async_client.py
@@ -284,24 +284,8 @@ class AsyncClient(BaseClient):
             request=request, metadata=self._rpc_metadata, **kwargs,
         )
 
-        while True:
-            for i in iterator.collection_ids:
-                yield self.collection(i)
-            if iterator.next_page_token:
-                next_request = request.copy()
-                next_request["page_token"] = iterator.next_page_token
-                iterator = await self._firestore_api.list_collection_ids(
-                    request=next_request, metadata=self._rpc_metadata, **kwargs,
-                )
-            else:
-                return
-
-        # TODO(microgen): currently this method is rewritten to iterate/page itself.
-        # https://github.com/googleapis/gapic-generator-python/issues/516
-        # it seems the generator ought to be able to do this itself.
-        # iterator.client = self
-        # iterator.item_to_value = _item_to_collection_ref
-        # return iterator
+        async for collection_id in iterator:
+            yield self.collection(collection_id)
 
     def batch(self) -> AsyncWriteBatch:
         """Get a batch instance from this client.
diff --git a/google/cloud/firestore_v1/async_document.py b/google/cloud/firestore_v1/async_document.py
index 5f821b6..a90227c 100644
--- a/google/cloud/firestore_v1/async_document.py
+++ b/google/cloud/firestore_v1/async_document.py
@@ -407,20 +407,5 @@ class AsyncDocumentReference(BaseDocumentReference):
             request=request, metadata=self._client._rpc_metadata, **kwargs,
         )
 
-        while True:
-            for i in iterator.collection_ids:
-                yield self.collection(i)
-            if iterator.next_page_token:
-                next_request = request.copy()
-                next_request["page_token"] = iterator.next_page_token
-                iterator = await self._client._firestore_api.list_collection_ids(
-                    request=request, metadata=self._client._rpc_metadata, **kwargs
-                )
-            else:
-                return
-
-        # TODO(microgen): currently this method is rewritten to iterate/page itself.
-        # it seems the generator ought to be able to do this itself.
-        # iterator.document = self
-        # iterator.item_to_value = _item_to_collection_ref
-        # return iterator
+        async for collection_id in iterator:
+            yield self.collection(collection_id)
diff --git a/google/cloud/firestore_v1/base_client.py b/google/cloud/firestore_v1/base_client.py
index 285ad82..64e38d0 100644
--- a/google/cloud/firestore_v1/base_client.py
+++ b/google/cloud/firestore_v1/base_client.py
@@ -536,17 +536,6 @@ def _get_doc_mask(field_paths: Iterable[str]) -> Optional[types.common.DocumentM
         return types.DocumentMask(field_paths=field_paths)
 
 
-def _item_to_collection_ref(iterator, item: str) -> Any:
-    """Convert collection ID to collection ref.
-
-    Args:
-        iterator (google.api_core.page_iterator.GRPCIterator):
-            iterator response
-        item (str): ID of the collection
-    """
-    return iterator.client.collection(item)
-
-
 def _path_helper(path: tuple) -> Any:
     """Standardize path into a tuple of path segments.
 
diff --git a/google/cloud/firestore_v1/base_document.py b/google/cloud/firestore_v1/base_document.py
index 7dcf407..f06d5a8 100644
--- a/google/cloud/firestore_v1/base_document.py
+++ b/google/cloud/firestore_v1/base_document.py
@@ -567,14 +567,3 @@ def _first_write_result(write_results: list) -> Any:
         raise ValueError("Expected at least one write result")
 
     return write_results[0]
-
-
-def _item_to_collection_ref(iterator, item: str) -> Any:
-    """Convert collection ID to collection ref.
-
-    Args:
-        iterator (google.api_core.page_iterator.GRPCIterator):
-            iterator response
-        item (str): ID of the collection
-    """
-    return iterator.document.collection(item)
diff --git a/google/cloud/firestore_v1/client.py b/google/cloud/firestore_v1/client.py
index c3f75ab..9ab945e 100644
--- a/google/cloud/firestore_v1/client.py
+++ b/google/cloud/firestore_v1/client.py
@@ -280,24 +280,8 @@ class Client(BaseClient):
             request=request, metadata=self._rpc_metadata, **kwargs,
         )
 
-        while True:
-            for i in iterator.collection_ids:
-                yield self.collection(i)
-            if iterator.next_page_token:
-                next_request = request.copy()
-                next_request["page_token"] = iterator.next_page_token
-                iterator = self._firestore_api.list_collection_ids(
-                    request=next_request, metadata=self._rpc_metadata, **kwargs,
-                )
-            else:
-                return
-
-        # TODO(microgen): currently this method is rewritten to iterate/page itself.
-        # https://github.com/googleapis/gapic-generator-python/issues/516
-        # it seems the generator ought to be able to do this itself.
-        # iterator.client = self
-        # iterator.item_to_value = _item_to_collection_ref
-        # return iterator
+        for collection_id in iterator:
+            yield self.collection(collection_id)
 
     def batch(self) -> WriteBatch:
         """Get a batch instance from this client.
diff --git a/google/cloud/firestore_v1/document.py b/google/cloud/firestore_v1/document.py
index 55e8797..42fd523 100644
--- a/google/cloud/firestore_v1/document.py
+++ b/google/cloud/firestore_v1/document.py
@@ -408,23 +408,8 @@ class DocumentReference(BaseDocumentReference):
             request=request, metadata=self._client._rpc_metadata, **kwargs,
         )
 
-        while True:
-            for i in iterator.collection_ids:
-                yield self.collection(i)
-            if iterator.next_page_token:
-                next_request = request.copy()
-                next_request["page_token"] = iterator.next_page_token
-                iterator = self._client._firestore_api.list_collection_ids(
-                    request=request, metadata=self._client._rpc_metadata, **kwargs
-                )
-            else:
-                return
-
-        # TODO(microgen): currently this method is rewritten to iterate/page itself.
-        # it seems the generator ought to be able to do this itself.
-        # iterator.document = self
-        # iterator.item_to_value = _item_to_collection_ref
-        # return iterator
+        for collection_id in iterator:
+            yield self.collection(collection_id)
 
     def on_snapshot(self, callback: Callable) -> Watch:
         """Watch this document.


Test patch:
diff --git a/tests/unit/v1/test__helpers.py b/tests/unit/v1/test__helpers.py
index ff2aa3e..5c4c459 100644
--- a/tests/unit/v1/test__helpers.py
+++ b/tests/unit/v1/test__helpers.py
@@ -1728,7 +1728,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         self.assertEqual(inst.data_merge, [])
         self.assertEqual(inst.transform_merge, [])
         self.assertEqual(inst.merge, [])
-        self.assertFalse(inst.has_updates)
 
     def test_apply_merge_all_w_delete(self):
         from google.cloud.firestore_v1.transforms import DELETE_FIELD
@@ -1745,7 +1744,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         self.assertEqual(inst.data_merge, expected_data_merge)
         self.assertEqual(inst.transform_merge, [])
         self.assertEqual(inst.merge, expected_data_merge)
-        self.assertTrue(inst.has_updates)
 
     def test_apply_merge_all_w_server_timestamp(self):
         from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP
@@ -1761,7 +1759,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         self.assertEqual(inst.data_merge, expected_data_merge)
         self.assertEqual(inst.transform_merge, expected_transform_merge)
         self.assertEqual(inst.merge, expected_merge)
-        self.assertTrue(inst.has_updates)
 
     def test_apply_merge_list_fields_w_empty_document(self):
         document_data = {}
@@ -1800,7 +1797,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         expected_deleted_fields = [_make_field_path("delete_me")]
         self.assertEqual(inst.set_fields, expected_set_fields)
         self.assertEqual(inst.deleted_fields, expected_deleted_fields)
-        self.assertTrue(inst.has_updates)
 
     def test_apply_merge_list_fields_w_prefixes(self):
 
@@ -1827,7 +1823,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
 
         expected_set_fields = {"write_me": "value"}
         self.assertEqual(inst.set_fields, expected_set_fields)
-        self.assertTrue(inst.has_updates)
 
     def test_apply_merge_list_fields_w_server_timestamp(self):
         from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP
@@ -1849,7 +1844,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         self.assertEqual(inst.merge, expected_merge)
         expected_server_timestamps = [_make_field_path("timestamp")]
         self.assertEqual(inst.server_timestamps, expected_server_timestamps)
-        self.assertTrue(inst.has_updates)
 
     def test_apply_merge_list_fields_w_array_remove(self):
         from google.cloud.firestore_v1.transforms import ArrayRemove
@@ -1872,7 +1866,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         self.assertEqual(inst.merge, expected_merge)
         expected_array_removes = {_make_field_path("remove_me"): values}
         self.assertEqual(inst.array_removes, expected_array_removes)
-        self.assertTrue(inst.has_updates)
 
     def test_apply_merge_list_fields_w_array_union(self):
         from google.cloud.firestore_v1.transforms import ArrayUnion
@@ -1895,7 +1888,6 @@ class TestDocumentExtractorForMerge(unittest.TestCase):
         self.assertEqual(inst.merge, expected_merge)
         expected_array_unions = {_make_field_path("union_me"): values}
         self.assertEqual(inst.array_unions, expected_array_unions)
-        self.assertTrue(inst.has_updates)
 
 
 class Test_pbs_for_set_with_merge(unittest.TestCase):
diff --git a/tests/unit/v1/test_async_client.py b/tests/unit/v1/test_async_client.py
index bf97878..44d81d0 100644
--- a/tests/unit/v1/test_async_client.py
+++ b/tests/unit/v1/test_async_client.py
@@ -196,33 +196,23 @@ class TestAsyncClient(aiounittest.AsyncTestCase):
         self.assertIsInstance(document2, AsyncDocumentReference)
 
     async def _collections_helper(self, retry=None, timeout=None):
-        from google.api_core.page_iterator import Iterator
-        from google.api_core.page_iterator import Page
         from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
         from google.cloud.firestore_v1 import _helpers
 
         collection_ids = ["users", "projects"]
-        client = self._make_default_one()
-        firestore_api = AsyncMock()
-        firestore_api.mock_add_spec(spec=["list_collection_ids"])
-        client._firestore_api_internal = firestore_api
 
-        # TODO(microgen): list_collection_ids isn't a pager.
-        # https://github.com/googleapis/gapic-generator-python/issues/516
-        class _Iterator(Iterator):
-            def __init__(self, pages):
-                super(_Iterator, self).__init__(client=None)
-                self._pages = pages
-                self.collection_ids = pages[0]
+        class Pager(object):
+            async def __aiter__(self, **_):
+                for collection_id in collection_ids:
+                    yield collection_id
 
-            def _next_page(self):
-                if self._pages:
-                    page, self._pages = self._pages[0], self._pages[1:]
-                    return Page(self, page, self.item_to_value)
+        firestore_api = AsyncMock()
+        firestore_api.mock_add_spec(spec=["list_collection_ids"])
+        firestore_api.list_collection_ids.return_value = Pager()
 
+        client = self._make_default_one()
+        client._firestore_api_internal = firestore_api
         kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout)
-        iterator = _Iterator(pages=[collection_ids])
-        firestore_api.list_collection_ids.return_value = iterator
 
         collections = [c async for c in client.collections(**kwargs)]
 
diff --git a/tests/unit/v1/test_async_document.py b/tests/unit/v1/test_async_document.py
index 04214fd..6066526 100644
--- a/tests/unit/v1/test_async_document.py
+++ b/tests/unit/v1/test_async_document.py
@@ -497,27 +497,18 @@ class TestAsyncDocumentReference(aiounittest.AsyncTestCase):
     @pytest.mark.asyncio
     async def _collections_helper(self, page_size=None, retry=None, timeout=None):
         from google.cloud.firestore_v1 import _helpers
-        from google.api_core.page_iterator import Iterator
-        from google.api_core.page_iterator import Page
         from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
 
-        # TODO(microgen): https://github.com/googleapis/gapic-generator-python/issues/516
-        class _Iterator(Iterator):
-            def __init__(self, pages):
-                super(_Iterator, self).__init__(client=None)
-                self._pages = pages
-                self.collection_ids = pages[0]
+        collection_ids = ["coll-1", "coll-2"]
 
-            def _next_page(self):
-                if self._pages:
-                    page, self._pages = self._pages[0], self._pages[1:]
-                    return Page(self, page, self.item_to_value)
+        class Pager(object):
+            async def __aiter__(self, **_):
+                for collection_id in collection_ids:
+                    yield collection_id
 
-        collection_ids = ["coll-1", "coll-2"]
-        iterator = _Iterator(pages=[collection_ids])
         firestore_api = AsyncMock()
         firestore_api.mock_add_spec(spec=["list_collection_ids"])
-        firestore_api.list_collection_ids.return_value = iterator
+        firestore_api.list_collection_ids.return_value = Pager()
 
         client = _make_client()
         client._firestore_api_internal = firestore_api
diff --git a/tests/unit/v1/test_async_query.py b/tests/unit/v1/test_async_query.py
index 23173ba..42514c7 100644
--- a/tests/unit/v1/test_async_query.py
+++ b/tests/unit/v1/test_async_query.py
@@ -25,16 +25,6 @@ from tests.unit.v1.test_base_query import (
 )
 
 
-class MockAsyncIter:
-    def __init__(self, count=3):
-        # count is arbitrary value
-        self.count = count
-
-    async def __aiter__(self, **_):
-        for i in range(self.count):
-            yield i
-
-
 class TestAsyncQuery(aiounittest.AsyncTestCase):
     @staticmethod
     def _get_target_class():
diff --git a/tests/unit/v1/test_client.py b/tests/unit/v1/test_client.py
index e1995e5..0055dab 100644
--- a/tests/unit/v1/test_client.py
+++ b/tests/unit/v1/test_client.py
@@ -195,31 +195,20 @@ class TestClient(unittest.TestCase):
 
     def _collections_helper(self, retry=None, timeout=None):
         from google.cloud.firestore_v1 import _helpers
-        from google.api_core.page_iterator import Iterator
-        from google.api_core.page_iterator import Page
         from google.cloud.firestore_v1.collection import CollectionReference
 
         collection_ids = ["users", "projects"]
-        client = self._make_default_one()
-        firestore_api = mock.Mock(spec=["list_collection_ids"])
-        client._firestore_api_internal = firestore_api
 
-        # TODO(microgen): list_collection_ids isn't a pager.
-        # https://github.com/googleapis/gapic-generator-python/issues/516
-        class _Iterator(Iterator):
-            def __init__(self, pages):
-                super(_Iterator, self).__init__(client=None)
-                self._pages = pages
-                self.collection_ids = pages[0]
+        class Pager(object):
+            def __iter__(self):
+                yield from collection_ids
 
-            def _next_page(self):
-                if self._pages:
-                    page, self._pages = self._pages[0], self._pages[1:]
-                    return Page(self, page, self.item_to_value)
+        firestore_api = mock.Mock(spec=["list_collection_ids"])
+        firestore_api.list_collection_ids.return_value = Pager()
 
+        client = self._make_default_one()
+        client._firestore_api_internal = firestore_api
         kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout)
-        iterator = _Iterator(pages=[collection_ids])
-        firestore_api.list_collection_ids.return_value = iterator
 
         collections = list(client.collections(**kwargs))
 
@@ -259,20 +248,6 @@ class TestClient(unittest.TestCase):
 
         return list(snapshots)
 
-    def _info_for_get_all(self, data1, data2):
-        client = self._make_default_one()
-        document1 = client.document("pineapple", "lamp1")
-        document2 = client.document("pineapple", "lamp2")
-
-        # Make response protobufs.
-        document_pb1, read_time = _doc_get_info(document1._document_path, data1)
-        response1 = _make_batch_response(found=document_pb1, read_time=read_time)
-
-        document, read_time = _doc_get_info(document2._document_path, data2)
-        response2 = _make_batch_response(found=document, read_time=read_time)
-
-        return client, document1, document2, response1, response2
-
     def _get_all_helper(self, num_snapshots=2, txn_id=None, retry=None, timeout=None):
         from google.cloud.firestore_v1 import _helpers
         from google.cloud.firestore_v1.types import common
diff --git a/tests/unit/v1/test_document.py b/tests/unit/v1/test_document.py
index ef55508..6ca9b30 100644
--- a/tests/unit/v1/test_document.py
+++ b/tests/unit/v1/test_document.py
@@ -468,28 +468,18 @@ class TestDocumentReference(unittest.TestCase):
         self._get_helper(use_transaction=True)
 
     def _collections_helper(self, page_size=None, retry=None, timeout=None):
-        from google.api_core.page_iterator import Iterator
-        from google.api_core.page_iterator import Page
         from google.cloud.firestore_v1.collection import CollectionReference
         from google.cloud.firestore_v1 import _helpers
         from google.cloud.firestore_v1.services.firestore.client import FirestoreClient
 
-        # TODO(microgen): https://github.com/googleapis/gapic-generator-python/issues/516
-        class _Iterator(Iterator):
-            def __init__(self, pages):
-                super(_Iterator, self).__init__(client=None)
-                self._pages = pages
-                self.collection_ids = pages[0]
+        collection_ids = ["coll-1", "coll-2"]
 
-            def _next_page(self):
-                if self._pages:
-                    page, self._pages = self._pages[0], self._pages[1:]
-                    return Page(self, page, self.item_to_value)
+        class Pager(object):
+            def __iter__(self):
+                yield from collection_ids
 
-        collection_ids = ["coll-1", "coll-2"]
-        iterator = _Iterator(pages=[collection_ids])
         api_client = mock.create_autospec(FirestoreClient)
-        api_client.list_collection_ids.return_value = iterator
+        api_client.list_collection_ids.return_value = Pager()
 
         client = _make_client()
         client._firestore_api_internal = api_client
diff --git a/tests/unit/v1/test_order.py b/tests/unit/v1/test_order.py
index 4db7432..90d99e5 100644
--- a/tests/unit/v1/test_order.py
+++ b/tests/unit/v1/test_order.py
@@ -207,8 +207,6 @@ def _int_value(value):
 
 
 def _string_value(s):
-    if not isinstance(s, str):
-        s = str(s)
     return encode_value(s)