From da3f1cb020e929daa33c90e31a0d2f8cbd2a3833 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 9 Mar 2022 12:50:12 +0100 Subject: [PATCH 01/15] chore(deps): update all dependencies (#549) --- .github/workflows/mypy.yml | 4 ++-- .github/workflows/system_emulated.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index e1b1d1750e..e806343096 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -8,9 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "3.8" - name: Install nox diff --git a/.github/workflows/system_emulated.yml b/.github/workflows/system_emulated.yml index b2843e9b39..ec1d4050e9 100644 --- a/.github/workflows/system_emulated.yml +++ b/.github/workflows/system_emulated.yml @@ -12,15 +12,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: '3.7' - name: Setup GCloud SDK - uses: google-github-actions/setup-gcloud@v0.5.1 + uses: google-github-actions/setup-gcloud@v0.6.0 - name: Install / run Nox run: | From 72ea138b2f8a07588b0eafa5ccefa2feccf5fbfb Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 06:54:14 -0400 Subject: [PATCH 02/15] chore(python): use black==22.3.0 (#553) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(python): use black==22.3.0 Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe * ci: update black version in owlbot.py * ci: lint * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * ci: lint Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 5 +- .../services/firestore_admin/async_client.py | 92 +- .../services/firestore_admin/client.py | 175 ++- .../firestore_admin/transports/base.py | 34 +- .../firestore_admin/transports/grpc.py | 3 +- .../firestore_admin_v1/types/database.py | 32 +- .../cloud/firestore_admin_v1/types/field.py | 41 +- .../types/firestore_admin.py | 155 ++- .../cloud/firestore_admin_v1/types/index.py | 40 +- .../firestore_admin_v1/types/location.py | 5 +- .../firestore_admin_v1/types/operation.py | 175 ++- google/cloud/firestore_bundle/_helpers.py | 3 +- google/cloud/firestore_bundle/bundle.py | 29 +- google/cloud/firestore_bundle/types/bundle.py | 95 +- google/cloud/firestore_v1/_helpers.py | 19 +- google/cloud/firestore_v1/async_batch.py | 8 +- google/cloud/firestore_v1/async_client.py | 16 +- google/cloud/firestore_v1/async_collection.py | 9 +- google/cloud/firestore_v1/async_document.py | 12 +- google/cloud/firestore_v1/async_query.py | 12 +- google/cloud/firestore_v1/base_client.py | 12 +- google/cloud/firestore_v1/base_collection.py | 14 +- google/cloud/firestore_v1/base_document.py | 20 +- google/cloud/firestore_v1/base_query.py | 30 +- google/cloud/firestore_v1/base_transaction.py | 10 +- google/cloud/firestore_v1/batch.py | 4 +- google/cloud/firestore_v1/bulk_batch.py | 4 +- google/cloud/firestore_v1/bulk_writer.py | 42 +- google/cloud/firestore_v1/client.py | 23 +- google/cloud/firestore_v1/collection.py | 9 +- google/cloud/firestore_v1/document.py | 12 +- google/cloud/firestore_v1/query.py | 20 +- google/cloud/firestore_v1/rate_limiter.py | 3 +- .../services/firestore/async_client.py | 120 +- .../firestore_v1/services/firestore/client.py | 161 ++- .../services/firestore/transports/base.py | 14 +- .../services/firestore/transports/grpc.py | 3 +- google/cloud/firestore_v1/types/common.py | 36 +- google/cloud/firestore_v1/types/document.py | 105 +- google/cloud/firestore_v1/types/firestore.py | 511 ++++++-- google/cloud/firestore_v1/types/query.py | 119 +- google/cloud/firestore_v1/types/write.py | 127 +- google/cloud/firestore_v1/watch.py | 8 +- noxfile.py | 21 +- owlbot.py | 4 +- .../test_firestore_admin.py | 938 +++++++++++---- .../unit/gapic/firestore_v1/test_firestore.py | 1036 +++++++++++++---- tests/unit/v1/_test_helpers.py | 3 +- tests/unit/v1/conformance_tests.py | 251 +++- tests/unit/v1/test__helpers.py | 68 +- tests/unit/v1/test_async_batch.py | 6 +- tests/unit/v1/test_async_client.py | 10 +- tests/unit/v1/test_async_collection.py | 22 +- tests/unit/v1/test_async_document.py | 4 +- tests/unit/v1/test_async_query.py | 15 +- tests/unit/v1/test_async_transaction.py | 12 +- tests/unit/v1/test_base_batch.py | 9 +- tests/unit/v1/test_base_client.py | 31 +- tests/unit/v1/test_base_query.py | 16 +- tests/unit/v1/test_batch.py | 6 +- tests/unit/v1/test_bulk_writer.py | 151 ++- tests/unit/v1/test_bundle.py | 7 +- tests/unit/v1/test_client.py | 10 +- tests/unit/v1/test_collection.py | 8 +- tests/unit/v1/test_cross_language.py | 6 +- tests/unit/v1/test_order.py | 6 +- tests/unit/v1/test_query.py | 28 +- tests/unit/v1/test_rate_limiter.py | 36 +- tests/unit/v1/test_transaction.py | 4 +- tests/unit/v1/test_transforms.py | 5 +- tests/unit/v1/test_watch.py | 13 +- 72 files changed, 3983 insertions(+), 1112 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7cc1..87dd006115 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 4f103b26fd..3d1dd17333 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py index fb8b297ee5..66c3a6fd03 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py @@ -358,7 +358,12 @@ def sample_create_index(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -471,12 +476,20 @@ def sample_list_indexes(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListIndexesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -579,7 +592,12 @@ def sample_get_index(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -672,7 +690,10 @@ def sample_delete_index(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_field( @@ -774,7 +795,12 @@ def sample_get_field(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -894,7 +920,12 @@ def sample_update_field(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1016,12 +1047,20 @@ def sample_list_fields(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListFieldsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1135,7 +1174,12 @@ def sample_export_documents(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1257,7 +1301,12 @@ def sample_import_documents(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1357,7 +1406,12 @@ def sample_get_database(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1445,7 +1499,12 @@ def sample_list_databases(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1550,7 +1609,12 @@ def sample_update_database(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/client.py index cf506663d1..3040aa6754 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/client.py @@ -66,7 +66,10 @@ class FirestoreAdminClientMeta(type): _transport_registry["grpc"] = FirestoreAdminGrpcTransport _transport_registry["grpc_asyncio"] = FirestoreAdminGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[FirestoreAdminTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[FirestoreAdminTransport]: """Returns an appropriate transport class. Args: @@ -202,10 +205,16 @@ def transport(self) -> FirestoreAdminTransport: return self._transport @staticmethod - def collection_group_path(project: str, database: str, collection: str,) -> str: + def collection_group_path( + project: str, + database: str, + collection: str, + ) -> str: """Returns a fully-qualified collection_group string.""" return "projects/{project}/databases/{database}/collectionGroups/{collection}".format( - project=project, database=database, collection=collection, + project=project, + database=database, + collection=collection, ) @staticmethod @@ -218,10 +227,14 @@ def parse_collection_group_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def database_path(project: str, database: str,) -> str: + def database_path( + project: str, + database: str, + ) -> str: """Returns a fully-qualified database string.""" return "projects/{project}/databases/{database}".format( - project=project, database=database, + project=project, + database=database, ) @staticmethod @@ -231,10 +244,18 @@ def parse_database_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def field_path(project: str, database: str, collection: str, field: str,) -> str: + def field_path( + project: str, + database: str, + collection: str, + field: str, + ) -> str: """Returns a fully-qualified field string.""" return "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}".format( - project=project, database=database, collection=collection, field=field, + project=project, + database=database, + collection=collection, + field=field, ) @staticmethod @@ -247,10 +268,18 @@ def parse_field_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def index_path(project: str, database: str, collection: str, index: str,) -> str: + def index_path( + project: str, + database: str, + collection: str, + index: str, + ) -> str: """Returns a fully-qualified index string.""" return "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}".format( - project=project, database=database, collection=collection, index=index, + project=project, + database=database, + collection=collection, + index=index, ) @staticmethod @@ -263,7 +292,9 @@ def parse_index_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -276,9 +307,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -287,9 +322,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -298,9 +337,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -309,10 +352,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -592,7 +639,12 @@ def sample_create_index(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = gac_operation.from_gapic( @@ -694,12 +746,20 @@ def sample_list_indexes(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListIndexesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -791,7 +851,12 @@ def sample_get_index(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -873,7 +938,10 @@ def sample_delete_index(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_field( @@ -964,7 +1032,12 @@ def sample_get_field(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1084,7 +1157,12 @@ def sample_update_field(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = gac_operation.from_gapic( @@ -1195,12 +1273,20 @@ def sample_list_fields(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListFieldsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1314,7 +1400,12 @@ def sample_export_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = gac_operation.from_gapic( @@ -1436,7 +1527,12 @@ def sample_import_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = gac_operation.from_gapic( @@ -1536,7 +1632,12 @@ def sample_get_database(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1624,7 +1725,12 @@ def sample_list_databases(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1729,7 +1835,12 @@ def sample_update_database(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = gac_operation.from_gapic( diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py index 2950bebfdb..f4185f72c5 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py @@ -130,7 +130,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_index: gapic_v1.method.wrap_method( - self.create_index, default_timeout=60.0, client_info=client_info, + self.create_index, + default_timeout=60.0, + client_info=client_info, ), self.list_indexes: gapic_v1.method.wrap_method( self.list_indexes, @@ -197,7 +199,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.update_field: gapic_v1.method.wrap_method( - self.update_field, default_timeout=60.0, client_info=client_info, + self.update_field, + default_timeout=60.0, + client_info=client_info, ), self.list_fields: gapic_v1.method.wrap_method( self.list_fields, @@ -216,28 +220,38 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.export_documents: gapic_v1.method.wrap_method( - self.export_documents, default_timeout=60.0, client_info=client_info, + self.export_documents, + default_timeout=60.0, + client_info=client_info, ), self.import_documents: gapic_v1.method.wrap_method( - self.import_documents, default_timeout=60.0, client_info=client_info, + self.import_documents, + default_timeout=60.0, + client_info=client_info, ), self.get_database: gapic_v1.method.wrap_method( - self.get_database, default_timeout=None, client_info=client_info, + self.get_database, + default_timeout=None, + client_info=client_info, ), self.list_databases: gapic_v1.method.wrap_method( - self.list_databases, default_timeout=None, client_info=client_info, + self.list_databases, + default_timeout=None, + client_info=client_info, ), self.update_database: gapic_v1.method.wrap_method( - self.update_database, default_timeout=None, client_info=client_info, + self.update_database, + default_timeout=None, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py index d525cdc697..3ac3627df9 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py @@ -261,8 +261,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/firestore_admin_v1/types/database.py b/google/cloud/firestore_admin_v1/types/database.py index 319b8a6afb..bda0b819d6 100644 --- a/google/cloud/firestore_admin_v1/types/database.py +++ b/google/cloud/firestore_admin_v1/types/database.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.firestore.admin.v1", manifest={"Database",}, + package="google.firestore.admin.v1", + manifest={ + "Database", + }, ) @@ -66,11 +69,28 @@ class ConcurrencyMode(proto.Enum): PESSIMISTIC = 2 OPTIMISTIC_WITH_ENTITY_GROUPS = 3 - name = proto.Field(proto.STRING, number=1,) - location_id = proto.Field(proto.STRING, number=9,) - type_ = proto.Field(proto.ENUM, number=10, enum=DatabaseType,) - concurrency_mode = proto.Field(proto.ENUM, number=15, enum=ConcurrencyMode,) - etag = proto.Field(proto.STRING, number=99,) + name = proto.Field( + proto.STRING, + number=1, + ) + location_id = proto.Field( + proto.STRING, + number=9, + ) + type_ = proto.Field( + proto.ENUM, + number=10, + enum=DatabaseType, + ) + concurrency_mode = proto.Field( + proto.ENUM, + number=15, + enum=ConcurrencyMode, + ) + etag = proto.Field( + proto.STRING, + number=99, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_admin_v1/types/field.py b/google/cloud/firestore_admin_v1/types/field.py index e8ceeb06c3..b4263d4010 100644 --- a/google/cloud/firestore_admin_v1/types/field.py +++ b/google/cloud/firestore_admin_v1/types/field.py @@ -18,7 +18,12 @@ from google.cloud.firestore_admin_v1.types import index -__protobuf__ = proto.module(package="google.firestore.admin.v1", manifest={"Field",},) +__protobuf__ = proto.module( + package="google.firestore.admin.v1", + manifest={ + "Field", + }, +) class Field(proto.Message): @@ -86,13 +91,33 @@ class IndexConfig(proto.Message): will be ``false``. """ - indexes = proto.RepeatedField(proto.MESSAGE, number=1, message=index.Index,) - uses_ancestor_config = proto.Field(proto.BOOL, number=2,) - ancestor_field = proto.Field(proto.STRING, number=3,) - reverting = proto.Field(proto.BOOL, number=4,) - - name = proto.Field(proto.STRING, number=1,) - index_config = proto.Field(proto.MESSAGE, number=2, message=IndexConfig,) + indexes = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=index.Index, + ) + uses_ancestor_config = proto.Field( + proto.BOOL, + number=2, + ) + ancestor_field = proto.Field( + proto.STRING, + number=3, + ) + reverting = proto.Field( + proto.BOOL, + number=4, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + index_config = proto.Field( + proto.MESSAGE, + number=2, + message=IndexConfig, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_admin_v1/types/firestore_admin.py b/google/cloud/firestore_admin_v1/types/firestore_admin.py index fff3262326..15d11cc18a 100644 --- a/google/cloud/firestore_admin_v1/types/firestore_admin.py +++ b/google/cloud/firestore_admin_v1/types/firestore_admin.py @@ -54,7 +54,10 @@ class ListDatabasesRequest(proto.Message): ``projects/{project_id}`` """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) class ListDatabasesResponse(proto.Message): @@ -66,7 +69,9 @@ class ListDatabasesResponse(proto.Message): """ databases = proto.RepeatedField( - proto.MESSAGE, number=1, message=gfa_database.Database, + proto.MESSAGE, + number=1, + message=gfa_database.Database, ) @@ -80,7 +85,10 @@ class GetDatabaseRequest(proto.Message): ``projects/{project_id}/databases/{database_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateDatabaseRequest(proto.Message): @@ -94,15 +102,20 @@ class UpdateDatabaseRequest(proto.Message): The list of fields to be updated. """ - database = proto.Field(proto.MESSAGE, number=1, message=gfa_database.Database,) + database = proto.Field( + proto.MESSAGE, + number=1, + message=gfa_database.Database, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) class UpdateDatabaseMetadata(proto.Message): - r"""Metadata related to the update database operation. - """ + r"""Metadata related to the update database operation.""" class CreateIndexRequest(proto.Message): @@ -117,8 +130,15 @@ class CreateIndexRequest(proto.Message): Required. The composite index to create. """ - parent = proto.Field(proto.STRING, number=1,) - index = proto.Field(proto.MESSAGE, number=2, message=gfa_index.Index,) + parent = proto.Field( + proto.STRING, + number=1, + ) + index = proto.Field( + proto.MESSAGE, + number=2, + message=gfa_index.Index, + ) class ListIndexesRequest(proto.Message): @@ -139,10 +159,22 @@ class ListIndexesRequest(proto.Message): that may be used to get the next page of results. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListIndexesResponse(proto.Message): @@ -162,8 +194,15 @@ class ListIndexesResponse(proto.Message): def raw_page(self): return self - indexes = proto.RepeatedField(proto.MESSAGE, number=1, message=gfa_index.Index,) - next_page_token = proto.Field(proto.STRING, number=2,) + indexes = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gfa_index.Index, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetIndexRequest(proto.Message): @@ -176,7 +215,10 @@ class GetIndexRequest(proto.Message): ``projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class DeleteIndexRequest(proto.Message): @@ -189,7 +231,10 @@ class DeleteIndexRequest(proto.Message): ``projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateFieldRequest(proto.Message): @@ -205,9 +250,15 @@ class UpdateFieldRequest(proto.Message): in the field. """ - field = proto.Field(proto.MESSAGE, number=1, message=gfa_field.Field,) + field = proto.Field( + proto.MESSAGE, + number=1, + message=gfa_field.Field, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -221,7 +272,10 @@ class GetFieldRequest(proto.Message): ``projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListFieldsRequest(proto.Message): @@ -248,10 +302,22 @@ class ListFieldsRequest(proto.Message): that may be used to get the next page of results. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListFieldsResponse(proto.Message): @@ -271,8 +337,15 @@ class ListFieldsResponse(proto.Message): def raw_page(self): return self - fields = proto.RepeatedField(proto.MESSAGE, number=1, message=gfa_field.Field,) - next_page_token = proto.Field(proto.STRING, number=2,) + fields = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gfa_field.Field, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class ExportDocumentsRequest(proto.Message): @@ -298,9 +371,18 @@ class ExportDocumentsRequest(proto.Message): generated based on the start time. """ - name = proto.Field(proto.STRING, number=1,) - collection_ids = proto.RepeatedField(proto.STRING, number=2,) - output_uri_prefix = proto.Field(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + collection_ids = proto.RepeatedField( + proto.STRING, + number=2, + ) + output_uri_prefix = proto.Field( + proto.STRING, + number=3, + ) class ImportDocumentsRequest(proto.Message): @@ -321,9 +403,18 @@ class ImportDocumentsRequest(proto.Message): [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix]. """ - name = proto.Field(proto.STRING, number=1,) - collection_ids = proto.RepeatedField(proto.STRING, number=2,) - input_uri_prefix = proto.Field(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + collection_ids = proto.RepeatedField( + proto.STRING, + number=2, + ) + input_uri_prefix = proto.Field( + proto.STRING, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_admin_v1/types/index.py b/google/cloud/firestore_admin_v1/types/index.py index 827d773c6f..980087889a 100644 --- a/google/cloud/firestore_admin_v1/types/index.py +++ b/google/cloud/firestore_admin_v1/types/index.py @@ -16,7 +16,12 @@ import proto # type: ignore -__protobuf__ = proto.module(package="google.firestore.admin.v1", manifest={"Index",},) +__protobuf__ = proto.module( + package="google.firestore.admin.v1", + manifest={ + "Index", + }, +) class Index(proto.Message): @@ -118,9 +123,15 @@ class ArrayConfig(proto.Enum): ARRAY_CONFIG_UNSPECIFIED = 0 CONTAINS = 1 - field_path = proto.Field(proto.STRING, number=1,) + field_path = proto.Field( + proto.STRING, + number=1, + ) order = proto.Field( - proto.ENUM, number=2, oneof="value_mode", enum="Index.IndexField.Order", + proto.ENUM, + number=2, + oneof="value_mode", + enum="Index.IndexField.Order", ) array_config = proto.Field( proto.ENUM, @@ -129,10 +140,25 @@ class ArrayConfig(proto.Enum): enum="Index.IndexField.ArrayConfig", ) - name = proto.Field(proto.STRING, number=1,) - query_scope = proto.Field(proto.ENUM, number=2, enum=QueryScope,) - fields = proto.RepeatedField(proto.MESSAGE, number=3, message=IndexField,) - state = proto.Field(proto.ENUM, number=4, enum=State,) + name = proto.Field( + proto.STRING, + number=1, + ) + query_scope = proto.Field( + proto.ENUM, + number=2, + enum=QueryScope, + ) + fields = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=IndexField, + ) + state = proto.Field( + proto.ENUM, + number=4, + enum=State, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_admin_v1/types/location.py b/google/cloud/firestore_admin_v1/types/location.py index be11f99cf8..2c209bbb03 100644 --- a/google/cloud/firestore_admin_v1/types/location.py +++ b/google/cloud/firestore_admin_v1/types/location.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.firestore.admin.v1", manifest={"LocationMetadata",}, + package="google.firestore.admin.v1", + manifest={ + "LocationMetadata", + }, ) diff --git a/google/cloud/firestore_admin_v1/types/operation.py b/google/cloud/firestore_admin_v1/types/operation.py index 543ac2f0b0..744d77bc32 100644 --- a/google/cloud/firestore_admin_v1/types/operation.py +++ b/google/cloud/firestore_admin_v1/types/operation.py @@ -70,12 +70,35 @@ class IndexOperationMetadata(proto.Message): The progress, in bytes, of this operation. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - index = proto.Field(proto.STRING, number=3,) - state = proto.Field(proto.ENUM, number=4, enum="OperationState",) - progress_documents = proto.Field(proto.MESSAGE, number=5, message="Progress",) - progress_bytes = proto.Field(proto.MESSAGE, number=6, message="Progress",) + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + index = proto.Field( + proto.STRING, + number=3, + ) + state = proto.Field( + proto.ENUM, + number=4, + enum="OperationState", + ) + progress_documents = proto.Field( + proto.MESSAGE, + number=5, + message="Progress", + ) + progress_bytes = proto.Field( + proto.MESSAGE, + number=6, + message="Progress", + ) class FieldOperationMetadata(proto.Message): @@ -128,17 +151,46 @@ class ChangeType(proto.Enum): number=1, enum="FieldOperationMetadata.IndexConfigDelta.ChangeType", ) - index = proto.Field(proto.MESSAGE, number=2, message=gfa_index.Index,) + index = proto.Field( + proto.MESSAGE, + number=2, + message=gfa_index.Index, + ) - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - field = proto.Field(proto.STRING, number=3,) + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + field = proto.Field( + proto.STRING, + number=3, + ) index_config_deltas = proto.RepeatedField( - proto.MESSAGE, number=4, message=IndexConfigDelta, + proto.MESSAGE, + number=4, + message=IndexConfigDelta, + ) + state = proto.Field( + proto.ENUM, + number=5, + enum="OperationState", + ) + progress_documents = proto.Field( + proto.MESSAGE, + number=6, + message="Progress", + ) + progress_bytes = proto.Field( + proto.MESSAGE, + number=7, + message="Progress", ) - state = proto.Field(proto.ENUM, number=5, enum="OperationState",) - progress_documents = proto.Field(proto.MESSAGE, number=6, message="Progress",) - progress_bytes = proto.Field(proto.MESSAGE, number=7, message="Progress",) class ExportDocumentsMetadata(proto.Message): @@ -166,13 +218,39 @@ class ExportDocumentsMetadata(proto.Message): Where the entities are being exported to. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - operation_state = proto.Field(proto.ENUM, number=3, enum="OperationState",) - progress_documents = proto.Field(proto.MESSAGE, number=4, message="Progress",) - progress_bytes = proto.Field(proto.MESSAGE, number=5, message="Progress",) - collection_ids = proto.RepeatedField(proto.STRING, number=6,) - output_uri_prefix = proto.Field(proto.STRING, number=7,) + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + operation_state = proto.Field( + proto.ENUM, + number=3, + enum="OperationState", + ) + progress_documents = proto.Field( + proto.MESSAGE, + number=4, + message="Progress", + ) + progress_bytes = proto.Field( + proto.MESSAGE, + number=5, + message="Progress", + ) + collection_ids = proto.RepeatedField( + proto.STRING, + number=6, + ) + output_uri_prefix = proto.Field( + proto.STRING, + number=7, + ) class ImportDocumentsMetadata(proto.Message): @@ -200,13 +278,39 @@ class ImportDocumentsMetadata(proto.Message): The location of the documents being imported. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - operation_state = proto.Field(proto.ENUM, number=3, enum="OperationState",) - progress_documents = proto.Field(proto.MESSAGE, number=4, message="Progress",) - progress_bytes = proto.Field(proto.MESSAGE, number=5, message="Progress",) - collection_ids = proto.RepeatedField(proto.STRING, number=6,) - input_uri_prefix = proto.Field(proto.STRING, number=7,) + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + operation_state = proto.Field( + proto.ENUM, + number=3, + enum="OperationState", + ) + progress_documents = proto.Field( + proto.MESSAGE, + number=4, + message="Progress", + ) + progress_bytes = proto.Field( + proto.MESSAGE, + number=5, + message="Progress", + ) + collection_ids = proto.RepeatedField( + proto.STRING, + number=6, + ) + input_uri_prefix = proto.Field( + proto.STRING, + number=7, + ) class ExportDocumentsResponse(proto.Message): @@ -222,7 +326,10 @@ class ExportDocumentsResponse(proto.Message): operation completes successfully. """ - output_uri_prefix = proto.Field(proto.STRING, number=1,) + output_uri_prefix = proto.Field( + proto.STRING, + number=1, + ) class Progress(proto.Message): @@ -237,8 +344,14 @@ class Progress(proto.Message): The amount of work completed. """ - estimated_work = proto.Field(proto.INT64, number=1,) - completed_work = proto.Field(proto.INT64, number=2,) + estimated_work = proto.Field( + proto.INT64, + number=1, + ) + completed_work = proto.Field( + proto.INT64, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_bundle/_helpers.py b/google/cloud/firestore_bundle/_helpers.py index 8b7ce7a698..bd04833a00 100644 --- a/google/cloud/firestore_bundle/_helpers.py +++ b/google/cloud/firestore_bundle/_helpers.py @@ -3,8 +3,7 @@ def limit_type_of_query(query: BaseQuery) -> int: - """BundledQuery.LimitType equivalent of this query. - """ + """BundledQuery.LimitType equivalent of this query.""" return ( BundledQuery.LimitType.LAST diff --git a/google/cloud/firestore_bundle/bundle.py b/google/cloud/firestore_bundle/bundle.py index 73a53aadb5..0f9aaed976 100644 --- a/google/cloud/firestore_bundle/bundle.py +++ b/google/cloud/firestore_bundle/bundle.py @@ -116,7 +116,8 @@ def add_document(self, snapshot: DocumentSnapshot) -> "FirestoreBundle": # equivalent to: # `if snapshot.read_time > original_document.snapshot.read_time` or _helpers.compare_timestamps( - snapshot.read_time, original_document.snapshot.read_time, + snapshot.read_time, + original_document.snapshot.read_time, ) >= 0 ) @@ -202,15 +203,22 @@ def _save_documents_from_query( return _read_time def _save_named_query( - self, name: str, query: BaseQuery, read_time: datetime.datetime, + self, + name: str, + query: BaseQuery, + read_time: datetime.datetime, ) -> None: self.named_queries[name] = self._build_named_query( - name=name, snapshot=query, read_time=read_time, + name=name, + snapshot=query, + read_time=read_time, ) self._update_last_read_time(read_time) async def _process_async_query( - self, snapshot: AsyncQuery, query_name: str, + self, + snapshot: AsyncQuery, + query_name: str, ) -> datetime.datetime: doc: DocumentSnapshot _read_time = datetime.datetime.min.replace(tzinfo=UTC) @@ -222,7 +230,10 @@ async def _process_async_query( return _read_time def _build_named_query( - self, name: str, snapshot: BaseQuery, read_time: datetime.datetime, + self, + name: str, + snapshot: BaseQuery, + read_time: datetime.datetime, ) -> NamedQuery: return NamedQuery( name=name, @@ -334,7 +345,9 @@ def build(self) -> str: ) document_count += 1 buffer += self._compile_bundle_element( - BundleElement(document=bundled_document.snapshot._to_protobuf()._pb,) + BundleElement( + document=bundled_document.snapshot._to_protobuf()._pb, + ) ) metadata: BundleElement = BundleElement( @@ -364,7 +377,9 @@ class _BundledDocument: of a document to be bundled.""" def __init__( - self, snapshot: DocumentSnapshot, metadata: BundledDocumentMetadata, + self, + snapshot: DocumentSnapshot, + metadata: BundledDocumentMetadata, ) -> None: self.snapshot = snapshot self.metadata = metadata diff --git a/google/cloud/firestore_bundle/types/bundle.py b/google/cloud/firestore_bundle/types/bundle.py index e5f0bba288..526623fbe1 100644 --- a/google/cloud/firestore_bundle/types/bundle.py +++ b/google/cloud/firestore_bundle/types/bundle.py @@ -55,11 +55,21 @@ class LimitType(proto.Enum): FIRST = 0 LAST = 1 - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) structured_query = proto.Field( - proto.MESSAGE, number=2, oneof="query_type", message=query_pb2.StructuredQuery, + proto.MESSAGE, + number=2, + oneof="query_type", + message=query_pb2.StructuredQuery, + ) + limit_type = proto.Field( + proto.ENUM, + number=3, + enum=LimitType, ) - limit_type = proto.Field(proto.ENUM, number=3, enum=LimitType,) class NamedQuery(proto.Message): @@ -82,9 +92,20 @@ class NamedQuery(proto.Message): client SDKs. """ - name = proto.Field(proto.STRING, number=1,) - bundled_query = proto.Field(proto.MESSAGE, number=2, message="BundledQuery",) - read_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + name = proto.Field( + proto.STRING, + number=1, + ) + bundled_query = proto.Field( + proto.MESSAGE, + number=2, + message="BundledQuery", + ) + read_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) class BundledDocumentMetadata(proto.Message): @@ -103,10 +124,23 @@ class BundledDocumentMetadata(proto.Message): this document matches to. """ - name = proto.Field(proto.STRING, number=1,) - read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - exists = proto.Field(proto.BOOL, number=3,) - queries = proto.RepeatedField(proto.STRING, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + read_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + exists = proto.Field( + proto.BOOL, + number=3, + ) + queries = proto.RepeatedField( + proto.STRING, + number=4, + ) class BundleMetadata(proto.Message): @@ -127,11 +161,27 @@ class BundleMetadata(proto.Message): ``BundleMetadata``. """ - id = proto.Field(proto.STRING, number=1,) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - version = proto.Field(proto.UINT32, number=3,) - total_documents = proto.Field(proto.UINT32, number=4,) - total_bytes = proto.Field(proto.UINT64, number=5,) + id = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + version = proto.Field( + proto.UINT32, + number=3, + ) + total_documents = proto.Field( + proto.UINT32, + number=4, + ) + total_bytes = proto.Field( + proto.UINT64, + number=5, + ) class BundleElement(proto.Message): @@ -164,10 +214,16 @@ class BundleElement(proto.Message): """ metadata = proto.Field( - proto.MESSAGE, number=1, oneof="element_type", message="BundleMetadata", + proto.MESSAGE, + number=1, + oneof="element_type", + message="BundleMetadata", ) named_query = proto.Field( - proto.MESSAGE, number=2, oneof="element_type", message="NamedQuery", + proto.MESSAGE, + number=2, + oneof="element_type", + message="NamedQuery", ) document_metadata = proto.Field( proto.MESSAGE, @@ -176,7 +232,10 @@ class BundleElement(proto.Message): message="BundledDocumentMetadata", ) document = proto.Field( - proto.MESSAGE, number=4, oneof="element_type", message=document_pb2.Document, + proto.MESSAGE, + number=4, + oneof="element_type", + message=document_pb2.Document, ) diff --git a/google/cloud/firestore_v1/_helpers.py b/google/cloud/firestore_v1/_helpers.py index 05e8c26790..c800a194ee 100644 --- a/google/cloud/firestore_v1/_helpers.py +++ b/google/cloud/firestore_v1/_helpers.py @@ -476,7 +476,7 @@ def get_field_value(document_data, field_path) -> Any: class DocumentExtractor(object): - """ Break document data up into actual data and transforms. + """Break document data up into actual data and transforms. Handle special values such as ``DELETE_FIELD``, ``SERVER_TIMESTAMP``. @@ -720,8 +720,7 @@ def pbs_for_set_no_merge(document_path, document_data) -> List[types.write.Write class DocumentExtractorForMerge(DocumentExtractor): - """ Break document data up into actual data and transforms. - """ + """Break document data up into actual data and transforms.""" def __init__(self, document_data) -> None: super(DocumentExtractorForMerge, self).__init__(document_data) @@ -874,8 +873,7 @@ def pbs_for_set_with_merge( class DocumentExtractorForUpdate(DocumentExtractor): - """ Break document data up into actual data and transforms. - """ + """Break document data up into actual data and transforms.""" def __init__(self, document_data) -> None: super(DocumentExtractorForUpdate, self).__init__(document_data) @@ -1134,7 +1132,8 @@ def build_timestamp( def compare_timestamps( - ts1: Union[Timestamp, datetime.datetime], ts2: Union[Timestamp, datetime.datetime], + ts1: Union[Timestamp, datetime.datetime], + ts2: Union[Timestamp, datetime.datetime], ) -> int: ts1 = build_timestamp(ts1) if not isinstance(ts1, Timestamp) else ts1 ts2 = build_timestamp(ts2) if not isinstance(ts2, Timestamp) else ts2 @@ -1234,7 +1233,9 @@ def deserialize_bundle( # Now, finally add the metadata element bundle._add_bundle_element( - metadata_bundle_element, client=client, type="metadata", # type: ignore + metadata_bundle_element, + client=client, + type="metadata", # type: ignore ) return bundle @@ -1295,7 +1296,9 @@ def _get_documents_from_bundle( def _get_document_from_bundle( - bundle, *, document_id: str, + bundle, + *, + document_id: str, ) -> Optional["google.cloud.firestore.DocumentSnapshot"]: # type: ignore bundled_doc = bundle.documents.get(document_id) if bundled_doc: diff --git a/google/cloud/firestore_v1/async_batch.py b/google/cloud/firestore_v1/async_batch.py index 87033d73ba..e33d28f136 100644 --- a/google/cloud/firestore_v1/async_batch.py +++ b/google/cloud/firestore_v1/async_batch.py @@ -37,7 +37,9 @@ def __init__(self, client) -> None: super(AsyncWriteBatch, self).__init__(client=client) async def commit( - self, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, + self, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, ) -> list: """Commit the changes accumulated in this batch. @@ -56,7 +58,9 @@ async def commit( request, kwargs = self._prep_commit(retry, timeout) commit_response = await self._client._firestore_api.commit( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) self._write_pbs = [] diff --git a/google/cloud/firestore_v1/async_client.py b/google/cloud/firestore_v1/async_client.py index 275f904fb9..c7f2b5bbfa 100644 --- a/google/cloud/firestore_v1/async_client.py +++ b/google/cloud/firestore_v1/async_client.py @@ -275,14 +275,18 @@ async def get_all( ) response_iterator = await self._firestore_api.batch_get_documents( - request=request, metadata=self._rpc_metadata, **kwargs, + request=request, + metadata=self._rpc_metadata, + **kwargs, ) async for get_doc_response in response_iterator: yield _parse_batch_get(get_doc_response, reference_map, self) async def collections( - self, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, + self, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, ) -> AsyncGenerator[AsyncCollectionReference, Any]: """List top-level collections of the client's database. @@ -298,7 +302,9 @@ async def collections( """ request, kwargs = self._prep_collections(retry, timeout) iterator = await self._firestore_api.list_collection_ids( - request=request, metadata=self._rpc_metadata, **kwargs, + request=request, + metadata=self._rpc_metadata, + **kwargs, ) async for collection_id in iterator: @@ -335,7 +341,9 @@ async def recursive_delete( bulk_writer = self.bulk_writer() return await self._recursive_delete( - reference, bulk_writer=bulk_writer, chunk_size=chunk_size, + reference, + bulk_writer=bulk_writer, + chunk_size=chunk_size, ) async def _recursive_delete( diff --git a/google/cloud/firestore_v1/async_collection.py b/google/cloud/firestore_v1/async_collection.py index f16992e887..52847a3dcf 100644 --- a/google/cloud/firestore_v1/async_collection.py +++ b/google/cloud/firestore_v1/async_collection.py @@ -111,7 +111,10 @@ async def add( If ``document_id`` is provided and the document already exists. """ document_ref, kwargs = self._prep_add( - document_data, document_id, retry, timeout, + document_data, + document_id, + retry, + timeout, ) write_result = await document_ref.create(document_data, **kwargs) return write_result.update_time, document_ref @@ -159,7 +162,9 @@ async def list_documents( request, kwargs = self._prep_list_documents(page_size, retry, timeout) iterator = await self._client._firestore_api.list_documents( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) async for i in iterator: yield _item_to_document_ref(self, i) diff --git a/google/cloud/firestore_v1/async_document.py b/google/cloud/firestore_v1/async_document.py index c11e6db2d4..a6606963e3 100644 --- a/google/cloud/firestore_v1/async_document.py +++ b/google/cloud/firestore_v1/async_document.py @@ -316,7 +316,9 @@ async def delete( request, kwargs = self._prep_delete(option, retry, timeout) commit_response = await self._client._firestore_api.commit( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) return commit_response.commit_time @@ -363,7 +365,9 @@ async def get( request, kwargs = self._prep_batch_get(field_paths, transaction, retry, timeout) response_iter = await self._client._firestore_api.batch_get_documents( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) async for resp in response_iter: @@ -414,7 +418,9 @@ async def collections( request, kwargs = self._prep_collections(page_size, retry, timeout) iterator = await self._client._firestore_api.list_collection_ids( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) async for collection_id in iterator: diff --git a/google/cloud/firestore_v1/async_query.py b/google/cloud/firestore_v1/async_query.py index 418f4f157c..1ad0459f74 100644 --- a/google/cloud/firestore_v1/async_query.py +++ b/google/cloud/firestore_v1/async_query.py @@ -250,11 +250,15 @@ async def stream( The next document that fulfills the query. """ request, expected_prefix, kwargs = self._prep_stream( - transaction, retry, timeout, + transaction, + retry, + timeout, ) response_iterator = await self._client._firestore_api.run_query( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) async for response in response_iterator: @@ -345,7 +349,9 @@ async def get_partitions( """ request, kwargs = self._prep_get_partitions(partition_count, retry, timeout) pager = await self._client._firestore_api.partition_query( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) start_at = None diff --git a/google/cloud/firestore_v1/base_client.py b/google/cloud/firestore_v1/base_client.py index 87c01deef5..8c1ff6f3a8 100644 --- a/google/cloud/firestore_v1/base_client.py +++ b/google/cloud/firestore_v1/base_client.py @@ -361,9 +361,7 @@ def field_path(*field_names: str) -> str: @staticmethod def write_option( **kwargs, - ) -> Union[ - _helpers.ExistsOption, _helpers.LastUpdateOption, - ]: + ) -> Union[_helpers.ExistsOption, _helpers.LastUpdateOption]: """Create a write option for write operations. Write operations include :meth:`~google.cloud.DocumentReference.set`, @@ -445,7 +443,9 @@ def get_all( raise NotImplementedError def _prep_collections( - self, retry: retries.Retry = None, timeout: float = None, + self, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[dict, dict]: """Shared setup for async/sync :meth:`collections`.""" request = {"parent": "{}/documents".format(self._database_string)} @@ -454,7 +454,9 @@ def _prep_collections( return request, kwargs def collections( - self, retry: retries.Retry = None, timeout: float = None, + self, + retry: retries.Retry = None, + timeout: float = None, ) -> Union[ AsyncGenerator[BaseCollectionReference, Any], Generator[BaseCollectionReference, Any, Any], diff --git a/google/cloud/firestore_v1/base_collection.py b/google/cloud/firestore_v1/base_collection.py index c3091e75aa..681bcd781e 100644 --- a/google/cloud/firestore_v1/base_collection.py +++ b/google/cloud/firestore_v1/base_collection.py @@ -178,7 +178,10 @@ def add( raise NotImplementedError def _prep_list_documents( - self, page_size: int = None, retry: retries.Retry = None, timeout: float = None, + self, + page_size: int = None, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[dict, dict]: """Shared setup for async / sync :method:`list_documents`""" parent, _ = self._parent_info() @@ -197,7 +200,10 @@ def _prep_list_documents( return request, kwargs def list_documents( - self, page_size: int = None, retry: retries.Retry = None, timeout: float = None, + self, + page_size: int = None, + retry: retries.Retry = None, + timeout: float = None, ) -> Union[ Generator[DocumentReference, Any, Any], AsyncGenerator[DocumentReference, Any] ]: @@ -438,7 +444,9 @@ def end_at( return query.end_at(document_fields) def _prep_get_or_stream( - self, retry: retries.Retry = None, timeout: float = None, + self, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[Any, dict]: """Shared setup for async / sync :meth:`get` / :meth:`stream`""" query = self._query() diff --git a/google/cloud/firestore_v1/base_document.py b/google/cloud/firestore_v1/base_document.py index a4ab469df6..3997b5b4db 100644 --- a/google/cloud/firestore_v1/base_document.py +++ b/google/cloud/firestore_v1/base_document.py @@ -187,7 +187,10 @@ def collection(self, collection_id: str) -> Any: return self._client.collection(*child_path) def _prep_create( - self, document_data: dict, retry: retries.Retry = None, timeout: float = None, + self, + document_data: dict, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[Any, dict]: batch = self._client.batch() batch.create(self, document_data) @@ -196,7 +199,10 @@ def _prep_create( return batch, kwargs def create( - self, document_data: dict, retry: retries.Retry = None, timeout: float = None, + self, + document_data: dict, + retry: retries.Retry = None, + timeout: float = None, ) -> NoReturn: raise NotImplementedError @@ -305,7 +311,10 @@ def get( raise NotImplementedError def _prep_collections( - self, page_size: int = None, retry: retries.Retry = None, timeout: float = None, + self, + page_size: int = None, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[dict, dict]: """Shared setup for async/sync :meth:`collections`.""" request = {"parent": self._document_path, "page_size": page_size} @@ -314,7 +323,10 @@ def _prep_collections( return request, kwargs def collections( - self, page_size: int = None, retry: retries.Retry = None, timeout: float = None, + self, + page_size: int = None, + retry: retries.Retry = None, + timeout: float = None, ) -> None: raise NotImplementedError diff --git a/google/cloud/firestore_v1/base_query.py b/google/cloud/firestore_v1/base_query.py index 537288d160..150940c0d4 100644 --- a/google/cloud/firestore_v1/base_query.py +++ b/google/cloud/firestore_v1/base_query.py @@ -807,12 +807,18 @@ def _to_protobuf(self) -> StructuredQuery: return query.StructuredQuery(**query_kwargs) def get( - self, transaction=None, retry: retries.Retry = None, timeout: float = None, + self, + transaction=None, + retry: retries.Retry = None, + timeout: float = None, ) -> Iterable[DocumentSnapshot]: raise NotImplementedError def _prep_stream( - self, transaction=None, retry: retries.Retry = None, timeout: float = None, + self, + transaction=None, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[dict, str, dict]: """Shared setup for async / sync :meth:`stream`""" if self._limit_to_last: @@ -832,7 +838,10 @@ def _prep_stream( return request, expected_prefix, kwargs def stream( - self, transaction=None, retry: retries.Retry = None, timeout: float = None, + self, + transaction=None, + retry: retries.Retry = None, + timeout: float = None, ) -> Generator[document.DocumentSnapshot, Any, None]: raise NotImplementedError @@ -1123,7 +1132,8 @@ class BaseCollectionGroup(BaseQuery): _PARTITION_QUERY_ORDER = ( BaseQuery._make_order( - field_path_module.FieldPath.document_id(), BaseQuery.ASCENDING, + field_path_module.FieldPath.document_id(), + BaseQuery.ASCENDING, ), ) @@ -1175,7 +1185,10 @@ def _get_query_class(self): raise NotImplementedError def _prep_get_partitions( - self, partition_count, retry: retries.Retry = None, timeout: float = None, + self, + partition_count, + retry: retries.Retry = None, + timeout: float = None, ) -> Tuple[dict, dict]: self._validate_partition_query() parent_path, expected_prefix = self._parent._parent_info() @@ -1197,7 +1210,10 @@ def _prep_get_partitions( return request, kwargs def get_partitions( - self, partition_count, retry: retries.Retry = None, timeout: float = None, + self, + partition_count, + retry: retries.Retry = None, + timeout: float = None, ) -> NoReturn: raise NotImplementedError @@ -1222,7 +1238,7 @@ class QueryPartition: Cursor for first query result after the last result included in the partition. If `None`, the partition runs to the end of the result set. - """ + """ def __init__(self, query, start_at, end_at): self._query = query diff --git a/google/cloud/firestore_v1/base_transaction.py b/google/cloud/firestore_v1/base_transaction.py index 7774a3f03d..1453212459 100644 --- a/google/cloud/firestore_v1/base_transaction.py +++ b/google/cloud/firestore_v1/base_transaction.py @@ -143,12 +143,18 @@ def _commit(self) -> Union[list, Coroutine[Any, Any, list]]: raise NotImplementedError def get_all( - self, references: list, retry: retries.Retry = None, timeout: float = None, + self, + references: list, + retry: retries.Retry = None, + timeout: float = None, ) -> NoReturn: raise NotImplementedError def get( - self, ref_or_query, retry: retries.Retry = None, timeout: float = None, + self, + ref_or_query, + retry: retries.Retry = None, + timeout: float = None, ) -> NoReturn: raise NotImplementedError diff --git a/google/cloud/firestore_v1/batch.py b/google/cloud/firestore_v1/batch.py index 2621efc205..5fa7880410 100644 --- a/google/cloud/firestore_v1/batch.py +++ b/google/cloud/firestore_v1/batch.py @@ -57,7 +57,9 @@ def commit( request, kwargs = self._prep_commit(retry, timeout) commit_response = self._client._firestore_api.commit( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) self._write_pbs = [] diff --git a/google/cloud/firestore_v1/bulk_batch.py b/google/cloud/firestore_v1/bulk_batch.py index a525a09620..7df48e586a 100644 --- a/google/cloud/firestore_v1/bulk_batch.py +++ b/google/cloud/firestore_v1/bulk_batch.py @@ -71,7 +71,9 @@ def commit( _api = self._client._firestore_api save_response: BatchWriteResponse = _api.batch_write( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) self._write_pbs = [] diff --git a/google/cloud/firestore_v1/bulk_writer.py b/google/cloud/firestore_v1/bulk_writer.py index e52061c03d..bd0af8c87d 100644 --- a/google/cloud/firestore_v1/bulk_writer.py +++ b/google/cloud/firestore_v1/bulk_writer.py @@ -169,7 +169,9 @@ def _process_response( should_retry: bool = self._error_callback( # BulkWriteFailure BulkWriteFailure( - operation=operation, code=status.code, message=status.message, + operation=operation, + code=status.code, + message=status.message, ), # BulkWriter self, @@ -179,12 +181,13 @@ def _process_response( self._retry_operation(operation) def _retry_operation( - self, operation: "BulkWriterOperation", + self, + operation: "BulkWriterOperation", ) -> concurrent.futures.Future: delay: int = 0 if self._options.retry == BulkRetry.exponential: - delay = operation.attempts ** 2 # pragma: NO COVER + delay = operation.attempts**2 # pragma: NO COVER elif self._options.retry == BulkRetry.linear: delay = operation.attempts @@ -195,7 +198,8 @@ def _retry_operation( # able to do this because `OperationRetry` instances are entirely sortable # by their `run_at` value. bisect.insort( - self._retries, OperationRetry(operation=operation, run_at=run_at), + self._retries, + OperationRetry(operation=operation, run_at=run_at), ) def _send(self, batch: BulkWriteBatch) -> BatchWriteResponse: @@ -313,7 +317,9 @@ def __init__( @staticmethod def _default_on_batch( - batch: BulkWriteBatch, response: BatchWriteResponse, bulk_writer: "BulkWriter", + batch: BulkWriteBatch, + response: BatchWriteResponse, + bulk_writer: "BulkWriter", ) -> None: pass @@ -527,7 +533,10 @@ def _request_send(self, batch_size: int) -> bool: return True def create( - self, reference: BaseDocumentReference, document_data: Dict, attempts: int = 0, + self, + reference: BaseDocumentReference, + document_data: Dict, + attempts: int = 0, ) -> None: """Adds a `create` pb to the in-progress batch. @@ -553,7 +562,9 @@ def create( self._operations.append( BulkWriterCreateOperation( - reference=reference, document_data=document_data, attempts=attempts, + reference=reference, + document_data=document_data, + attempts=attempts, ), ) self._operations_document_paths.append(reference._document_path) @@ -590,7 +601,9 @@ def delete( self._operations.append( BulkWriterDeleteOperation( - reference=reference, option=option, attempts=attempts, + reference=reference, + option=option, + attempts=attempts, ), ) self._operations_document_paths.append(reference._document_path) @@ -730,11 +743,15 @@ def add_to_batch(self, batch: BulkWriteBatch): assert isinstance(batch, BulkWriteBatch) if isinstance(self, BulkWriterCreateOperation): return batch.create( - reference=self.reference, document_data=self.document_data, + reference=self.reference, + document_data=self.document_data, ) if isinstance(self, BulkWriterDeleteOperation): - return batch.delete(reference=self.reference, option=self.option,) + return batch.delete( + reference=self.reference, + option=self.option, + ) if isinstance(self, BulkWriterSetOperation): return batch.set( @@ -874,7 +891,6 @@ class BulkWriterDeleteOperation(BulkWriterOperation): option: Optional[_helpers.WriteOption] attempts: int = 0 - except ImportError: # Note: When support for Python 3.6 is dropped and `dataclasses` is reliably @@ -921,7 +937,9 @@ class OperationRetry(BaseOperationRetry): the future.""" def __init__( - self, operation: BulkWriterOperation, run_at: datetime.datetime, + self, + operation: BulkWriterOperation, + run_at: datetime.datetime, ): self.operation = operation self.run_at = run_at diff --git a/google/cloud/firestore_v1/client.py b/google/cloud/firestore_v1/client.py index 345f833c98..9426323d97 100644 --- a/google/cloud/firestore_v1/client.py +++ b/google/cloud/firestore_v1/client.py @@ -260,14 +260,18 @@ def get_all( ) response_iterator = self._firestore_api.batch_get_documents( - request=request, metadata=self._rpc_metadata, **kwargs, + request=request, + metadata=self._rpc_metadata, + **kwargs, ) for get_doc_response in response_iterator: yield _parse_batch_get(get_doc_response, reference_map, self) def collections( - self, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, + self, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, ) -> Generator[Any, Any, None]: """List top-level collections of the client's database. @@ -284,7 +288,9 @@ def collections( request, kwargs = self._prep_collections(retry, timeout) iterator = self._firestore_api.list_collection_ids( - request=request, metadata=self._rpc_metadata, **kwargs, + request=request, + metadata=self._rpc_metadata, + **kwargs, ) for collection_id in iterator: @@ -321,7 +327,11 @@ def recursive_delete( if bulk_writer is None: bulk_writer or self.bulk_writer() - return self._recursive_delete(reference, bulk_writer, chunk_size=chunk_size,) + return self._recursive_delete( + reference, + bulk_writer, + chunk_size=chunk_size, + ) def _recursive_delete( self, @@ -351,7 +361,10 @@ def _recursive_delete( col_ref: CollectionReference for col_ref in reference.collections(): num_deleted += self._recursive_delete( - col_ref, bulk_writer, chunk_size=chunk_size, depth=depth + 1, + col_ref, + bulk_writer, + chunk_size=chunk_size, + depth=depth + 1, ) num_deleted += 1 bulk_writer.delete(reference) diff --git a/google/cloud/firestore_v1/collection.py b/google/cloud/firestore_v1/collection.py index 3488275dd7..c0fb55b78e 100644 --- a/google/cloud/firestore_v1/collection.py +++ b/google/cloud/firestore_v1/collection.py @@ -102,7 +102,10 @@ def add( If ``document_id`` is provided and the document already exists. """ document_ref, kwargs = self._prep_add( - document_data, document_id, retry, timeout, + document_data, + document_id, + retry, + timeout, ) write_result = document_ref.create(document_data, **kwargs) return write_result.update_time, document_ref @@ -133,7 +136,9 @@ def list_documents( request, kwargs = self._prep_list_documents(page_size, retry, timeout) iterator = self._client._firestore_api.list_documents( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) return (_item_to_document_ref(self, i) for i in iterator) diff --git a/google/cloud/firestore_v1/document.py b/google/cloud/firestore_v1/document.py index acdab69e7a..00d682d2bb 100644 --- a/google/cloud/firestore_v1/document.py +++ b/google/cloud/firestore_v1/document.py @@ -352,7 +352,9 @@ def delete( request, kwargs = self._prep_delete(option, retry, timeout) commit_response = self._client._firestore_api.commit( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) return commit_response.commit_time @@ -399,7 +401,9 @@ def get( request, kwargs = self._prep_batch_get(field_paths, transaction, retry, timeout) response_iter = self._client._firestore_api.batch_get_documents( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) get_doc_response = next(response_iter, None) @@ -451,7 +455,9 @@ def collections( request, kwargs = self._prep_collections(page_size, retry, timeout) iterator = self._client._firestore_api.list_collection_ids( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) for collection_id in iterator: diff --git a/google/cloud/firestore_v1/query.py b/google/cloud/firestore_v1/query.py index 25ac92cc2f..49e8013c87 100644 --- a/google/cloud/firestore_v1/query.py +++ b/google/cloud/firestore_v1/query.py @@ -210,11 +210,15 @@ def _chunkify( def _get_stream_iterator(self, transaction, retry, timeout): """Helper method for :meth:`stream`.""" request, expected_prefix, kwargs = self._prep_stream( - transaction, retry, timeout, + transaction, + retry, + timeout, ) response_iterator = self._client._firestore_api.run_query( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) return response_iterator, expected_prefix @@ -267,7 +271,9 @@ def stream( The next document that fulfills the query. """ response_iterator, expected_prefix = self._get_stream_iterator( - transaction, retry, timeout, + transaction, + retry, + timeout, ) last_snapshot = None @@ -279,7 +285,9 @@ def stream( if self._retry_query_after_exception(exc, retry, transaction): new_query = self.start_after(last_snapshot) response_iterator, _ = new_query._get_stream_iterator( - transaction, retry, timeout, + transaction, + retry, + timeout, ) continue else: @@ -408,7 +416,9 @@ def get_partitions( request, kwargs = self._prep_get_partitions(partition_count, retry, timeout) pager = self._client._firestore_api.partition_query( - request=request, metadata=self._client._rpc_metadata, **kwargs, + request=request, + metadata=self._client._rpc_metadata, + **kwargs, ) start_at = None diff --git a/google/cloud/firestore_v1/rate_limiter.py b/google/cloud/firestore_v1/rate_limiter.py index ee920edae0..2543869532 100644 --- a/google/cloud/firestore_v1/rate_limiter.py +++ b/google/cloud/firestore_v1/rate_limiter.py @@ -173,5 +173,6 @@ def _refill(self) -> NoReturn: # Add the number of provisioned tokens, capped at the maximum size. self._available_tokens = min( - self._maximum_tokens, self._available_tokens + new_tokens, + self._maximum_tokens, + self._available_tokens + new_tokens, ) diff --git a/google/cloud/firestore_v1/services/firestore/async_client.py b/google/cloud/firestore_v1/services/firestore/async_client.py index 0d55326b81..dbf1780333 100644 --- a/google/cloud/firestore_v1/services/firestore/async_client.py +++ b/google/cloud/firestore_v1/services/firestore/async_client.py @@ -295,7 +295,12 @@ def sample_get_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -381,12 +386,20 @@ def sample_list_documents(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListDocumentsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -506,7 +519,12 @@ def sample_update_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -601,7 +619,10 @@ def sample_delete_document(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def batch_get_documents( @@ -684,7 +705,12 @@ def sample_batch_get_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -786,7 +812,12 @@ def sample_begin_transaction(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -898,7 +929,12 @@ def sample_commit(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1003,7 +1039,10 @@ def sample_rollback(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def run_query( @@ -1083,7 +1122,12 @@ def sample_run_query(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1172,12 +1216,20 @@ def sample_partition_query(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.PartitionQueryAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1265,7 +1317,12 @@ def request_generator(): metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata(()),) # Send the request. - response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + requests, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1356,7 +1413,12 @@ def request_generator(): metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata(()),) # Send the request. - response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + requests, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1464,12 +1526,20 @@ def sample_list_collection_ids(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListCollectionIdsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1560,7 +1630,12 @@ def sample_batch_write(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1639,7 +1714,12 @@ def sample_create_document(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1653,7 +1733,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-firestore",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-firestore", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/firestore_v1/services/firestore/client.py b/google/cloud/firestore_v1/services/firestore/client.py index 9820fac25a..3656ce84a3 100644 --- a/google/cloud/firestore_v1/services/firestore/client.py +++ b/google/cloud/firestore_v1/services/firestore/client.py @@ -60,7 +60,10 @@ class FirestoreClientMeta(type): _transport_registry["grpc"] = FirestoreGrpcTransport _transport_registry["grpc_asyncio"] = FirestoreGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[FirestoreTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[FirestoreTransport]: """Returns an appropriate transport class. Args: @@ -173,7 +176,9 @@ def transport(self) -> FirestoreTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -186,9 +191,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -197,9 +206,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -208,9 +221,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -219,10 +236,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -461,7 +482,12 @@ def sample_get_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -536,12 +562,20 @@ def sample_list_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListDocumentsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -651,7 +685,12 @@ def sample_update_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -734,7 +773,10 @@ def sample_delete_document(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def batch_get_documents( @@ -806,7 +848,12 @@ def sample_batch_get_documents(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -896,7 +943,12 @@ def sample_begin_transaction(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -998,7 +1050,12 @@ def sample_commit(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1091,7 +1148,10 @@ def sample_rollback(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def run_query( @@ -1160,7 +1220,12 @@ def sample_run_query(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1238,12 +1303,20 @@ def sample_partition_query(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.PartitionQueryPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1327,7 +1400,12 @@ def request_generator(): metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata(()),) # Send the request. - response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + requests, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1402,7 +1480,12 @@ def request_generator(): metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata(()),) # Send the request. - response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + requests, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1498,12 +1581,20 @@ def sample_list_collection_ids(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListCollectionIdsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1584,7 +1675,12 @@ def sample_batch_write(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1654,7 +1750,12 @@ def sample_create_document(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1675,7 +1776,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-firestore",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-firestore", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/firestore_v1/services/firestore/transports/base.py b/google/cloud/firestore_v1/services/firestore/transports/base.py index 2cb218f258..d2fe931108 100644 --- a/google/cloud/firestore_v1/services/firestore/transports/base.py +++ b/google/cloud/firestore_v1/services/firestore/transports/base.py @@ -32,7 +32,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-firestore",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-firestore", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -291,7 +293,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.write: gapic_v1.method.wrap_method( - self.write, default_timeout=86400.0, client_info=client_info, + self.write, + default_timeout=86400.0, + client_info=client_info, ), self.listen: gapic_v1.method.wrap_method( self.listen, @@ -363,9 +367,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/firestore_v1/services/firestore/transports/grpc.py b/google/cloud/firestore_v1/services/firestore/transports/grpc.py index 674da51adc..ee9c9963d6 100644 --- a/google/cloud/firestore_v1/services/firestore/transports/grpc.py +++ b/google/cloud/firestore_v1/services/firestore/transports/grpc.py @@ -234,8 +234,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/firestore_v1/types/common.py b/google/cloud/firestore_v1/types/common.py index 63356bcf1e..efc8d9531f 100644 --- a/google/cloud/firestore_v1/types/common.py +++ b/google/cloud/firestore_v1/types/common.py @@ -20,7 +20,11 @@ __protobuf__ = proto.module( package="google.firestore.v1", - manifest={"DocumentMask", "Precondition", "TransactionOptions",}, + manifest={ + "DocumentMask", + "Precondition", + "TransactionOptions", + }, ) @@ -38,7 +42,10 @@ class DocumentMask(proto.Message): field path syntax reference. """ - field_paths = proto.RepeatedField(proto.STRING, number=1,) + field_paths = proto.RepeatedField( + proto.STRING, + number=1, + ) class Precondition(proto.Message): @@ -66,7 +73,11 @@ class Precondition(proto.Message): This field is a member of `oneof`_ ``condition_type``. """ - exists = proto.Field(proto.BOOL, number=1, oneof="condition_type",) + exists = proto.Field( + proto.BOOL, + number=1, + oneof="condition_type", + ) update_time = proto.Field( proto.MESSAGE, number=2, @@ -107,7 +118,10 @@ class ReadWrite(proto.Message): An optional transaction to retry. """ - retry_transaction = proto.Field(proto.BYTES, number=1,) + retry_transaction = proto.Field( + proto.BYTES, + number=1, + ) class ReadOnly(proto.Message): r"""Options for a transaction that can only be used to read @@ -131,8 +145,18 @@ class ReadOnly(proto.Message): message=timestamp_pb2.Timestamp, ) - read_only = proto.Field(proto.MESSAGE, number=2, oneof="mode", message=ReadOnly,) - read_write = proto.Field(proto.MESSAGE, number=3, oneof="mode", message=ReadWrite,) + read_only = proto.Field( + proto.MESSAGE, + number=2, + oneof="mode", + message=ReadOnly, + ) + read_write = proto.Field( + proto.MESSAGE, + number=3, + oneof="mode", + message=ReadWrite, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_v1/types/document.py b/google/cloud/firestore_v1/types/document.py index d568eabfaf..750706ead7 100644 --- a/google/cloud/firestore_v1/types/document.py +++ b/google/cloud/firestore_v1/types/document.py @@ -22,7 +22,12 @@ __protobuf__ = proto.module( package="google.firestore.v1", - manifest={"Document", "Value", "ArrayValue", "MapValue",}, + manifest={ + "Document", + "Value", + "ArrayValue", + "MapValue", + }, ) @@ -77,10 +82,26 @@ class Document(proto.Message): ``read_time`` of a query. """ - name = proto.Field(proto.STRING, number=1,) - fields = proto.MapField(proto.STRING, proto.MESSAGE, number=2, message="Value",) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + name = proto.Field( + proto.STRING, + number=1, + ) + fields = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=2, + message="Value", + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) class Value(proto.Message): @@ -155,25 +176,64 @@ class Value(proto.Message): """ null_value = proto.Field( - proto.ENUM, number=11, oneof="value_type", enum=struct_pb2.NullValue, + proto.ENUM, + number=11, + oneof="value_type", + enum=struct_pb2.NullValue, + ) + boolean_value = proto.Field( + proto.BOOL, + number=1, + oneof="value_type", + ) + integer_value = proto.Field( + proto.INT64, + number=2, + oneof="value_type", + ) + double_value = proto.Field( + proto.DOUBLE, + number=3, + oneof="value_type", ) - boolean_value = proto.Field(proto.BOOL, number=1, oneof="value_type",) - integer_value = proto.Field(proto.INT64, number=2, oneof="value_type",) - double_value = proto.Field(proto.DOUBLE, number=3, oneof="value_type",) timestamp_value = proto.Field( - proto.MESSAGE, number=10, oneof="value_type", message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=10, + oneof="value_type", + message=timestamp_pb2.Timestamp, + ) + string_value = proto.Field( + proto.STRING, + number=17, + oneof="value_type", + ) + bytes_value = proto.Field( + proto.BYTES, + number=18, + oneof="value_type", + ) + reference_value = proto.Field( + proto.STRING, + number=5, + oneof="value_type", ) - string_value = proto.Field(proto.STRING, number=17, oneof="value_type",) - bytes_value = proto.Field(proto.BYTES, number=18, oneof="value_type",) - reference_value = proto.Field(proto.STRING, number=5, oneof="value_type",) geo_point_value = proto.Field( - proto.MESSAGE, number=8, oneof="value_type", message=latlng_pb2.LatLng, + proto.MESSAGE, + number=8, + oneof="value_type", + message=latlng_pb2.LatLng, ) array_value = proto.Field( - proto.MESSAGE, number=9, oneof="value_type", message="ArrayValue", + proto.MESSAGE, + number=9, + oneof="value_type", + message="ArrayValue", ) map_value = proto.Field( - proto.MESSAGE, number=6, oneof="value_type", message="MapValue", + proto.MESSAGE, + number=6, + oneof="value_type", + message="MapValue", ) @@ -185,7 +245,11 @@ class ArrayValue(proto.Message): Values in the array. """ - values = proto.RepeatedField(proto.MESSAGE, number=1, message="Value",) + values = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Value", + ) class MapValue(proto.Message): @@ -202,7 +266,12 @@ class MapValue(proto.Message): bytes and cannot be empty. """ - fields = proto.MapField(proto.STRING, proto.MESSAGE, number=1, message="Value",) + fields = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=1, + message="Value", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_v1/types/firestore.py b/google/cloud/firestore_v1/types/firestore.py index 62cf58ffdb..4741e2ffe9 100644 --- a/google/cloud/firestore_v1/types/firestore.py +++ b/google/cloud/firestore_v1/types/firestore.py @@ -91,9 +91,20 @@ class GetDocumentRequest(proto.Message): This field is a member of `oneof`_ ``consistency_selector``. """ - name = proto.Field(proto.STRING, number=1,) - mask = proto.Field(proto.MESSAGE, number=2, message=common.DocumentMask,) - transaction = proto.Field(proto.BYTES, number=3, oneof="consistency_selector",) + name = proto.Field( + proto.STRING, + number=1, + ) + mask = proto.Field( + proto.MESSAGE, + number=2, + message=common.DocumentMask, + ) + transaction = proto.Field( + proto.BYTES, + number=3, + oneof="consistency_selector", + ) read_time = proto.Field( proto.MESSAGE, number=5, @@ -162,20 +173,46 @@ class ListDocumentsRequest(proto.Message): ``order_by``. """ - parent = proto.Field(proto.STRING, number=1,) - collection_id = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) - order_by = proto.Field(proto.STRING, number=6,) - mask = proto.Field(proto.MESSAGE, number=7, message=common.DocumentMask,) - transaction = proto.Field(proto.BYTES, number=8, oneof="consistency_selector",) + parent = proto.Field( + proto.STRING, + number=1, + ) + collection_id = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=6, + ) + mask = proto.Field( + proto.MESSAGE, + number=7, + message=common.DocumentMask, + ) + transaction = proto.Field( + proto.BYTES, + number=8, + oneof="consistency_selector", + ) read_time = proto.Field( proto.MESSAGE, number=10, oneof="consistency_selector", message=timestamp_pb2.Timestamp, ) - show_missing = proto.Field(proto.BOOL, number=12,) + show_missing = proto.Field( + proto.BOOL, + number=12, + ) class ListDocumentsResponse(proto.Message): @@ -194,9 +231,14 @@ def raw_page(self): return self documents = proto.RepeatedField( - proto.MESSAGE, number=1, message=gf_document.Document, + proto.MESSAGE, + number=1, + message=gf_document.Document, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class CreateDocumentRequest(proto.Message): @@ -227,11 +269,28 @@ class CreateDocumentRequest(proto.Message): the response. """ - parent = proto.Field(proto.STRING, number=1,) - collection_id = proto.Field(proto.STRING, number=2,) - document_id = proto.Field(proto.STRING, number=3,) - document = proto.Field(proto.MESSAGE, number=4, message=gf_document.Document,) - mask = proto.Field(proto.MESSAGE, number=5, message=common.DocumentMask,) + parent = proto.Field( + proto.STRING, + number=1, + ) + collection_id = proto.Field( + proto.STRING, + number=2, + ) + document_id = proto.Field( + proto.STRING, + number=3, + ) + document = proto.Field( + proto.MESSAGE, + number=4, + message=gf_document.Document, + ) + mask = proto.Field( + proto.MESSAGE, + number=5, + message=common.DocumentMask, + ) class UpdateDocumentRequest(proto.Message): @@ -265,11 +324,25 @@ class UpdateDocumentRequest(proto.Message): by the target document. """ - document = proto.Field(proto.MESSAGE, number=1, message=gf_document.Document,) - update_mask = proto.Field(proto.MESSAGE, number=2, message=common.DocumentMask,) - mask = proto.Field(proto.MESSAGE, number=3, message=common.DocumentMask,) + document = proto.Field( + proto.MESSAGE, + number=1, + message=gf_document.Document, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=common.DocumentMask, + ) + mask = proto.Field( + proto.MESSAGE, + number=3, + message=common.DocumentMask, + ) current_document = proto.Field( - proto.MESSAGE, number=4, message=common.Precondition, + proto.MESSAGE, + number=4, + message=common.Precondition, ) @@ -288,9 +361,14 @@ class DeleteDocumentRequest(proto.Message): by the target document. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) current_document = proto.Field( - proto.MESSAGE, number=2, message=common.Precondition, + proto.MESSAGE, + number=2, + message=common.Precondition, ) @@ -339,10 +417,24 @@ class BatchGetDocumentsRequest(proto.Message): This field is a member of `oneof`_ ``consistency_selector``. """ - database = proto.Field(proto.STRING, number=1,) - documents = proto.RepeatedField(proto.STRING, number=2,) - mask = proto.Field(proto.MESSAGE, number=3, message=common.DocumentMask,) - transaction = proto.Field(proto.BYTES, number=4, oneof="consistency_selector",) + database = proto.Field( + proto.STRING, + number=1, + ) + documents = proto.RepeatedField( + proto.STRING, + number=2, + ) + mask = proto.Field( + proto.MESSAGE, + number=3, + message=common.DocumentMask, + ) + transaction = proto.Field( + proto.BYTES, + number=4, + oneof="consistency_selector", + ) new_transaction = proto.Field( proto.MESSAGE, number=5, @@ -392,11 +484,25 @@ class BatchGetDocumentsResponse(proto.Message): """ found = proto.Field( - proto.MESSAGE, number=1, oneof="result", message=gf_document.Document, + proto.MESSAGE, + number=1, + oneof="result", + message=gf_document.Document, + ) + missing = proto.Field( + proto.STRING, + number=2, + oneof="result", + ) + transaction = proto.Field( + proto.BYTES, + number=3, + ) + read_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, ) - missing = proto.Field(proto.STRING, number=2, oneof="result",) - transaction = proto.Field(proto.BYTES, number=3,) - read_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) class BeginTransactionRequest(proto.Message): @@ -412,8 +518,15 @@ class BeginTransactionRequest(proto.Message): Defaults to a read-write transaction. """ - database = proto.Field(proto.STRING, number=1,) - options = proto.Field(proto.MESSAGE, number=2, message=common.TransactionOptions,) + database = proto.Field( + proto.STRING, + number=1, + ) + options = proto.Field( + proto.MESSAGE, + number=2, + message=common.TransactionOptions, + ) class BeginTransactionResponse(proto.Message): @@ -425,7 +538,10 @@ class BeginTransactionResponse(proto.Message): The transaction that was started. """ - transaction = proto.Field(proto.BYTES, number=1,) + transaction = proto.Field( + proto.BYTES, + number=1, + ) class CommitRequest(proto.Message): @@ -444,9 +560,19 @@ class CommitRequest(proto.Message): transaction, and commits it. """ - database = proto.Field(proto.STRING, number=1,) - writes = proto.RepeatedField(proto.MESSAGE, number=2, message=write.Write,) - transaction = proto.Field(proto.BYTES, number=3,) + database = proto.Field( + proto.STRING, + number=1, + ) + writes = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=write.Write, + ) + transaction = proto.Field( + proto.BYTES, + number=3, + ) class CommitResponse(proto.Message): @@ -465,9 +591,15 @@ class CommitResponse(proto.Message): """ write_results = proto.RepeatedField( - proto.MESSAGE, number=1, message=write.WriteResult, + proto.MESSAGE, + number=1, + message=write.WriteResult, + ) + commit_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) - commit_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) class RollbackRequest(proto.Message): @@ -482,8 +614,14 @@ class RollbackRequest(proto.Message): Required. The transaction to roll back. """ - database = proto.Field(proto.STRING, number=1,) - transaction = proto.Field(proto.BYTES, number=2,) + database = proto.Field( + proto.STRING, + number=1, + ) + transaction = proto.Field( + proto.BYTES, + number=2, + ) class RunQueryRequest(proto.Message): @@ -531,11 +669,21 @@ class RunQueryRequest(proto.Message): This field is a member of `oneof`_ ``consistency_selector``. """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) structured_query = proto.Field( - proto.MESSAGE, number=2, oneof="query_type", message=gf_query.StructuredQuery, + proto.MESSAGE, + number=2, + oneof="query_type", + message=gf_query.StructuredQuery, + ) + transaction = proto.Field( + proto.BYTES, + number=5, + oneof="consistency_selector", ) - transaction = proto.Field(proto.BYTES, number=5, oneof="consistency_selector",) new_transaction = proto.Field( proto.MESSAGE, number=6, @@ -579,10 +727,24 @@ class RunQueryResponse(proto.Message): the current response. """ - transaction = proto.Field(proto.BYTES, number=2,) - document = proto.Field(proto.MESSAGE, number=1, message=gf_document.Document,) - read_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - skipped_results = proto.Field(proto.INT32, number=4,) + transaction = proto.Field( + proto.BYTES, + number=2, + ) + document = proto.Field( + proto.MESSAGE, + number=1, + message=gf_document.Document, + ) + read_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + skipped_results = proto.Field( + proto.INT32, + number=4, + ) class PartitionQueryRequest(proto.Message): @@ -647,13 +809,28 @@ class PartitionQueryRequest(proto.Message): ``partition_count``. """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) structured_query = proto.Field( - proto.MESSAGE, number=2, oneof="query_type", message=gf_query.StructuredQuery, + proto.MESSAGE, + number=2, + oneof="query_type", + message=gf_query.StructuredQuery, + ) + partition_count = proto.Field( + proto.INT64, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + page_size = proto.Field( + proto.INT32, + number=5, ) - partition_count = proto.Field(proto.INT64, number=3,) - page_token = proto.Field(proto.STRING, number=4,) - page_size = proto.Field(proto.INT32, number=5,) class PartitionQueryResponse(proto.Message): @@ -690,8 +867,15 @@ class PartitionQueryResponse(proto.Message): def raw_page(self): return self - partitions = proto.RepeatedField(proto.MESSAGE, number=1, message=gf_query.Cursor,) - next_page_token = proto.Field(proto.STRING, number=2,) + partitions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gf_query.Cursor, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class WriteRequest(proto.Message): @@ -744,11 +928,28 @@ class WriteRequest(proto.Message): Labels associated with this write request. """ - database = proto.Field(proto.STRING, number=1,) - stream_id = proto.Field(proto.STRING, number=2,) - writes = proto.RepeatedField(proto.MESSAGE, number=3, message=write.Write,) - stream_token = proto.Field(proto.BYTES, number=4,) - labels = proto.MapField(proto.STRING, proto.STRING, number=5,) + database = proto.Field( + proto.STRING, + number=1, + ) + stream_id = proto.Field( + proto.STRING, + number=2, + ) + writes = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=write.Write, + ) + stream_token = proto.Field( + proto.BYTES, + number=4, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=5, + ) class WriteResponse(proto.Message): @@ -775,12 +976,24 @@ class WriteResponse(proto.Message): effects of the write. """ - stream_id = proto.Field(proto.STRING, number=1,) - stream_token = proto.Field(proto.BYTES, number=2,) + stream_id = proto.Field( + proto.STRING, + number=1, + ) + stream_token = proto.Field( + proto.BYTES, + number=2, + ) write_results = proto.RepeatedField( - proto.MESSAGE, number=3, message=write.WriteResult, + proto.MESSAGE, + number=3, + message=write.WriteResult, + ) + commit_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, ) - commit_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) class ListenRequest(proto.Message): @@ -811,12 +1024,26 @@ class ListenRequest(proto.Message): Labels associated with this target change. """ - database = proto.Field(proto.STRING, number=1,) + database = proto.Field( + proto.STRING, + number=1, + ) add_target = proto.Field( - proto.MESSAGE, number=2, oneof="target_change", message="Target", + proto.MESSAGE, + number=2, + oneof="target_change", + message="Target", + ) + remove_target = proto.Field( + proto.INT32, + number=3, + oneof="target_change", + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, ) - remove_target = proto.Field(proto.INT32, number=3, oneof="target_change",) - labels = proto.MapField(proto.STRING, proto.STRING, number=4,) class ListenResponse(proto.Message): @@ -861,19 +1088,34 @@ class ListenResponse(proto.Message): """ target_change = proto.Field( - proto.MESSAGE, number=2, oneof="response_type", message="TargetChange", + proto.MESSAGE, + number=2, + oneof="response_type", + message="TargetChange", ) document_change = proto.Field( - proto.MESSAGE, number=3, oneof="response_type", message=write.DocumentChange, + proto.MESSAGE, + number=3, + oneof="response_type", + message=write.DocumentChange, ) document_delete = proto.Field( - proto.MESSAGE, number=4, oneof="response_type", message=write.DocumentDelete, + proto.MESSAGE, + number=4, + oneof="response_type", + message=write.DocumentDelete, ) document_remove = proto.Field( - proto.MESSAGE, number=6, oneof="response_type", message=write.DocumentRemove, + proto.MESSAGE, + number=6, + oneof="response_type", + message=write.DocumentRemove, ) filter = proto.Field( - proto.MESSAGE, number=5, oneof="response_type", message=write.ExistenceFilter, + proto.MESSAGE, + number=5, + oneof="response_type", + message=write.ExistenceFilter, ) @@ -934,7 +1176,10 @@ class DocumentsTarget(proto.Message): elided. """ - documents = proto.RepeatedField(proto.STRING, number=2,) + documents = proto.RepeatedField( + proto.STRING, + number=2, + ) class QueryTarget(proto.Message): r"""A target specified by a query. @@ -956,7 +1201,10 @@ class QueryTarget(proto.Message): This field is a member of `oneof`_ ``query_type``. """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) structured_query = proto.Field( proto.MESSAGE, number=2, @@ -965,17 +1213,36 @@ class QueryTarget(proto.Message): ) query = proto.Field( - proto.MESSAGE, number=2, oneof="target_type", message=QueryTarget, + proto.MESSAGE, + number=2, + oneof="target_type", + message=QueryTarget, ) documents = proto.Field( - proto.MESSAGE, number=3, oneof="target_type", message=DocumentsTarget, + proto.MESSAGE, + number=3, + oneof="target_type", + message=DocumentsTarget, + ) + resume_token = proto.Field( + proto.BYTES, + number=4, + oneof="resume_type", ) - resume_token = proto.Field(proto.BYTES, number=4, oneof="resume_type",) read_time = proto.Field( - proto.MESSAGE, number=11, oneof="resume_type", message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=11, + oneof="resume_type", + message=timestamp_pb2.Timestamp, + ) + target_id = proto.Field( + proto.INT32, + number=5, + ) + once = proto.Field( + proto.BOOL, + number=6, ) - target_id = proto.Field(proto.INT32, number=5,) - once = proto.Field(proto.BOOL, number=6,) class TargetChange(proto.Message): @@ -1020,11 +1287,29 @@ class TargetChangeType(proto.Enum): CURRENT = 3 RESET = 4 - target_change_type = proto.Field(proto.ENUM, number=1, enum=TargetChangeType,) - target_ids = proto.RepeatedField(proto.INT32, number=2,) - cause = proto.Field(proto.MESSAGE, number=3, message=status_pb2.Status,) - resume_token = proto.Field(proto.BYTES, number=4,) - read_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + target_change_type = proto.Field( + proto.ENUM, + number=1, + enum=TargetChangeType, + ) + target_ids = proto.RepeatedField( + proto.INT32, + number=2, + ) + cause = proto.Field( + proto.MESSAGE, + number=3, + message=status_pb2.Status, + ) + resume_token = proto.Field( + proto.BYTES, + number=4, + ) + read_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) class ListCollectionIdsRequest(proto.Message): @@ -1044,9 +1329,18 @@ class ListCollectionIdsRequest(proto.Message): [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListCollectionIdsResponse(proto.Message): @@ -1065,8 +1359,14 @@ class ListCollectionIdsResponse(proto.Message): def raw_page(self): return self - collection_ids = proto.RepeatedField(proto.STRING, number=1,) - next_page_token = proto.Field(proto.STRING, number=2,) + collection_ids = proto.RepeatedField( + proto.STRING, + number=1, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class BatchWriteRequest(proto.Message): @@ -1087,9 +1387,20 @@ class BatchWriteRequest(proto.Message): Labels associated with this batch write. """ - database = proto.Field(proto.STRING, number=1,) - writes = proto.RepeatedField(proto.MESSAGE, number=2, message=write.Write,) - labels = proto.MapField(proto.STRING, proto.STRING, number=3,) + database = proto.Field( + proto.STRING, + number=1, + ) + writes = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=write.Write, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) class BatchWriteResponse(proto.Message): @@ -1108,9 +1419,15 @@ class BatchWriteResponse(proto.Message): """ write_results = proto.RepeatedField( - proto.MESSAGE, number=1, message=write.WriteResult, + proto.MESSAGE, + number=1, + message=write.WriteResult, + ) + status = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=status_pb2.Status, ) - status = proto.RepeatedField(proto.MESSAGE, number=2, message=status_pb2.Status,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_v1/types/query.py b/google/cloud/firestore_v1/types/query.py index f1a8eba373..54a50262a4 100644 --- a/google/cloud/firestore_v1/types/query.py +++ b/google/cloud/firestore_v1/types/query.py @@ -20,7 +20,11 @@ __protobuf__ = proto.module( - package="google.firestore.v1", manifest={"StructuredQuery", "Cursor",}, + package="google.firestore.v1", + manifest={ + "StructuredQuery", + "Cursor", + }, ) @@ -90,8 +94,14 @@ class CollectionSelector(proto.Message): collections. """ - collection_id = proto.Field(proto.STRING, number=2,) - all_descendants = proto.Field(proto.BOOL, number=3,) + collection_id = proto.Field( + proto.STRING, + number=2, + ) + all_descendants = proto.Field( + proto.BOOL, + number=3, + ) class Filter(proto.Message): r"""A filter. @@ -155,10 +165,14 @@ class Operator(proto.Enum): AND = 1 op = proto.Field( - proto.ENUM, number=1, enum="StructuredQuery.CompositeFilter.Operator", + proto.ENUM, + number=1, + enum="StructuredQuery.CompositeFilter.Operator", ) filters = proto.RepeatedField( - proto.MESSAGE, number=2, message="StructuredQuery.Filter", + proto.MESSAGE, + number=2, + message="StructuredQuery.Filter", ) class FieldFilter(proto.Message): @@ -188,12 +202,20 @@ class Operator(proto.Enum): NOT_IN = 10 field = proto.Field( - proto.MESSAGE, number=1, message="StructuredQuery.FieldReference", + proto.MESSAGE, + number=1, + message="StructuredQuery.FieldReference", ) op = proto.Field( - proto.ENUM, number=2, enum="StructuredQuery.FieldFilter.Operator", + proto.ENUM, + number=2, + enum="StructuredQuery.FieldFilter.Operator", + ) + value = proto.Field( + proto.MESSAGE, + number=3, + message=document.Value, ) - value = proto.Field(proto.MESSAGE, number=3, message=document.Value,) class UnaryFilter(proto.Message): r"""A filter with a single operand. @@ -218,7 +240,9 @@ class Operator(proto.Enum): IS_NOT_NULL = 5 op = proto.Field( - proto.ENUM, number=1, enum="StructuredQuery.UnaryFilter.Operator", + proto.ENUM, + number=1, + enum="StructuredQuery.UnaryFilter.Operator", ) field = proto.Field( proto.MESSAGE, @@ -238,9 +262,15 @@ class Order(proto.Message): """ field = proto.Field( - proto.MESSAGE, number=1, message="StructuredQuery.FieldReference", + proto.MESSAGE, + number=1, + message="StructuredQuery.FieldReference", + ) + direction = proto.Field( + proto.ENUM, + number=2, + enum="StructuredQuery.Direction", ) - direction = proto.Field(proto.ENUM, number=2, enum="StructuredQuery.Direction",) class FieldReference(proto.Message): r"""A reference to a field, such as ``max(messages.time) as max_time``. @@ -250,7 +280,10 @@ class FieldReference(proto.Message): """ - field_path = proto.Field(proto.STRING, number=2,) + field_path = proto.Field( + proto.STRING, + number=2, + ) class Projection(proto.Message): r"""The projection of document's fields to return. @@ -264,17 +297,50 @@ class Projection(proto.Message): """ fields = proto.RepeatedField( - proto.MESSAGE, number=2, message="StructuredQuery.FieldReference", + proto.MESSAGE, + number=2, + message="StructuredQuery.FieldReference", ) - select = proto.Field(proto.MESSAGE, number=1, message=Projection,) - from_ = proto.RepeatedField(proto.MESSAGE, number=2, message=CollectionSelector,) - where = proto.Field(proto.MESSAGE, number=3, message=Filter,) - order_by = proto.RepeatedField(proto.MESSAGE, number=4, message=Order,) - start_at = proto.Field(proto.MESSAGE, number=7, message="Cursor",) - end_at = proto.Field(proto.MESSAGE, number=8, message="Cursor",) - offset = proto.Field(proto.INT32, number=6,) - limit = proto.Field(proto.MESSAGE, number=5, message=wrappers_pb2.Int32Value,) + select = proto.Field( + proto.MESSAGE, + number=1, + message=Projection, + ) + from_ = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=CollectionSelector, + ) + where = proto.Field( + proto.MESSAGE, + number=3, + message=Filter, + ) + order_by = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=Order, + ) + start_at = proto.Field( + proto.MESSAGE, + number=7, + message="Cursor", + ) + end_at = proto.Field( + proto.MESSAGE, + number=8, + message="Cursor", + ) + offset = proto.Field( + proto.INT32, + number=6, + ) + limit = proto.Field( + proto.MESSAGE, + number=5, + message=wrappers_pb2.Int32Value, + ) class Cursor(proto.Message): @@ -293,8 +359,15 @@ class Cursor(proto.Message): defined by the query. """ - values = proto.RepeatedField(proto.MESSAGE, number=1, message=document.Value,) - before = proto.Field(proto.BOOL, number=2,) + values = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=document.Value, + ) + before = proto.Field( + proto.BOOL, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_v1/types/write.py b/google/cloud/firestore_v1/types/write.py index 0e3bedbd9f..5f85d9de07 100644 --- a/google/cloud/firestore_v1/types/write.py +++ b/google/cloud/firestore_v1/types/write.py @@ -83,18 +83,36 @@ class Write(proto.Message): """ update = proto.Field( - proto.MESSAGE, number=1, oneof="operation", message=gf_document.Document, + proto.MESSAGE, + number=1, + oneof="operation", + message=gf_document.Document, + ) + delete = proto.Field( + proto.STRING, + number=2, + oneof="operation", ) - delete = proto.Field(proto.STRING, number=2, oneof="operation",) transform = proto.Field( - proto.MESSAGE, number=6, oneof="operation", message="DocumentTransform", + proto.MESSAGE, + number=6, + oneof="operation", + message="DocumentTransform", + ) + update_mask = proto.Field( + proto.MESSAGE, + number=3, + message=common.DocumentMask, ) - update_mask = proto.Field(proto.MESSAGE, number=3, message=common.DocumentMask,) update_transforms = proto.RepeatedField( - proto.MESSAGE, number=7, message="DocumentTransform.FieldTransform", + proto.MESSAGE, + number=7, + message="DocumentTransform.FieldTransform", ) current_document = proto.Field( - proto.MESSAGE, number=4, message=common.Precondition, + proto.MESSAGE, + number=4, + message=common.Precondition, ) @@ -219,7 +237,10 @@ class ServerValue(proto.Enum): SERVER_VALUE_UNSPECIFIED = 0 REQUEST_TIME = 1 - field_path = proto.Field(proto.STRING, number=1,) + field_path = proto.Field( + proto.STRING, + number=1, + ) set_to_server_value = proto.Field( proto.ENUM, number=2, @@ -227,13 +248,22 @@ class ServerValue(proto.Enum): enum="DocumentTransform.FieldTransform.ServerValue", ) increment = proto.Field( - proto.MESSAGE, number=3, oneof="transform_type", message=gf_document.Value, + proto.MESSAGE, + number=3, + oneof="transform_type", + message=gf_document.Value, ) maximum = proto.Field( - proto.MESSAGE, number=4, oneof="transform_type", message=gf_document.Value, + proto.MESSAGE, + number=4, + oneof="transform_type", + message=gf_document.Value, ) minimum = proto.Field( - proto.MESSAGE, number=5, oneof="transform_type", message=gf_document.Value, + proto.MESSAGE, + number=5, + oneof="transform_type", + message=gf_document.Value, ) append_missing_elements = proto.Field( proto.MESSAGE, @@ -248,9 +278,14 @@ class ServerValue(proto.Enum): message=gf_document.ArrayValue, ) - document = proto.Field(proto.STRING, number=1,) + document = proto.Field( + proto.STRING, + number=1, + ) field_transforms = proto.RepeatedField( - proto.MESSAGE, number=2, message=FieldTransform, + proto.MESSAGE, + number=2, + message=FieldTransform, ) @@ -270,9 +305,15 @@ class WriteResult(proto.Message): in the same order. """ - update_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) transform_results = proto.RepeatedField( - proto.MESSAGE, number=2, message=gf_document.Value, + proto.MESSAGE, + number=2, + message=gf_document.Value, ) @@ -302,9 +343,19 @@ class DocumentChange(proto.Message): longer match this document. """ - document = proto.Field(proto.MESSAGE, number=1, message=gf_document.Document,) - target_ids = proto.RepeatedField(proto.INT32, number=5,) - removed_target_ids = proto.RepeatedField(proto.INT32, number=6,) + document = proto.Field( + proto.MESSAGE, + number=1, + message=gf_document.Document, + ) + target_ids = proto.RepeatedField( + proto.INT32, + number=5, + ) + removed_target_ids = proto.RepeatedField( + proto.INT32, + number=6, + ) class DocumentDelete(proto.Message): @@ -331,9 +382,19 @@ class DocumentDelete(proto.Message): Greater or equal to the ``commit_time`` of the delete. """ - document = proto.Field(proto.STRING, number=1,) - removed_target_ids = proto.RepeatedField(proto.INT32, number=6,) - read_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + document = proto.Field( + proto.STRING, + number=1, + ) + removed_target_ids = proto.RepeatedField( + proto.INT32, + number=6, + ) + read_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) class DocumentRemove(proto.Message): @@ -363,9 +424,19 @@ class DocumentRemove(proto.Message): change/delete/remove. """ - document = proto.Field(proto.STRING, number=1,) - removed_target_ids = proto.RepeatedField(proto.INT32, number=2,) - read_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + document = proto.Field( + proto.STRING, + number=1, + ) + removed_target_ids = proto.RepeatedField( + proto.INT32, + number=2, + ) + read_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) class ExistenceFilter(proto.Message): @@ -383,8 +454,14 @@ class ExistenceFilter(proto.Message): longer match the target. """ - target_id = proto.Field(proto.INT32, number=1,) - count = proto.Field(proto.INT32, number=2,) + target_id = proto.Field( + proto.INT32, + number=1, + ) + count = proto.Field( + proto.INT32, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/firestore_v1/watch.py b/google/cloud/firestore_v1/watch.py index ba45832e84..d1ce5a57af 100644 --- a/google/cloud/firestore_v1/watch.py +++ b/google/cloud/firestore_v1/watch.py @@ -249,7 +249,10 @@ def _init_stream(self): @classmethod def for_document( - cls, document_ref, snapshot_callback, document_snapshot_cls, + cls, + document_ref, + snapshot_callback, + document_snapshot_cls, ): """ Creates a watch snapshot listener for a document. snapshot_callback @@ -518,7 +521,8 @@ def on_snapshot(self, proto): # First, shut down current stream _LOGGER.info("Filter mismatch -- restarting stream.") thread = threading.Thread( - name=_RPC_ERROR_THREAD_NAME, target=self.close, + name=_RPC_ERROR_THREAD_NAME, + target=self.close, ) thread.start() thread.join() # wait for shutdown to complete diff --git a/noxfile.py b/noxfile.py index b388f2797b..d27d2c81a1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,7 +25,7 @@ PYTYPE_VERSION = "pytype==2020.7.24" -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -60,7 +60,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -70,7 +72,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) @@ -78,7 +81,9 @@ def blacken(session): def pytype(session): """Verify type hints are pytype compatible.""" session.install(PYTYPE_VERSION) - session.run("pytype",) + session.run( + "pytype", + ) @nox.session(python=DEFAULT_PYTHON_VERSION) @@ -157,7 +162,13 @@ def system_emulated(session): # Currently, CI/CD doesn't have beta component of gcloud. subprocess.call( - ["gcloud", "components", "install", "beta", "cloud-firestore-emulator",] + [ + "gcloud", + "components", + "install", + "beta", + "cloud-firestore-emulator", + ] ) hostport = "localhost:8789" diff --git a/owlbot.py b/owlbot.py index d2f0422d2f..c3c8812fae 100644 --- a/owlbot.py +++ b/owlbot.py @@ -280,11 +280,11 @@ def system_emulated(session): s.replace( "noxfile.py", """\ -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" """, """\ PYTYPE_VERSION = "pytype==2020.7.24" -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" """, ) diff --git a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py index fe70d20f33..61aa7edf89 100644 --- a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py +++ b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py @@ -102,7 +102,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [FirestoreAdminClient, FirestoreAdminAsyncClient,] + "client_class", + [ + FirestoreAdminClient, + FirestoreAdminAsyncClient, + ], ) def test_firestore_admin_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -144,7 +148,11 @@ def test_firestore_admin_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [FirestoreAdminClient, FirestoreAdminAsyncClient,] + "client_class", + [ + FirestoreAdminClient, + FirestoreAdminAsyncClient, + ], ) def test_firestore_admin_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -508,7 +516,9 @@ def test_firestore_admin_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -651,10 +661,17 @@ def test_firestore_admin_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [firestore_admin.CreateIndexRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.CreateIndexRequest, + dict, + ], +) def test_create_index(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -680,7 +697,8 @@ def test_create_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -696,7 +714,8 @@ async def test_create_index_async( transport: str = "grpc_asyncio", request_type=firestore_admin.CreateIndexRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -726,7 +745,9 @@ async def test_create_index_async_from_dict(): def test_create_index_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -746,7 +767,10 @@ def test_create_index_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -775,11 +799,16 @@ async def test_create_index_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_index_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_index), "__call__") as call: @@ -788,7 +817,8 @@ def test_create_index_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_index( - parent="parent_value", index=gfa_index.Index(name="name_value"), + parent="parent_value", + index=gfa_index.Index(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -804,7 +834,9 @@ def test_create_index_flattened(): def test_create_index_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -833,7 +865,8 @@ async def test_create_index_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_index( - parent="parent_value", index=gfa_index.Index(name="name_value"), + parent="parent_value", + index=gfa_index.Index(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -864,10 +897,17 @@ async def test_create_index_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [firestore_admin.ListIndexesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.ListIndexesRequest, + dict, + ], +) def test_list_indexes(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -896,7 +936,8 @@ def test_list_indexes_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -912,7 +953,8 @@ async def test_list_indexes_async( transport: str = "grpc_asyncio", request_type=firestore_admin.ListIndexesRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -945,7 +987,9 @@ async def test_list_indexes_async_from_dict(): def test_list_indexes_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -965,7 +1009,10 @@ def test_list_indexes_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -994,11 +1041,16 @@ async def test_list_indexes_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_indexes_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: @@ -1006,7 +1058,9 @@ def test_list_indexes_flattened(): call.return_value = firestore_admin.ListIndexesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_indexes(parent="parent_value",) + client.list_indexes( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1018,13 +1072,16 @@ def test_list_indexes_flattened(): def test_list_indexes_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_indexes( - firestore_admin.ListIndexesRequest(), parent="parent_value", + firestore_admin.ListIndexesRequest(), + parent="parent_value", ) @@ -1044,7 +1101,9 @@ async def test_list_indexes_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_indexes(parent="parent_value",) + response = await client.list_indexes( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1065,13 +1124,15 @@ async def test_list_indexes_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_indexes( - firestore_admin.ListIndexesRequest(), parent="parent_value", + firestore_admin.ListIndexesRequest(), + parent="parent_value", ) def test_list_indexes_pager(transport_name: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1079,15 +1140,28 @@ def test_list_indexes_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + index.Index(), + ], next_page_token="abc", ), - firestore_admin.ListIndexesResponse(indexes=[], next_page_token="def",), firestore_admin.ListIndexesResponse( - indexes=[index.Index(),], next_page_token="ghi", + indexes=[], + next_page_token="def", + ), + firestore_admin.ListIndexesResponse( + indexes=[ + index.Index(), + ], + next_page_token="ghi", ), firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + ], ), RuntimeError, ) @@ -1107,7 +1181,8 @@ def test_list_indexes_pager(transport_name: str = "grpc"): def test_list_indexes_pages(transport_name: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1115,15 +1190,28 @@ def test_list_indexes_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + index.Index(), + ], next_page_token="abc", ), - firestore_admin.ListIndexesResponse(indexes=[], next_page_token="def",), firestore_admin.ListIndexesResponse( - indexes=[index.Index(),], next_page_token="ghi", + indexes=[], + next_page_token="def", + ), + firestore_admin.ListIndexesResponse( + indexes=[ + index.Index(), + ], + next_page_token="ghi", ), firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + ], ), RuntimeError, ) @@ -1134,7 +1222,9 @@ def test_list_indexes_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_indexes_async_pager(): - client = FirestoreAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1143,19 +1233,34 @@ async def test_list_indexes_async_pager(): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + index.Index(), + ], next_page_token="abc", ), - firestore_admin.ListIndexesResponse(indexes=[], next_page_token="def",), firestore_admin.ListIndexesResponse( - indexes=[index.Index(),], next_page_token="ghi", + indexes=[], + next_page_token="def", + ), + firestore_admin.ListIndexesResponse( + indexes=[ + index.Index(), + ], + next_page_token="ghi", ), firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + ], ), RuntimeError, ) - async_pager = await client.list_indexes(request={},) + async_pager = await client.list_indexes( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1167,7 +1272,9 @@ async def test_list_indexes_async_pager(): @pytest.mark.asyncio async def test_list_indexes_async_pages(): - client = FirestoreAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1176,15 +1283,28 @@ async def test_list_indexes_async_pages(): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + index.Index(), + ], next_page_token="abc", ), - firestore_admin.ListIndexesResponse(indexes=[], next_page_token="def",), firestore_admin.ListIndexesResponse( - indexes=[index.Index(),], next_page_token="ghi", + indexes=[], + next_page_token="def", + ), + firestore_admin.ListIndexesResponse( + indexes=[ + index.Index(), + ], + next_page_token="ghi", ), firestore_admin.ListIndexesResponse( - indexes=[index.Index(), index.Index(),], + indexes=[ + index.Index(), + index.Index(), + ], ), RuntimeError, ) @@ -1195,10 +1315,17 @@ async def test_list_indexes_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [firestore_admin.GetIndexRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.GetIndexRequest, + dict, + ], +) def test_get_index(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1231,7 +1358,8 @@ def test_get_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1247,7 +1375,8 @@ async def test_get_index_async( transport: str = "grpc_asyncio", request_type=firestore_admin.GetIndexRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1284,7 +1413,9 @@ async def test_get_index_async_from_dict(): def test_get_index_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1304,7 +1435,10 @@ def test_get_index_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1331,11 +1465,16 @@ async def test_get_index_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_index_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: @@ -1343,7 +1482,9 @@ def test_get_index_flattened(): call.return_value = index.Index() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_index(name="name_value",) + client.get_index( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1355,13 +1496,16 @@ def test_get_index_flattened(): def test_get_index_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_index( - firestore_admin.GetIndexRequest(), name="name_value", + firestore_admin.GetIndexRequest(), + name="name_value", ) @@ -1379,7 +1523,9 @@ async def test_get_index_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(index.Index()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_index(name="name_value",) + response = await client.get_index( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1400,14 +1546,22 @@ async def test_get_index_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_index( - firestore_admin.GetIndexRequest(), name="name_value", + firestore_admin.GetIndexRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [firestore_admin.DeleteIndexRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.DeleteIndexRequest, + dict, + ], +) def test_delete_index(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1433,7 +1587,8 @@ def test_delete_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1449,7 +1604,8 @@ async def test_delete_index_async( transport: str = "grpc_asyncio", request_type=firestore_admin.DeleteIndexRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1477,7 +1633,9 @@ async def test_delete_index_async_from_dict(): def test_delete_index_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1497,7 +1655,10 @@ def test_delete_index_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1524,11 +1685,16 @@ async def test_delete_index_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_index_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_index), "__call__") as call: @@ -1536,7 +1702,9 @@ def test_delete_index_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_index(name="name_value",) + client.delete_index( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1548,13 +1716,16 @@ def test_delete_index_flattened(): def test_delete_index_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_index( - firestore_admin.DeleteIndexRequest(), name="name_value", + firestore_admin.DeleteIndexRequest(), + name="name_value", ) @@ -1572,7 +1743,9 @@ async def test_delete_index_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_index(name="name_value",) + response = await client.delete_index( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1593,14 +1766,22 @@ async def test_delete_index_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_index( - firestore_admin.DeleteIndexRequest(), name="name_value", + firestore_admin.DeleteIndexRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [firestore_admin.GetFieldRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.GetFieldRequest, + dict, + ], +) def test_get_field(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1610,7 +1791,9 @@ def test_get_field(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_field), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = field.Field(name="name_value",) + call.return_value = field.Field( + name="name_value", + ) response = client.get_field(request) # Establish that the underlying gRPC stub method was called. @@ -1627,7 +1810,8 @@ def test_get_field_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1643,7 +1827,8 @@ async def test_get_field_async( transport: str = "grpc_asyncio", request_type=firestore_admin.GetFieldRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1654,7 +1839,9 @@ async def test_get_field_async( with mock.patch.object(type(client.transport.get_field), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - field.Field(name="name_value",) + field.Field( + name="name_value", + ) ) response = await client.get_field(request) @@ -1674,7 +1861,9 @@ async def test_get_field_async_from_dict(): def test_get_field_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1694,7 +1883,10 @@ def test_get_field_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1721,11 +1913,16 @@ async def test_get_field_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_field_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_field), "__call__") as call: @@ -1733,7 +1930,9 @@ def test_get_field_flattened(): call.return_value = field.Field() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_field(name="name_value",) + client.get_field( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1745,13 +1944,16 @@ def test_get_field_flattened(): def test_get_field_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_field( - firestore_admin.GetFieldRequest(), name="name_value", + firestore_admin.GetFieldRequest(), + name="name_value", ) @@ -1769,7 +1971,9 @@ async def test_get_field_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(field.Field()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_field(name="name_value",) + response = await client.get_field( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1790,14 +1994,22 @@ async def test_get_field_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_field( - firestore_admin.GetFieldRequest(), name="name_value", + firestore_admin.GetFieldRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [firestore_admin.UpdateFieldRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.UpdateFieldRequest, + dict, + ], +) def test_update_field(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1823,7 +2035,8 @@ def test_update_field_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1839,7 +2052,8 @@ async def test_update_field_async( transport: str = "grpc_asyncio", request_type=firestore_admin.UpdateFieldRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1869,7 +2083,9 @@ async def test_update_field_async_from_dict(): def test_update_field_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1889,7 +2105,10 @@ def test_update_field_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "field.name=field.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "field.name=field.name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1918,11 +2137,16 @@ async def test_update_field_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "field.name=field.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "field.name=field.name/value", + ) in kw["metadata"] def test_update_field_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_field), "__call__") as call: @@ -1930,7 +2154,9 @@ def test_update_field_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_field(field=gfa_field.Field(name="name_value"),) + client.update_field( + field=gfa_field.Field(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1942,7 +2168,9 @@ def test_update_field_flattened(): def test_update_field_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1969,7 +2197,9 @@ async def test_update_field_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_field(field=gfa_field.Field(name="name_value"),) + response = await client.update_field( + field=gfa_field.Field(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1995,10 +2225,17 @@ async def test_update_field_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [firestore_admin.ListFieldsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.ListFieldsRequest, + dict, + ], +) def test_list_fields(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2027,7 +2264,8 @@ def test_list_fields_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2043,7 +2281,8 @@ async def test_list_fields_async( transport: str = "grpc_asyncio", request_type=firestore_admin.ListFieldsRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2054,7 +2293,9 @@ async def test_list_fields_async( with mock.patch.object(type(client.transport.list_fields), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - firestore_admin.ListFieldsResponse(next_page_token="next_page_token_value",) + firestore_admin.ListFieldsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_fields(request) @@ -2074,7 +2315,9 @@ async def test_list_fields_async_from_dict(): def test_list_fields_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2094,7 +2337,10 @@ def test_list_fields_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2123,11 +2369,16 @@ async def test_list_fields_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_fields_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_fields), "__call__") as call: @@ -2135,7 +2386,9 @@ def test_list_fields_flattened(): call.return_value = firestore_admin.ListFieldsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_fields(parent="parent_value",) + client.list_fields( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2147,13 +2400,16 @@ def test_list_fields_flattened(): def test_list_fields_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_fields( - firestore_admin.ListFieldsRequest(), parent="parent_value", + firestore_admin.ListFieldsRequest(), + parent="parent_value", ) @@ -2173,7 +2429,9 @@ async def test_list_fields_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_fields(parent="parent_value",) + response = await client.list_fields( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2194,13 +2452,15 @@ async def test_list_fields_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_fields( - firestore_admin.ListFieldsRequest(), parent="parent_value", + firestore_admin.ListFieldsRequest(), + parent="parent_value", ) def test_list_fields_pager(transport_name: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2208,14 +2468,29 @@ def test_list_fields_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListFieldsResponse( - fields=[field.Field(), field.Field(), field.Field(),], + fields=[ + field.Field(), + field.Field(), + field.Field(), + ], next_page_token="abc", ), - firestore_admin.ListFieldsResponse(fields=[], next_page_token="def",), firestore_admin.ListFieldsResponse( - fields=[field.Field(),], next_page_token="ghi", + fields=[], + next_page_token="def", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + ], + next_page_token="ghi", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + field.Field(), + ], ), - firestore_admin.ListFieldsResponse(fields=[field.Field(), field.Field(),],), RuntimeError, ) @@ -2234,7 +2509,8 @@ def test_list_fields_pager(transport_name: str = "grpc"): def test_list_fields_pages(transport_name: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2242,14 +2518,29 @@ def test_list_fields_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListFieldsResponse( - fields=[field.Field(), field.Field(), field.Field(),], + fields=[ + field.Field(), + field.Field(), + field.Field(), + ], next_page_token="abc", ), - firestore_admin.ListFieldsResponse(fields=[], next_page_token="def",), firestore_admin.ListFieldsResponse( - fields=[field.Field(),], next_page_token="ghi", + fields=[], + next_page_token="def", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + ], + next_page_token="ghi", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + field.Field(), + ], ), - firestore_admin.ListFieldsResponse(fields=[field.Field(), field.Field(),],), RuntimeError, ) pages = list(client.list_fields(request={}).pages) @@ -2259,7 +2550,9 @@ def test_list_fields_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_fields_async_pager(): - client = FirestoreAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2268,17 +2561,34 @@ async def test_list_fields_async_pager(): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListFieldsResponse( - fields=[field.Field(), field.Field(), field.Field(),], + fields=[ + field.Field(), + field.Field(), + field.Field(), + ], next_page_token="abc", ), - firestore_admin.ListFieldsResponse(fields=[], next_page_token="def",), firestore_admin.ListFieldsResponse( - fields=[field.Field(),], next_page_token="ghi", + fields=[], + next_page_token="def", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + ], + next_page_token="ghi", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + field.Field(), + ], ), - firestore_admin.ListFieldsResponse(fields=[field.Field(), field.Field(),],), RuntimeError, ) - async_pager = await client.list_fields(request={},) + async_pager = await client.list_fields( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -2290,7 +2600,9 @@ async def test_list_fields_async_pager(): @pytest.mark.asyncio async def test_list_fields_async_pages(): - client = FirestoreAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2299,14 +2611,29 @@ async def test_list_fields_async_pages(): # Set the response to a series of pages. call.side_effect = ( firestore_admin.ListFieldsResponse( - fields=[field.Field(), field.Field(), field.Field(),], + fields=[ + field.Field(), + field.Field(), + field.Field(), + ], next_page_token="abc", ), - firestore_admin.ListFieldsResponse(fields=[], next_page_token="def",), firestore_admin.ListFieldsResponse( - fields=[field.Field(),], next_page_token="ghi", + fields=[], + next_page_token="def", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + ], + next_page_token="ghi", + ), + firestore_admin.ListFieldsResponse( + fields=[ + field.Field(), + field.Field(), + ], ), - firestore_admin.ListFieldsResponse(fields=[field.Field(), field.Field(),],), RuntimeError, ) pages = [] @@ -2317,11 +2644,16 @@ async def test_list_fields_async_pages(): @pytest.mark.parametrize( - "request_type", [firestore_admin.ExportDocumentsRequest, dict,] + "request_type", + [ + firestore_admin.ExportDocumentsRequest, + dict, + ], ) def test_export_documents(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2347,7 +2679,8 @@ def test_export_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2363,7 +2696,8 @@ async def test_export_documents_async( transport: str = "grpc_asyncio", request_type=firestore_admin.ExportDocumentsRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2393,7 +2727,9 @@ async def test_export_documents_async_from_dict(): def test_export_documents_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2413,7 +2749,10 @@ def test_export_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2442,11 +2781,16 @@ async def test_export_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_export_documents_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_documents), "__call__") as call: @@ -2454,7 +2798,9 @@ def test_export_documents_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.export_documents(name="name_value",) + client.export_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2466,13 +2812,16 @@ def test_export_documents_flattened(): def test_export_documents_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.export_documents( - firestore_admin.ExportDocumentsRequest(), name="name_value", + firestore_admin.ExportDocumentsRequest(), + name="name_value", ) @@ -2492,7 +2841,9 @@ async def test_export_documents_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.export_documents(name="name_value",) + response = await client.export_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2513,16 +2864,22 @@ async def test_export_documents_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.export_documents( - firestore_admin.ExportDocumentsRequest(), name="name_value", + firestore_admin.ExportDocumentsRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [firestore_admin.ImportDocumentsRequest, dict,] + "request_type", + [ + firestore_admin.ImportDocumentsRequest, + dict, + ], ) def test_import_documents(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2548,7 +2905,8 @@ def test_import_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2564,7 +2922,8 @@ async def test_import_documents_async( transport: str = "grpc_asyncio", request_type=firestore_admin.ImportDocumentsRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2594,7 +2953,9 @@ async def test_import_documents_async_from_dict(): def test_import_documents_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2614,7 +2975,10 @@ def test_import_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2643,11 +3007,16 @@ async def test_import_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_import_documents_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_documents), "__call__") as call: @@ -2655,7 +3024,9 @@ def test_import_documents_flattened(): call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.import_documents(name="name_value",) + client.import_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2667,13 +3038,16 @@ def test_import_documents_flattened(): def test_import_documents_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.import_documents( - firestore_admin.ImportDocumentsRequest(), name="name_value", + firestore_admin.ImportDocumentsRequest(), + name="name_value", ) @@ -2693,7 +3067,9 @@ async def test_import_documents_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.import_documents(name="name_value",) + response = await client.import_documents( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2714,14 +3090,22 @@ async def test_import_documents_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.import_documents( - firestore_admin.ImportDocumentsRequest(), name="name_value", + firestore_admin.ImportDocumentsRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [firestore_admin.GetDatabaseRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.GetDatabaseRequest, + dict, + ], +) def test_get_database(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2758,7 +3142,8 @@ def test_get_database_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2774,7 +3159,8 @@ async def test_get_database_async( transport: str = "grpc_asyncio", request_type=firestore_admin.GetDatabaseRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2815,7 +3201,9 @@ async def test_get_database_async_from_dict(): def test_get_database_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2835,7 +3223,10 @@ def test_get_database_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2862,11 +3253,16 @@ async def test_get_database_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_database_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database), "__call__") as call: @@ -2874,7 +3270,9 @@ def test_get_database_flattened(): call.return_value = database.Database() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_database(name="name_value",) + client.get_database( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2886,13 +3284,16 @@ def test_get_database_flattened(): def test_get_database_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_database( - firestore_admin.GetDatabaseRequest(), name="name_value", + firestore_admin.GetDatabaseRequest(), + name="name_value", ) @@ -2910,7 +3311,9 @@ async def test_get_database_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(database.Database()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_database(name="name_value",) + response = await client.get_database( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2931,14 +3334,22 @@ async def test_get_database_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_database( - firestore_admin.GetDatabaseRequest(), name="name_value", + firestore_admin.GetDatabaseRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [firestore_admin.ListDatabasesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.ListDatabasesRequest, + dict, + ], +) def test_list_databases(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2964,7 +3375,8 @@ def test_list_databases_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2980,7 +3392,8 @@ async def test_list_databases_async( transport: str = "grpc_asyncio", request_type=firestore_admin.ListDatabasesRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3010,7 +3423,9 @@ async def test_list_databases_async_from_dict(): def test_list_databases_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3030,7 +3445,10 @@ def test_list_databases_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3059,11 +3477,16 @@ async def test_list_databases_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_databases_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_databases), "__call__") as call: @@ -3071,7 +3494,9 @@ def test_list_databases_flattened(): call.return_value = firestore_admin.ListDatabasesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_databases(parent="parent_value",) + client.list_databases( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3083,13 +3508,16 @@ def test_list_databases_flattened(): def test_list_databases_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_databases( - firestore_admin.ListDatabasesRequest(), parent="parent_value", + firestore_admin.ListDatabasesRequest(), + parent="parent_value", ) @@ -3109,7 +3537,9 @@ async def test_list_databases_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_databases(parent="parent_value",) + response = await client.list_databases( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3130,14 +3560,22 @@ async def test_list_databases_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_databases( - firestore_admin.ListDatabasesRequest(), parent="parent_value", + firestore_admin.ListDatabasesRequest(), + parent="parent_value", ) -@pytest.mark.parametrize("request_type", [firestore_admin.UpdateDatabaseRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore_admin.UpdateDatabaseRequest, + dict, + ], +) def test_update_database(request_type, transport: str = "grpc"): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3163,7 +3601,8 @@ def test_update_database_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3179,7 +3618,8 @@ async def test_update_database_async( transport: str = "grpc_asyncio", request_type=firestore_admin.UpdateDatabaseRequest ): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3209,7 +3649,9 @@ async def test_update_database_async_from_dict(): def test_update_database_field_headers(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3229,9 +3671,10 @@ def test_update_database_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database.name=database.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "database.name=database.name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3260,13 +3703,16 @@ async def test_update_database_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database.name=database.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "database.name=database.name/value", + ) in kw["metadata"] def test_update_database_flattened(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_database), "__call__") as call: @@ -3292,7 +3738,9 @@ def test_update_database_flattened(): def test_update_database_flattened_error(): - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3360,7 +3808,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3380,7 +3829,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = FirestoreAdminClient(client_options=options, transport=transport,) + client = FirestoreAdminClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -3396,7 +3848,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = FirestoreAdminClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3441,8 +3894,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = FirestoreAdminClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.FirestoreAdminGrpcTransport,) + client = FirestoreAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.FirestoreAdminGrpcTransport, + ) def test_firestore_admin_base_transport_error(): @@ -3503,7 +3961,8 @@ def test_firestore_admin_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.FirestoreAdminTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3673,7 +4132,8 @@ def test_firestore_admin_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.FirestoreAdminGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3685,7 +4145,8 @@ def test_firestore_admin_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.FirestoreAdminGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3794,12 +4255,16 @@ def test_firestore_admin_transport_channel_mtls_with_adc(transport_class): def test_firestore_admin_grpc_lro_client(): client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3807,12 +4272,16 @@ def test_firestore_admin_grpc_lro_client(): def test_firestore_admin_grpc_lro_async_client(): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -3822,8 +4291,12 @@ def test_collection_group_path(): project = "squid" database = "clam" collection = "whelk" - expected = "projects/{project}/databases/{database}/collectionGroups/{collection}".format( - project=project, database=database, collection=collection, + expected = ( + "projects/{project}/databases/{database}/collectionGroups/{collection}".format( + project=project, + database=database, + collection=collection, + ) ) actual = FirestoreAdminClient.collection_group_path(project, database, collection) assert expected == actual @@ -3846,7 +4319,8 @@ def test_database_path(): project = "cuttlefish" database = "mussel" expected = "projects/{project}/databases/{database}".format( - project=project, database=database, + project=project, + database=database, ) actual = FirestoreAdminClient.database_path(project, database) assert expected == actual @@ -3870,7 +4344,10 @@ def test_field_path(): collection = "squid" field = "clam" expected = "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}".format( - project=project, database=database, collection=collection, field=field, + project=project, + database=database, + collection=collection, + field=field, ) actual = FirestoreAdminClient.field_path(project, database, collection, field) assert expected == actual @@ -3896,7 +4373,10 @@ def test_index_path(): collection = "winkle" index = "nautilus" expected = "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}".format( - project=project, database=database, collection=collection, index=index, + project=project, + database=database, + collection=collection, + index=index, ) actual = FirestoreAdminClient.index_path(project, database, collection, index) assert expected == actual @@ -3938,7 +4418,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = FirestoreAdminClient.common_folder_path(folder) assert expected == actual @@ -3956,7 +4438,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = FirestoreAdminClient.common_organization_path(organization) assert expected == actual @@ -3974,7 +4458,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = FirestoreAdminClient.common_project_path(project) assert expected == actual @@ -3994,7 +4480,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = FirestoreAdminClient.common_location_path(project, location) assert expected == actual @@ -4019,7 +4506,8 @@ def test_client_with_default_client_info(): transports.FirestoreAdminTransport, "_prep_wrapped_messages" ) as prep: client = FirestoreAdminClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4028,7 +4516,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = FirestoreAdminClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4036,7 +4525,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = FirestoreAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/firestore_v1/test_firestore.py b/tests/unit/gapic/firestore_v1/test_firestore.py index f9d9d614f2..f8c68848f4 100644 --- a/tests/unit/gapic/firestore_v1/test_firestore.py +++ b/tests/unit/gapic/firestore_v1/test_firestore.py @@ -89,7 +89,13 @@ def test__get_default_mtls_endpoint(): assert FirestoreClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [FirestoreClient, FirestoreAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + FirestoreClient, + FirestoreAsyncClient, + ], +) def test_firestore_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -129,7 +135,13 @@ def test_firestore_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [FirestoreClient, FirestoreAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + FirestoreClient, + FirestoreAsyncClient, + ], +) def test_firestore_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -482,7 +494,9 @@ def test_firestore_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -613,10 +627,17 @@ def test_firestore_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [firestore.GetDocumentRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.GetDocumentRequest, + dict, + ], +) def test_get_document(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -626,7 +647,9 @@ def test_get_document(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_document), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = document.Document(name="name_value",) + call.return_value = document.Document( + name="name_value", + ) response = client.get_document(request) # Establish that the underlying gRPC stub method was called. @@ -643,7 +666,8 @@ def test_get_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -659,7 +683,8 @@ async def test_get_document_async( transport: str = "grpc_asyncio", request_type=firestore.GetDocumentRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -670,7 +695,9 @@ async def test_get_document_async( with mock.patch.object(type(client.transport.get_document), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - document.Document(name="name_value",) + document.Document( + name="name_value", + ) ) response = await client.get_document(request) @@ -690,7 +717,9 @@ async def test_get_document_async_from_dict(): def test_get_document_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -710,12 +739,17 @@ def test_get_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_document_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -735,13 +769,23 @@ async def test_get_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [firestore.ListDocumentsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.ListDocumentsRequest, + dict, + ], +) def test_list_documents(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -770,7 +814,8 @@ def test_list_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -786,7 +831,8 @@ async def test_list_documents_async( transport: str = "grpc_asyncio", request_type=firestore.ListDocumentsRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -797,7 +843,9 @@ async def test_list_documents_async( with mock.patch.object(type(client.transport.list_documents), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - firestore.ListDocumentsResponse(next_page_token="next_page_token_value",) + firestore.ListDocumentsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_documents(request) @@ -817,7 +865,9 @@ async def test_list_documents_async_from_dict(): def test_list_documents_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -837,12 +887,17 @@ def test_list_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_documents_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -864,12 +919,16 @@ async def test_list_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_documents_pager(transport_name: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -884,12 +943,21 @@ def test_list_documents_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - firestore.ListDocumentsResponse(documents=[], next_page_token="def",), firestore.ListDocumentsResponse( - documents=[document.Document(),], next_page_token="ghi", + documents=[], + next_page_token="def", ), firestore.ListDocumentsResponse( - documents=[document.Document(), document.Document(),], + documents=[ + document.Document(), + ], + next_page_token="ghi", + ), + firestore.ListDocumentsResponse( + documents=[ + document.Document(), + document.Document(), + ], ), RuntimeError, ) @@ -909,7 +977,8 @@ def test_list_documents_pager(transport_name: str = "grpc"): def test_list_documents_pages(transport_name: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -924,12 +993,21 @@ def test_list_documents_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - firestore.ListDocumentsResponse(documents=[], next_page_token="def",), firestore.ListDocumentsResponse( - documents=[document.Document(),], next_page_token="ghi", + documents=[], + next_page_token="def", + ), + firestore.ListDocumentsResponse( + documents=[ + document.Document(), + ], + next_page_token="ghi", ), firestore.ListDocumentsResponse( - documents=[document.Document(), document.Document(),], + documents=[ + document.Document(), + document.Document(), + ], ), RuntimeError, ) @@ -940,7 +1018,9 @@ def test_list_documents_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_documents_async_pager(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -956,16 +1036,27 @@ async def test_list_documents_async_pager(): ], next_page_token="abc", ), - firestore.ListDocumentsResponse(documents=[], next_page_token="def",), firestore.ListDocumentsResponse( - documents=[document.Document(),], next_page_token="ghi", + documents=[], + next_page_token="def", + ), + firestore.ListDocumentsResponse( + documents=[ + document.Document(), + ], + next_page_token="ghi", ), firestore.ListDocumentsResponse( - documents=[document.Document(), document.Document(),], + documents=[ + document.Document(), + document.Document(), + ], ), RuntimeError, ) - async_pager = await client.list_documents(request={},) + async_pager = await client.list_documents( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -977,7 +1068,9 @@ async def test_list_documents_async_pager(): @pytest.mark.asyncio async def test_list_documents_async_pages(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -993,12 +1086,21 @@ async def test_list_documents_async_pages(): ], next_page_token="abc", ), - firestore.ListDocumentsResponse(documents=[], next_page_token="def",), firestore.ListDocumentsResponse( - documents=[document.Document(),], next_page_token="ghi", + documents=[], + next_page_token="def", ), firestore.ListDocumentsResponse( - documents=[document.Document(), document.Document(),], + documents=[ + document.Document(), + ], + next_page_token="ghi", + ), + firestore.ListDocumentsResponse( + documents=[ + document.Document(), + document.Document(), + ], ), RuntimeError, ) @@ -1009,10 +1111,17 @@ async def test_list_documents_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [firestore.UpdateDocumentRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.UpdateDocumentRequest, + dict, + ], +) def test_update_document(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1022,7 +1131,9 @@ def test_update_document(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_document), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gf_document.Document(name="name_value",) + call.return_value = gf_document.Document( + name="name_value", + ) response = client.update_document(request) # Establish that the underlying gRPC stub method was called. @@ -1039,7 +1150,8 @@ def test_update_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1055,7 +1167,8 @@ async def test_update_document_async( transport: str = "grpc_asyncio", request_type=firestore.UpdateDocumentRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1066,7 +1179,9 @@ async def test_update_document_async( with mock.patch.object(type(client.transport.update_document), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gf_document.Document(name="name_value",) + gf_document.Document( + name="name_value", + ) ) response = await client.update_document(request) @@ -1086,7 +1201,9 @@ async def test_update_document_async_from_dict(): def test_update_document_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1106,14 +1223,17 @@ def test_update_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "document.name=document.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "document.name=document.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_document_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1135,13 +1255,16 @@ async def test_update_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "document.name=document.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "document.name=document.name/value", + ) in kw["metadata"] def test_update_document_flattened(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_document), "__call__") as call: @@ -1167,7 +1290,9 @@ def test_update_document_flattened(): def test_update_document_flattened_error(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1181,7 +1306,9 @@ def test_update_document_flattened_error(): @pytest.mark.asyncio async def test_update_document_flattened_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_document), "__call__") as call: @@ -1212,7 +1339,9 @@ async def test_update_document_flattened_async(): @pytest.mark.asyncio async def test_update_document_flattened_error_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1224,10 +1353,17 @@ async def test_update_document_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [firestore.DeleteDocumentRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.DeleteDocumentRequest, + dict, + ], +) def test_delete_document(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1253,7 +1389,8 @@ def test_delete_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1269,7 +1406,8 @@ async def test_delete_document_async( transport: str = "grpc_asyncio", request_type=firestore.DeleteDocumentRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1297,7 +1435,9 @@ async def test_delete_document_async_from_dict(): def test_delete_document_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1317,12 +1457,17 @@ def test_delete_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_document_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1342,11 +1487,16 @@ async def test_delete_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_document_flattened(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_document), "__call__") as call: @@ -1354,7 +1504,9 @@ def test_delete_document_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_document(name="name_value",) + client.delete_document( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1366,19 +1518,24 @@ def test_delete_document_flattened(): def test_delete_document_flattened_error(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_document( - firestore.DeleteDocumentRequest(), name="name_value", + firestore.DeleteDocumentRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_document_flattened_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_document), "__call__") as call: @@ -1388,7 +1545,9 @@ async def test_delete_document_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_document(name="name_value",) + response = await client.delete_document( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1401,20 +1560,30 @@ async def test_delete_document_flattened_async(): @pytest.mark.asyncio async def test_delete_document_flattened_error_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_document( - firestore.DeleteDocumentRequest(), name="name_value", + firestore.DeleteDocumentRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [firestore.BatchGetDocumentsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.BatchGetDocumentsRequest, + dict, + ], +) def test_batch_get_documents(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1443,7 +1612,8 @@ def test_batch_get_documents_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1461,7 +1631,8 @@ async def test_batch_get_documents_async( transport: str = "grpc_asyncio", request_type=firestore.BatchGetDocumentsRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1495,7 +1666,9 @@ async def test_batch_get_documents_async_from_dict(): def test_batch_get_documents_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1517,12 +1690,17 @@ def test_batch_get_documents_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_batch_get_documents_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1547,13 +1725,23 @@ async def test_batch_get_documents_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [firestore.BeginTransactionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.BeginTransactionRequest, + dict, + ], +) def test_begin_transaction(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1584,7 +1772,8 @@ def test_begin_transaction_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1602,7 +1791,8 @@ async def test_begin_transaction_async( transport: str = "grpc_asyncio", request_type=firestore.BeginTransactionRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1615,7 +1805,9 @@ async def test_begin_transaction_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - firestore.BeginTransactionResponse(transaction=b"transaction_blob",) + firestore.BeginTransactionResponse( + transaction=b"transaction_blob", + ) ) response = await client.begin_transaction(request) @@ -1635,7 +1827,9 @@ async def test_begin_transaction_async_from_dict(): def test_begin_transaction_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1657,12 +1851,17 @@ def test_begin_transaction_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_begin_transaction_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1686,11 +1885,16 @@ async def test_begin_transaction_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_begin_transaction_flattened(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1700,7 +1904,9 @@ def test_begin_transaction_flattened(): call.return_value = firestore.BeginTransactionResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.begin_transaction(database="database_value",) + client.begin_transaction( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1712,19 +1918,24 @@ def test_begin_transaction_flattened(): def test_begin_transaction_flattened_error(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.begin_transaction( - firestore.BeginTransactionRequest(), database="database_value", + firestore.BeginTransactionRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_begin_transaction_flattened_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1738,7 +1949,9 @@ async def test_begin_transaction_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.begin_transaction(database="database_value",) + response = await client.begin_transaction( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1751,20 +1964,30 @@ async def test_begin_transaction_flattened_async(): @pytest.mark.asyncio async def test_begin_transaction_flattened_error_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.begin_transaction( - firestore.BeginTransactionRequest(), database="database_value", + firestore.BeginTransactionRequest(), + database="database_value", ) -@pytest.mark.parametrize("request_type", [firestore.CommitRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.CommitRequest, + dict, + ], +) def test_commit(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1790,7 +2013,8 @@ def test_commit_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1806,7 +2030,8 @@ async def test_commit_async( transport: str = "grpc_asyncio", request_type=firestore.CommitRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1836,7 +2061,9 @@ async def test_commit_async_from_dict(): def test_commit_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1856,12 +2083,17 @@ def test_commit_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_commit_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1883,11 +2115,16 @@ async def test_commit_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_commit_flattened(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.commit), "__call__") as call: @@ -1913,7 +2150,9 @@ def test_commit_flattened(): def test_commit_flattened_error(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1927,7 +2166,9 @@ def test_commit_flattened_error(): @pytest.mark.asyncio async def test_commit_flattened_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.commit), "__call__") as call: @@ -1958,7 +2199,9 @@ async def test_commit_flattened_async(): @pytest.mark.asyncio async def test_commit_flattened_error_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1970,10 +2213,17 @@ async def test_commit_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [firestore.RollbackRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.RollbackRequest, + dict, + ], +) def test_rollback(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1999,7 +2249,8 @@ def test_rollback_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2015,7 +2266,8 @@ async def test_rollback_async( transport: str = "grpc_asyncio", request_type=firestore.RollbackRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2043,7 +2295,9 @@ async def test_rollback_async_from_dict(): def test_rollback_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2063,12 +2317,17 @@ def test_rollback_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_rollback_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2088,11 +2347,16 @@ async def test_rollback_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_rollback_flattened(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.rollback), "__call__") as call: @@ -2101,7 +2365,8 @@ def test_rollback_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.rollback( - database="database_value", transaction=b"transaction_blob", + database="database_value", + transaction=b"transaction_blob", ) # Establish that the underlying call was made with the expected @@ -2117,7 +2382,9 @@ def test_rollback_flattened(): def test_rollback_flattened_error(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2131,7 +2398,9 @@ def test_rollback_flattened_error(): @pytest.mark.asyncio async def test_rollback_flattened_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.rollback), "__call__") as call: @@ -2142,7 +2411,8 @@ async def test_rollback_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.rollback( - database="database_value", transaction=b"transaction_blob", + database="database_value", + transaction=b"transaction_blob", ) # Establish that the underlying call was made with the expected @@ -2159,7 +2429,9 @@ async def test_rollback_flattened_async(): @pytest.mark.asyncio async def test_rollback_flattened_error_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2171,10 +2443,17 @@ async def test_rollback_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [firestore.RunQueryRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.RunQueryRequest, + dict, + ], +) def test_run_query(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2201,7 +2480,8 @@ def test_run_query_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2217,7 +2497,8 @@ async def test_run_query_async( transport: str = "grpc_asyncio", request_type=firestore.RunQueryRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2249,7 +2530,9 @@ async def test_run_query_async_from_dict(): def test_run_query_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2269,12 +2552,17 @@ def test_run_query_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_run_query_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2297,13 +2585,23 @@ async def test_run_query_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [firestore.PartitionQueryRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.PartitionQueryRequest, + dict, + ], +) def test_partition_query(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2332,7 +2630,8 @@ def test_partition_query_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2348,7 +2647,8 @@ async def test_partition_query_async( transport: str = "grpc_asyncio", request_type=firestore.PartitionQueryRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2359,7 +2659,9 @@ async def test_partition_query_async( with mock.patch.object(type(client.transport.partition_query), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - firestore.PartitionQueryResponse(next_page_token="next_page_token_value",) + firestore.PartitionQueryResponse( + next_page_token="next_page_token_value", + ) ) response = await client.partition_query(request) @@ -2379,7 +2681,9 @@ async def test_partition_query_async_from_dict(): def test_partition_query_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2399,12 +2703,17 @@ def test_partition_query_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_partition_query_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2426,12 +2735,16 @@ async def test_partition_query_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_partition_query_pager(transport_name: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2439,15 +2752,28 @@ def test_partition_query_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + query.Cursor(), + ], next_page_token="abc", ), - firestore.PartitionQueryResponse(partitions=[], next_page_token="def",), firestore.PartitionQueryResponse( - partitions=[query.Cursor(),], next_page_token="ghi", + partitions=[], + next_page_token="def", + ), + firestore.PartitionQueryResponse( + partitions=[ + query.Cursor(), + ], + next_page_token="ghi", ), firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + ], ), RuntimeError, ) @@ -2467,7 +2793,8 @@ def test_partition_query_pager(transport_name: str = "grpc"): def test_partition_query_pages(transport_name: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2475,15 +2802,28 @@ def test_partition_query_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + query.Cursor(), + ], next_page_token="abc", ), - firestore.PartitionQueryResponse(partitions=[], next_page_token="def",), firestore.PartitionQueryResponse( - partitions=[query.Cursor(),], next_page_token="ghi", + partitions=[], + next_page_token="def", + ), + firestore.PartitionQueryResponse( + partitions=[ + query.Cursor(), + ], + next_page_token="ghi", ), firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + ], ), RuntimeError, ) @@ -2494,7 +2834,9 @@ def test_partition_query_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_partition_query_async_pager(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2503,19 +2845,34 @@ async def test_partition_query_async_pager(): # Set the response to a series of pages. call.side_effect = ( firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + query.Cursor(), + ], next_page_token="abc", ), - firestore.PartitionQueryResponse(partitions=[], next_page_token="def",), firestore.PartitionQueryResponse( - partitions=[query.Cursor(),], next_page_token="ghi", + partitions=[], + next_page_token="def", ), firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + ], + next_page_token="ghi", + ), + firestore.PartitionQueryResponse( + partitions=[ + query.Cursor(), + query.Cursor(), + ], ), RuntimeError, ) - async_pager = await client.partition_query(request={},) + async_pager = await client.partition_query( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -2527,7 +2884,9 @@ async def test_partition_query_async_pager(): @pytest.mark.asyncio async def test_partition_query_async_pages(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2536,15 +2895,28 @@ async def test_partition_query_async_pages(): # Set the response to a series of pages. call.side_effect = ( firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + query.Cursor(), + ], next_page_token="abc", ), - firestore.PartitionQueryResponse(partitions=[], next_page_token="def",), firestore.PartitionQueryResponse( - partitions=[query.Cursor(),], next_page_token="ghi", + partitions=[], + next_page_token="def", + ), + firestore.PartitionQueryResponse( + partitions=[ + query.Cursor(), + ], + next_page_token="ghi", ), firestore.PartitionQueryResponse( - partitions=[query.Cursor(), query.Cursor(),], + partitions=[ + query.Cursor(), + query.Cursor(), + ], ), RuntimeError, ) @@ -2555,10 +2927,17 @@ async def test_partition_query_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [firestore.WriteRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.WriteRequest, + dict, + ], +) def test_write(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2587,7 +2966,8 @@ async def test_write_async( transport: str = "grpc_asyncio", request_type=firestore.WriteRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2617,10 +2997,17 @@ async def test_write_async_from_dict(): await test_write_async(request_type=dict) -@pytest.mark.parametrize("request_type", [firestore.ListenRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.ListenRequest, + dict, + ], +) def test_listen(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2649,7 +3036,8 @@ async def test_listen_async( transport: str = "grpc_asyncio", request_type=firestore.ListenRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2681,10 +3069,17 @@ async def test_listen_async_from_dict(): await test_listen_async(request_type=dict) -@pytest.mark.parametrize("request_type", [firestore.ListCollectionIdsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.ListCollectionIdsRequest, + dict, + ], +) def test_list_collection_ids(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2717,7 +3112,8 @@ def test_list_collection_ids_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2735,7 +3131,8 @@ async def test_list_collection_ids_async( transport: str = "grpc_asyncio", request_type=firestore.ListCollectionIdsRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2772,7 +3169,9 @@ async def test_list_collection_ids_async_from_dict(): def test_list_collection_ids_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2794,12 +3193,17 @@ def test_list_collection_ids_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_collection_ids_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2823,11 +3227,16 @@ async def test_list_collection_ids_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_collection_ids_flattened(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2837,7 +3246,9 @@ def test_list_collection_ids_flattened(): call.return_value = firestore.ListCollectionIdsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_collection_ids(parent="parent_value",) + client.list_collection_ids( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2849,19 +3260,24 @@ def test_list_collection_ids_flattened(): def test_list_collection_ids_flattened_error(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_collection_ids( - firestore.ListCollectionIdsRequest(), parent="parent_value", + firestore.ListCollectionIdsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_collection_ids_flattened_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2875,7 +3291,9 @@ async def test_list_collection_ids_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_collection_ids(parent="parent_value",) + response = await client.list_collection_ids( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2888,19 +3306,23 @@ async def test_list_collection_ids_flattened_async(): @pytest.mark.asyncio async def test_list_collection_ids_flattened_error_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_collection_ids( - firestore.ListCollectionIdsRequest(), parent="parent_value", + firestore.ListCollectionIdsRequest(), + parent="parent_value", ) def test_list_collection_ids_pager(transport_name: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2910,15 +3332,29 @@ def test_list_collection_ids_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore.ListCollectionIdsResponse( - collection_ids=[str(), str(), str(),], next_page_token="abc", + collection_ids=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), firestore.ListCollectionIdsResponse( - collection_ids=[], next_page_token="def", + collection_ids=[], + next_page_token="def", ), firestore.ListCollectionIdsResponse( - collection_ids=[str(),], next_page_token="ghi", + collection_ids=[ + str(), + ], + next_page_token="ghi", + ), + firestore.ListCollectionIdsResponse( + collection_ids=[ + str(), + str(), + ], ), - firestore.ListCollectionIdsResponse(collection_ids=[str(), str(),],), RuntimeError, ) @@ -2937,7 +3373,8 @@ def test_list_collection_ids_pager(transport_name: str = "grpc"): def test_list_collection_ids_pages(transport_name: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2947,15 +3384,29 @@ def test_list_collection_ids_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( firestore.ListCollectionIdsResponse( - collection_ids=[str(), str(), str(),], next_page_token="abc", + collection_ids=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), firestore.ListCollectionIdsResponse( - collection_ids=[], next_page_token="def", + collection_ids=[], + next_page_token="def", + ), + firestore.ListCollectionIdsResponse( + collection_ids=[ + str(), + ], + next_page_token="ghi", ), firestore.ListCollectionIdsResponse( - collection_ids=[str(),], next_page_token="ghi", + collection_ids=[ + str(), + str(), + ], ), - firestore.ListCollectionIdsResponse(collection_ids=[str(), str(),],), RuntimeError, ) pages = list(client.list_collection_ids(request={}).pages) @@ -2965,7 +3416,9 @@ def test_list_collection_ids_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_collection_ids_async_pager(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2976,18 +3429,34 @@ async def test_list_collection_ids_async_pager(): # Set the response to a series of pages. call.side_effect = ( firestore.ListCollectionIdsResponse( - collection_ids=[str(), str(), str(),], next_page_token="abc", + collection_ids=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), firestore.ListCollectionIdsResponse( - collection_ids=[], next_page_token="def", + collection_ids=[], + next_page_token="def", ), firestore.ListCollectionIdsResponse( - collection_ids=[str(),], next_page_token="ghi", + collection_ids=[ + str(), + ], + next_page_token="ghi", + ), + firestore.ListCollectionIdsResponse( + collection_ids=[ + str(), + str(), + ], ), - firestore.ListCollectionIdsResponse(collection_ids=[str(), str(),],), RuntimeError, ) - async_pager = await client.list_collection_ids(request={},) + async_pager = await client.list_collection_ids( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -2999,7 +3468,9 @@ async def test_list_collection_ids_async_pager(): @pytest.mark.asyncio async def test_list_collection_ids_async_pages(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3010,15 +3481,29 @@ async def test_list_collection_ids_async_pages(): # Set the response to a series of pages. call.side_effect = ( firestore.ListCollectionIdsResponse( - collection_ids=[str(), str(), str(),], next_page_token="abc", + collection_ids=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), firestore.ListCollectionIdsResponse( - collection_ids=[], next_page_token="def", + collection_ids=[], + next_page_token="def", ), firestore.ListCollectionIdsResponse( - collection_ids=[str(),], next_page_token="ghi", + collection_ids=[ + str(), + ], + next_page_token="ghi", + ), + firestore.ListCollectionIdsResponse( + collection_ids=[ + str(), + str(), + ], ), - firestore.ListCollectionIdsResponse(collection_ids=[str(), str(),],), RuntimeError, ) pages = [] @@ -3028,10 +3513,17 @@ async def test_list_collection_ids_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [firestore.BatchWriteRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.BatchWriteRequest, + dict, + ], +) def test_batch_write(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3057,7 +3549,8 @@ def test_batch_write_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3073,7 +3566,8 @@ async def test_batch_write_async( transport: str = "grpc_asyncio", request_type=firestore.BatchWriteRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3103,7 +3597,9 @@ async def test_batch_write_async_from_dict(): def test_batch_write_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3123,12 +3619,17 @@ def test_batch_write_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_batch_write_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3150,13 +3651,23 @@ async def test_batch_write_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [firestore.CreateDocumentRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + firestore.CreateDocumentRequest, + dict, + ], +) def test_create_document(request_type, transport: str = "grpc"): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3166,7 +3677,9 @@ def test_create_document(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_document), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = document.Document(name="name_value",) + call.return_value = document.Document( + name="name_value", + ) response = client.create_document(request) # Establish that the underlying gRPC stub method was called. @@ -3183,7 +3696,8 @@ def test_create_document_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3199,7 +3713,8 @@ async def test_create_document_async( transport: str = "grpc_asyncio", request_type=firestore.CreateDocumentRequest ): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3210,7 +3725,9 @@ async def test_create_document_async( with mock.patch.object(type(client.transport.create_document), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - document.Document(name="name_value",) + document.Document( + name="name_value", + ) ) response = await client.create_document(request) @@ -3230,7 +3747,9 @@ async def test_create_document_async_from_dict(): def test_create_document_field_headers(): - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3250,12 +3769,17 @@ def test_create_document_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_document_field_headers_async(): - client = FirestoreAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = FirestoreAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3275,7 +3799,10 @@ async def test_create_document_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -3285,7 +3812,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3305,7 +3833,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = FirestoreClient(client_options=options, transport=transport,) + client = FirestoreClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -3321,7 +3852,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = FirestoreClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3351,7 +3883,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.FirestoreGrpcTransport, transports.FirestoreGrpcAsyncIOTransport,], + [ + transports.FirestoreGrpcTransport, + transports.FirestoreGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -3363,8 +3898,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = FirestoreClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.FirestoreGrpcTransport,) + client = FirestoreClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.FirestoreGrpcTransport, + ) def test_firestore_base_transport_error(): @@ -3423,7 +3963,8 @@ def test_firestore_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.FirestoreTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3464,7 +4005,10 @@ def test_firestore_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.FirestoreGrpcTransport, transports.FirestoreGrpcAsyncIOTransport,], + [ + transports.FirestoreGrpcTransport, + transports.FirestoreGrpcAsyncIOTransport, + ], ) def test_firestore_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -3587,7 +4131,8 @@ def test_firestore_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.FirestoreGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3599,7 +4144,8 @@ def test_firestore_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.FirestoreGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3720,7 +4266,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = FirestoreClient.common_folder_path(folder) assert expected == actual @@ -3738,7 +4286,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = FirestoreClient.common_organization_path(organization) assert expected == actual @@ -3756,7 +4306,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = FirestoreClient.common_project_path(project) assert expected == actual @@ -3776,7 +4328,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = FirestoreClient.common_location_path(project, location) assert expected == actual @@ -3801,7 +4354,8 @@ def test_client_with_default_client_info(): transports.FirestoreTransport, "_prep_wrapped_messages" ) as prep: client = FirestoreClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3810,7 +4364,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = FirestoreClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3818,7 +4373,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = FirestoreAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/v1/_test_helpers.py b/tests/unit/v1/_test_helpers.py index 92d20b7ece..3b09f9f9ad 100644 --- a/tests/unit/v1/_test_helpers.py +++ b/tests/unit/v1/_test_helpers.py @@ -35,7 +35,8 @@ def make_test_credentials() -> google.auth.credentials.Credentials: # type: ign def make_client(project_name: typing.Optional[str] = None) -> Client: return Client( - project=project_name or "project-project", credentials=make_test_credentials(), + project=project_name or "project-project", + credentials=make_test_credentials(), ) diff --git a/tests/unit/v1/conformance_tests.py b/tests/unit/v1/conformance_tests.py index 9254395c05..779c83b0e3 100644 --- a/tests/unit/v1/conformance_tests.py +++ b/tests/unit/v1/conformance_tests.py @@ -60,7 +60,11 @@ class TestFile(proto.Message): """ - tests = proto.RepeatedField(proto.MESSAGE, number=1, message="Test",) + tests = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Test", + ) class Test(proto.Message): @@ -95,23 +99,61 @@ class Test(proto.Message): comment = proto.Field(proto.STRING, number=10) - get = proto.Field(proto.MESSAGE, number=2, oneof="test", message="GetTest",) + get = proto.Field( + proto.MESSAGE, + number=2, + oneof="test", + message="GetTest", + ) - create = proto.Field(proto.MESSAGE, number=3, oneof="test", message="CreateTest",) + create = proto.Field( + proto.MESSAGE, + number=3, + oneof="test", + message="CreateTest", + ) - set_ = proto.Field(proto.MESSAGE, number=4, oneof="test", message="SetTest",) + set_ = proto.Field( + proto.MESSAGE, + number=4, + oneof="test", + message="SetTest", + ) - update = proto.Field(proto.MESSAGE, number=5, oneof="test", message="UpdateTest",) + update = proto.Field( + proto.MESSAGE, + number=5, + oneof="test", + message="UpdateTest", + ) update_paths = proto.Field( - proto.MESSAGE, number=6, oneof="test", message="UpdatePathsTest", + proto.MESSAGE, + number=6, + oneof="test", + message="UpdatePathsTest", ) - delete = proto.Field(proto.MESSAGE, number=7, oneof="test", message="DeleteTest",) + delete = proto.Field( + proto.MESSAGE, + number=7, + oneof="test", + message="DeleteTest", + ) - query = proto.Field(proto.MESSAGE, number=8, oneof="test", message="QueryTest",) + query = proto.Field( + proto.MESSAGE, + number=8, + oneof="test", + message="QueryTest", + ) - listen = proto.Field(proto.MESSAGE, number=9, oneof="test", message="ListenTest",) + listen = proto.Field( + proto.MESSAGE, + number=9, + oneof="test", + message="ListenTest", + ) class GetTest(proto.Message): @@ -129,7 +171,9 @@ class GetTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) request = proto.Field( - proto.MESSAGE, number=2, message=firestore.GetDocumentRequest, + proto.MESSAGE, + number=2, + message=firestore.GetDocumentRequest, ) @@ -158,7 +202,11 @@ class CreateTest(proto.Message): json_data = proto.Field(proto.STRING, number=2) - request = proto.Field(proto.MESSAGE, number=3, message=firestore.CommitRequest,) + request = proto.Field( + proto.MESSAGE, + number=3, + message=firestore.CommitRequest, + ) is_error = proto.Field(proto.BOOL, number=4) @@ -181,11 +229,19 @@ class SetTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - option = proto.Field(proto.MESSAGE, number=2, message="SetOption",) + option = proto.Field( + proto.MESSAGE, + number=2, + message="SetOption", + ) json_data = proto.Field(proto.STRING, number=3) - request = proto.Field(proto.MESSAGE, number=4, message=firestore.CommitRequest,) + request = proto.Field( + proto.MESSAGE, + number=4, + message=firestore.CommitRequest, + ) is_error = proto.Field(proto.BOOL, number=5) @@ -209,11 +265,19 @@ class UpdateTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - precondition = proto.Field(proto.MESSAGE, number=2, message=common.Precondition,) + precondition = proto.Field( + proto.MESSAGE, + number=2, + message=common.Precondition, + ) json_data = proto.Field(proto.STRING, number=3) - request = proto.Field(proto.MESSAGE, number=4, message=firestore.CommitRequest,) + request = proto.Field( + proto.MESSAGE, + number=4, + message=firestore.CommitRequest, + ) is_error = proto.Field(proto.BOOL, number=5) @@ -240,13 +304,25 @@ class UpdatePathsTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - precondition = proto.Field(proto.MESSAGE, number=2, message=common.Precondition,) + precondition = proto.Field( + proto.MESSAGE, + number=2, + message=common.Precondition, + ) - field_paths = proto.RepeatedField(proto.MESSAGE, number=3, message="FieldPath",) + field_paths = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="FieldPath", + ) json_values = proto.RepeatedField(proto.STRING, number=4) - request = proto.Field(proto.MESSAGE, number=5, message=firestore.CommitRequest,) + request = proto.Field( + proto.MESSAGE, + number=5, + message=firestore.CommitRequest, + ) is_error = proto.Field(proto.BOOL, number=6) @@ -267,9 +343,17 @@ class DeleteTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - precondition = proto.Field(proto.MESSAGE, number=2, message=common.Precondition,) + precondition = proto.Field( + proto.MESSAGE, + number=2, + message=common.Precondition, + ) - request = proto.Field(proto.MESSAGE, number=3, message=firestore.CommitRequest,) + request = proto.Field( + proto.MESSAGE, + number=3, + message=firestore.CommitRequest, + ) is_error = proto.Field(proto.BOOL, number=4) @@ -287,7 +371,11 @@ class SetOption(proto.Message): all_ = proto.Field(proto.BOOL, number=1) - fields = proto.RepeatedField(proto.MESSAGE, number=2, message="FieldPath",) + fields = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="FieldPath", + ) class QueryTest(proto.Message): @@ -307,9 +395,17 @@ class QueryTest(proto.Message): coll_path = proto.Field(proto.STRING, number=1) - clauses = proto.RepeatedField(proto.MESSAGE, number=2, message="Clause",) + clauses = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="Clause", + ) - query = proto.Field(proto.MESSAGE, number=3, message=gcf_query.StructuredQuery,) + query = proto.Field( + proto.MESSAGE, + number=3, + message=gcf_query.StructuredQuery, + ) is_error = proto.Field(proto.BOOL, number=4) @@ -338,26 +434,57 @@ class Clause(proto.Message): """ - select = proto.Field(proto.MESSAGE, number=1, oneof="clause", message="Select",) + select = proto.Field( + proto.MESSAGE, + number=1, + oneof="clause", + message="Select", + ) - where = proto.Field(proto.MESSAGE, number=2, oneof="clause", message="Where",) + where = proto.Field( + proto.MESSAGE, + number=2, + oneof="clause", + message="Where", + ) - order_by = proto.Field(proto.MESSAGE, number=3, oneof="clause", message="OrderBy",) + order_by = proto.Field( + proto.MESSAGE, + number=3, + oneof="clause", + message="OrderBy", + ) offset = proto.Field(proto.INT32, number=4, oneof="clause") limit = proto.Field(proto.INT32, number=5, oneof="clause") - start_at = proto.Field(proto.MESSAGE, number=6, oneof="clause", message="Cursor_",) + start_at = proto.Field( + proto.MESSAGE, + number=6, + oneof="clause", + message="Cursor_", + ) start_after = proto.Field( - proto.MESSAGE, number=7, oneof="clause", message="Cursor_", + proto.MESSAGE, + number=7, + oneof="clause", + message="Cursor_", ) - end_at = proto.Field(proto.MESSAGE, number=8, oneof="clause", message="Cursor_",) + end_at = proto.Field( + proto.MESSAGE, + number=8, + oneof="clause", + message="Cursor_", + ) end_before = proto.Field( - proto.MESSAGE, number=9, oneof="clause", message="Cursor_", + proto.MESSAGE, + number=9, + oneof="clause", + message="Cursor_", ) @@ -369,7 +496,11 @@ class Select(proto.Message): """ - fields = proto.RepeatedField(proto.MESSAGE, number=1, message="FieldPath",) + fields = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="FieldPath", + ) class Where(proto.Message): @@ -384,7 +515,11 @@ class Where(proto.Message): """ - path = proto.Field(proto.MESSAGE, number=1, message="FieldPath",) + path = proto.Field( + proto.MESSAGE, + number=1, + message="FieldPath", + ) op = proto.Field(proto.STRING, number=2) @@ -401,7 +536,11 @@ class OrderBy(proto.Message): "asc" or "desc". """ - path = proto.Field(proto.MESSAGE, number=1, message="FieldPath",) + path = proto.Field( + proto.MESSAGE, + number=1, + message="FieldPath", + ) direction = proto.Field(proto.STRING, number=2) @@ -416,7 +555,11 @@ class Cursor_(proto.Message): """ - doc_snapshot = proto.Field(proto.MESSAGE, number=1, message="DocSnapshot",) + doc_snapshot = proto.Field( + proto.MESSAGE, + number=1, + message="DocSnapshot", + ) json_values = proto.RepeatedField(proto.STRING, number=2) @@ -471,10 +614,16 @@ class ListenTest(proto.Message): """ responses = proto.RepeatedField( - proto.MESSAGE, number=1, message=firestore.ListenResponse, + proto.MESSAGE, + number=1, + message=firestore.ListenResponse, ) - snapshots = proto.RepeatedField(proto.MESSAGE, number=2, message="Snapshot",) + snapshots = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="Snapshot", + ) is_error = proto.Field(proto.BOOL, number=3) @@ -491,11 +640,23 @@ class Snapshot(proto.Message): """ - docs = proto.RepeatedField(proto.MESSAGE, number=1, message=document.Document,) + docs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=document.Document, + ) - changes = proto.RepeatedField(proto.MESSAGE, number=2, message="DocChange",) + changes = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="DocChange", + ) - read_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + read_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) class DocChange(proto.Message): @@ -519,9 +680,17 @@ class Kind(proto.Enum): REMOVED = 2 MODIFIED = 3 - kind = proto.Field(proto.ENUM, number=1, enum=Kind,) + kind = proto.Field( + proto.ENUM, + number=1, + enum=Kind, + ) - doc = proto.Field(proto.MESSAGE, number=2, message=document.Document,) + doc = proto.Field( + proto.MESSAGE, + number=2, + message=document.Document, + ) old_index = proto.Field(proto.INT32, number=3) diff --git a/tests/unit/v1/test__helpers.py b/tests/unit/v1/test__helpers.py index 200f66d81e..95cb595716 100644 --- a/tests/unit/v1/test__helpers.py +++ b/tests/unit/v1/test__helpers.py @@ -213,7 +213,7 @@ def test_encode_value_w_datetime_wo_nanos(): def test_encode_value_w_string(): from google.cloud.firestore_v1._helpers import encode_value - value = u"\u2018left quote, right quote\u2019" + value = "\u2018left quote, right quote\u2019" result = encode_value(value) expected = _value_pb(string_value=value) assert result == expected @@ -312,11 +312,11 @@ def test_encode_dict_w_many_types(): "baz": 981, "quux": 2.875, "quuz": dt_val, - "corge": u"\N{snowman}", + "corge": "\N{snowman}", "grault": b"\xe2\x98\x83", "wibble": document, - "garply": [u"fork", 4.0], - "waldo": {"fred": u"zap", "thud": False}, + "garply": ["fork", 4.0], + "waldo": {"fred": "zap", "thud": False}, } encoded_dict = encode_dict(values_dict) expected_dict = { @@ -327,18 +327,18 @@ def test_encode_dict_w_many_types(): "quuz": _value_pb( timestamp_value=timestamp_pb2.Timestamp(seconds=dt_seconds, nanos=dt_nanos) ), - "corge": _value_pb(string_value=u"\N{snowman}"), + "corge": _value_pb(string_value="\N{snowman}"), "grault": _value_pb(bytes_value=b"\xe2\x98\x83"), "wibble": _value_pb(reference_value=document._document_path), "garply": _value_pb( array_value=ArrayValue( - values=[_value_pb(string_value=u"fork"), _value_pb(double_value=4.0)] + values=[_value_pb(string_value="fork"), _value_pb(double_value=4.0)] ) ), "waldo": _value_pb( map_value=MapValue( fields={ - "fred": _value_pb(string_value=u"zap"), + "fred": _value_pb(string_value="zap"), "thud": _value_pb(boolean_value=False), } ) @@ -510,7 +510,7 @@ def test_decode_value_w_datetime(): def test_decode_value_w_unicode(): from google.cloud.firestore_v1._helpers import decode_value - unicode_val = u"zorgon" + unicode_val = "zorgon" value = _value_pb(string_value=unicode_val) assert decode_value(value, mock.sentinel.client) == unicode_val @@ -528,7 +528,7 @@ def test_decode_value_w_reference(): from google.cloud.firestore_v1._helpers import decode_value client = _make_client() - path = (u"then", u"there-was-one") + path = ("then", "there-was-one") document = client.document(*path) ref_string = document._document_path value = _value_pb(reference_value=ref_string) @@ -571,7 +571,7 @@ def test_decode_value_w_map(): from google.cloud.firestore_v1._helpers import decode_value sub_value1 = _value_pb(integer_value=187680) - sub_value2 = _value_pb(string_value=u"how low can you go?") + sub_value2 = _value_pb(string_value="how low can you go?") map_pb = document.MapValue(fields={"first": sub_value1, "second": sub_value2}) value = _value_pb(map_value=map_pb) @@ -587,7 +587,7 @@ def test_decode_value_w_nested_map(): from google.cloud.firestore_v1._helpers import decode_value actual_value1 = 1009876 - actual_value2 = u"hey you guys" + actual_value2 = "hey you guys" actual_value3 = 90.875 map_pb1 = document.MapValue( fields={ @@ -663,17 +663,17 @@ def test_decode_dict_w_many_types(): "quuz": _value_pb( timestamp_value=timestamp_pb2.Timestamp(seconds=dt_seconds, nanos=dt_nanos) ), - "corge": _value_pb(string_value=u"\N{snowman}"), + "corge": _value_pb(string_value="\N{snowman}"), "grault": _value_pb(bytes_value=b"\xe2\x98\x83"), "garply": _value_pb( array_value=ArrayValue( - values=[_value_pb(string_value=u"fork"), _value_pb(double_value=4.0)] + values=[_value_pb(string_value="fork"), _value_pb(double_value=4.0)] ) ), "waldo": _value_pb( map_value=MapValue( fields={ - "fred": _value_pb(string_value=u"zap"), + "fred": _value_pb(string_value="zap"), "thud": _value_pb(boolean_value=False), } ) @@ -686,10 +686,10 @@ def test_decode_dict_w_many_types(): "baz": 981, "quux": 2.875, "quuz": dt_val, - "corge": u"\N{snowman}", + "corge": "\N{snowman}", "grault": b"\xe2\x98\x83", - "garply": [u"fork", 4.0], - "waldo": {"fred": u"zap", "thud": False}, + "garply": ["fork", 4.0], + "waldo": {"fred": "zap", "thud": False}, "a.b.c": False, } assert decode_dict(value_fields, mock.sentinel.client) == expected @@ -698,8 +698,8 @@ def test_decode_dict_w_many_types(): def _dummy_ref_string(collection_id): from google.cloud.firestore_v1.client import DEFAULT_DATABASE - project = u"bazzzz" - return u"projects/{}/databases/{}/documents/{}".format( + project = "bazzzz" + return "projects/{}/databases/{}/documents/{}".format( project, DEFAULT_DATABASE, collection_id ) @@ -1659,7 +1659,7 @@ def __pbs_for_create_helper(do_transform=False, empty_val=False): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_create - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {"cheese": 1.5, "crackers": True} if do_transform: @@ -1723,7 +1723,7 @@ def _add_field_transforms_for_set_no_merge(update_pb, fields): def test__pbs_for_set_w_empty_document(): from google.cloud.firestore_v1._helpers import pbs_for_set_no_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {} write_pbs = pbs_for_set_no_merge(document_path, document_data) @@ -1737,7 +1737,7 @@ def test__pbs_for_set_w_only_server_timestamp(): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_no_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {"butter": SERVER_TIMESTAMP} write_pbs = pbs_for_set_no_merge(document_path, document_data) @@ -1752,7 +1752,7 @@ def _pbs_for_set_no_merge_helper(do_transform=False, empty_val=False): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_no_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {"cheese": 1.5, "crackers": True} if do_transform: @@ -2023,7 +2023,7 @@ def _update_document_mask(update_pb, field_paths): def test__pbs_for_set_with_merge_w_merge_true_wo_transform(): from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {"cheese": 1.5, "crackers": True} write_pbs = pbs_for_set_with_merge(document_path, document_data, merge=True) @@ -2037,7 +2037,7 @@ def test__pbs_for_set_with_merge_w_merge_true_wo_transform(): def test__pbs_for_set_with_merge_w_merge_field_wo_transform(): from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {"cheese": 1.5, "crackers": True} write_pbs = pbs_for_set_with_merge(document_path, document_data, merge=["cheese"]) @@ -2054,7 +2054,7 @@ def test__pbs_for_set_with_merge_w_merge_true_w_only_transform(): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") document_data = {"butter": SERVER_TIMESTAMP} write_pbs = pbs_for_set_with_merge(document_path, document_data, merge=True) @@ -2070,7 +2070,7 @@ def test__pbs_for_set_with_merge_w_merge_true_w_transform(): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") update_data = {"cheese": 1.5, "crackers": True} document_data = update_data.copy() document_data["butter"] = SERVER_TIMESTAMP @@ -2088,7 +2088,7 @@ def test__pbs_for_set_with_merge_w_merge_field_w_transform(): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") update_data = {"cheese": 1.5, "crackers": True} document_data = update_data.copy() document_data["butter"] = SERVER_TIMESTAMP @@ -2110,7 +2110,7 @@ def test__pbs_for_set_with_merge_w_merge_field_w_transform_masking_simple(): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") update_data = {"cheese": 1.5, "crackers": True} document_data = update_data.copy() document_data["butter"] = {"pecan": SERVER_TIMESTAMP} @@ -2130,7 +2130,7 @@ def test__pbs_for_set_with_merge_w_merge_field_w_transform_parent(): from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP from google.cloud.firestore_v1._helpers import pbs_for_set_with_merge - document_path = _make_ref_string(u"little", u"town", u"of", u"ham") + document_path = _make_ref_string("little", "town", "of", "ham") update_data = {"cheese": 1.5, "crackers": True} document_data = update_data.copy() document_data["butter"] = {"popcorn": "yum", "pecan": SERVER_TIMESTAMP} @@ -2221,7 +2221,7 @@ def _pbs_for_update_helper(option=None, do_transform=False, **write_kwargs): from google.cloud.firestore_v1.types import write from google.cloud.firestore_v1._helpers import pbs_for_update - document_path = _make_ref_string(u"toy", u"car", u"onion", u"garlic") + document_path = _make_ref_string("toy", "car", "onion", "garlic") field_path1 = "bitez.yum" value = b"\x00\x01" field_path2 = "blog.internet" @@ -2286,7 +2286,7 @@ def _pb_for_delete_helper(option=None, **write_kwargs): from google.cloud.firestore_v1.types import write from google.cloud.firestore_v1._helpers import pb_for_delete - document_path = _make_ref_string(u"chicken", u"philly", u"one", u"two") + document_path = _make_ref_string("chicken", "philly", "one", "two") write_pb = pb_for_delete(document_path, option) expected_pb = write.Write(delete=document_path, **write_kwargs) @@ -2366,7 +2366,7 @@ def test_get_transaction_id_w_good_transaction(): def test_metadata_with_prefix(): from google.cloud.firestore_v1._helpers import metadata_with_prefix - database_string = u"projects/prahj/databases/dee-bee" + database_string = "projects/prahj/databases/dee-bee" metadata = metadata_with_prefix(database_string) assert metadata == [("google-cloud-resource-prefix", database_string)] @@ -2559,7 +2559,7 @@ def _make_ref_string(project, database, *path): from google.cloud.firestore_v1 import _helpers doc_rel_path = _helpers.DOCUMENT_PATH_DELIMITER.join(path) - return u"projects/{}/databases/{}/documents/{}".format( + return "projects/{}/databases/{}/documents/{}".format( project, database, doc_rel_path ) diff --git a/tests/unit/v1/test_async_batch.py b/tests/unit/v1/test_async_batch.py index 6bed2351b3..f44d0caa75 100644 --- a/tests/unit/v1/test_async_batch.py +++ b/tests/unit/v1/test_async_batch.py @@ -42,7 +42,8 @@ async def _commit_helper(retry=None, timeout=None): firestore_api = AsyncMock(spec=["commit"]) timestamp = timestamp_pb2.Timestamp(seconds=1234567, nanos=123456798) commit_response = firestore.CommitResponse( - write_results=[write.WriteResult(), write.WriteResult()], commit_time=timestamp, + write_results=[write.WriteResult(), write.WriteResult()], + commit_time=timestamp, ) firestore_api.commit.return_value = commit_response kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout) @@ -103,7 +104,8 @@ async def test_as_context_mgr_wo_error(): firestore_api = AsyncMock(spec=["commit"]) timestamp = timestamp_pb2.Timestamp(seconds=1234567, nanos=123456798) commit_response = firestore.CommitResponse( - write_results=[write.WriteResult(), write.WriteResult()], commit_time=timestamp, + write_results=[write.WriteResult(), write.WriteResult()], + commit_time=timestamp, ) firestore_api.commit.return_value = commit_response client = _make_client() diff --git a/tests/unit/v1/test_async_client.py b/tests/unit/v1/test_async_client.py index 3af0ef6d38..69785f5b82 100644 --- a/tests/unit/v1/test_async_client.py +++ b/tests/unit/v1/test_async_client.py @@ -218,7 +218,9 @@ async def __aiter__(self, **_): base_path = client._database_string + "/documents" firestore_api.list_collection_ids.assert_called_once_with( - request={"parent": base_path}, metadata=client._rpc_metadata, **kwargs, + request={"parent": base_path}, + metadata=client._rpc_metadata, + **kwargs, ) @@ -286,7 +288,11 @@ async def _get_all_helper(num_snapshots=2, txn_id=None, retry=None, timeout=None kwargs["transaction"] = transaction snapshots = await _invoke_get_all( - client, documents, responses, field_paths=field_paths, **kwargs, + client, + documents, + responses, + field_paths=field_paths, + **kwargs, ) assert len(snapshots) == num_snapshots diff --git a/tests/unit/v1/test_async_collection.py b/tests/unit/v1/test_async_collection.py index 69a33d1122..4a9e480a92 100644 --- a/tests/unit/v1/test_async_collection.py +++ b/tests/unit/v1/test_async_collection.py @@ -171,7 +171,9 @@ async def _add_helper(retry=None, timeout=None): kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout) update_time, document_ref = await collection.add( - document_data, document_id=doc_id, **kwargs, + document_data, + document_id=doc_id, + **kwargs, ) # Verify the response and the mocks. @@ -223,7 +225,9 @@ async def test_asynccollectionreference_chunkify(): f"documents/my-collection/{index}" ) results.append( - firestore.RunQueryResponse(document=document.Document(name=name),), + firestore.RunQueryResponse( + document=document.Document(name=name), + ), ) chunks = [ @@ -280,7 +284,11 @@ async def _next_page(self): if page_size is not None: documents = [ - i async for i in collection.list_documents(page_size=page_size, **kwargs,) + i + async for i in collection.list_documents( + page_size=page_size, + **kwargs, + ) ] else: documents = [i async for i in collection.list_documents(**kwargs)] @@ -353,7 +361,9 @@ async def test_asynccollectionreference_get_w_retry_timeout(query_class): assert get_response is query_instance.get.return_value query_instance.get.assert_called_once_with( - transaction=None, retry=retry, timeout=timeout, + transaction=None, + retry=retry, + timeout=timeout, ) @@ -405,7 +415,9 @@ async def test_asynccollectionreference_stream_w_retry_timeout(query_class): query_class.assert_called_once_with(collection) query_instance = query_class.return_value query_instance.stream.assert_called_once_with( - transaction=None, retry=retry, timeout=timeout, + transaction=None, + retry=retry, + timeout=timeout, ) diff --git a/tests/unit/v1/test_async_document.py b/tests/unit/v1/test_async_document.py index 7d8558fe8d..82f52d0f34 100644 --- a/tests/unit/v1/test_async_document.py +++ b/tests/unit/v1/test_async_document.py @@ -447,7 +447,9 @@ def WhichOneof(val): kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout) snapshot = await document_reference.get( - field_paths=field_paths, transaction=transaction, **kwargs, + field_paths=field_paths, + transaction=transaction, + **kwargs, ) assert snapshot.reference is document_reference diff --git a/tests/unit/v1/test_async_query.py b/tests/unit/v1/test_async_query.py index c7f01608da..4b7b83cede 100644 --- a/tests/unit/v1/test_async_query.py +++ b/tests/unit/v1/test_async_query.py @@ -189,15 +189,21 @@ async def test_asyncquery_chunkify_w_chunksize_lt_limit(): for index in range(5) ] responses1 = [ - firestore.RunQueryResponse(document=document.Document(name=doc_id),) + firestore.RunQueryResponse( + document=document.Document(name=doc_id), + ) for doc_id in doc_ids[:2] ] responses2 = [ - firestore.RunQueryResponse(document=document.Document(name=doc_id),) + firestore.RunQueryResponse( + document=document.Document(name=doc_id), + ) for doc_id in doc_ids[2:4] ] responses3 = [ - firestore.RunQueryResponse(document=document.Document(name=doc_id),) + firestore.RunQueryResponse( + document=document.Document(name=doc_id), + ) for doc_id in doc_ids[4:] ] firestore_api.run_query.side_effect = [ @@ -626,7 +632,8 @@ async def _get_partitions_helper(retry=None, timeout=None): # Verify the mock call. parent_path, _ = parent._parent_info() partition_query = _make_async_collection_group( - parent, orders=(query._make_order("__name__", query.ASCENDING),), + parent, + orders=(query._make_order("__name__", query.ASCENDING),), ) firestore_api.partition_query.assert_called_once_with( request={ diff --git a/tests/unit/v1/test_async_transaction.py b/tests/unit/v1/test_async_transaction.py index 81c7bdc08a..12f704a6ec 100644 --- a/tests/unit/v1/test_async_transaction.py +++ b/tests/unit/v1/test_async_transaction.py @@ -295,7 +295,9 @@ async def _get_all_helper(retry=None, timeout=None): result = await transaction.get_all([ref1, ref2], **kwargs) client.get_all.assert_called_once_with( - [ref1, ref2], transaction=transaction, **kwargs, + [ref1, ref2], + transaction=transaction, + **kwargs, ) assert result is client.get_all.return_value @@ -353,10 +355,14 @@ async def _get_w_query_helper(retry=None, timeout=None): query.stream = AsyncMock() kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout) - result = await transaction.get(query, **kwargs,) + result = await transaction.get( + query, + **kwargs, + ) query.stream.assert_called_once_with( - transaction=transaction, **kwargs, + transaction=transaction, + **kwargs, ) assert result is query.stream.return_value diff --git a/tests/unit/v1/test_base_batch.py b/tests/unit/v1/test_base_batch.py index d47912055b..eedb6625a3 100644 --- a/tests/unit/v1/test_base_batch.py +++ b/tests/unit/v1/test_base_batch.py @@ -82,7 +82,7 @@ def test_basewritebatch_set(): reference = client.document("another", "one") field = "zapzap" - value = u"meadows and flowers" + value = "meadows and flowers" document_data = {field: value} ret_val = batch.set(reference, document_data) assert ret_val is None @@ -105,7 +105,7 @@ def test_basewritebatch_set_merge(): reference = client.document("another", "one") field = "zapzap" - value = u"meadows and flowers" + value = "meadows and flowers" document_data = {field: value} ret_val = batch.set(reference, document_data, merge=True) assert ret_val is None @@ -130,7 +130,7 @@ def test_basewritebatch_update(): reference = client.document("cats", "cradle") field_path = "head.foot" - value = u"knees toes shoulders" + value = "knees toes shoulders" field_updates = {field_path: value} ret_val = batch.update(reference, field_updates) @@ -139,7 +139,8 @@ def test_basewritebatch_update(): map_pb = document.MapValue(fields={"foot": _value_pb(string_value=value)}) new_write_pb = write.Write( update=document.Document( - name=reference._document_path, fields={"head": _value_pb(map_value=map_pb)}, + name=reference._document_path, + fields={"head": _value_pb(map_value=map_pb)}, ), update_mask=common.DocumentMask(field_paths=[field_path]), current_document=common.Precondition(exists=True), diff --git a/tests/unit/v1/test_base_client.py b/tests/unit/v1/test_base_client.py index 42f9b25ca4..dfc235641d 100644 --- a/tests/unit/v1/test_base_client.py +++ b/tests/unit/v1/test_base_client.py @@ -109,7 +109,8 @@ def test_baseclient__firestore_api_helper_wo_emulator(): target, credentials=client._credentials, options=channel_options.items() ) transport_class.assert_called_once_with( - host=target, channel=transport_class.create_channel.return_value, + host=target, + channel=transport_class.create_channel.return_value, ) client_class.assert_called_once_with( transport=transport_class.return_value, client_options=client_options @@ -138,7 +139,8 @@ def test_baseclient__firestore_api_helper_w_emulator(): emulator_channel.assert_called_once_with(transport_class) transport_class.assert_called_once_with( - host=target, channel=emulator_channel.return_value, + host=target, + channel=emulator_channel.return_value, ) client_class.assert_called_once_with( transport=transport_class.return_value, client_options=client_options @@ -252,7 +254,9 @@ def test_baseclient__target_helper_w_client_options_w_endpoint(): endpoint = "https://api.example.com/firestore" client_options = {"api_endpoint": endpoint} client = _make_base_client( - project=PROJECT, credentials=credentials, client_options=client_options, + project=PROJECT, + credentials=credentials, + client_options=client_options, ) assert client._target_helper(None) == endpoint @@ -264,7 +268,9 @@ def test_baseclient__target_helper_w_client_options_wo_endpoint(): client_options = {} client_class = mock.Mock(instance=False, DEFAULT_ENDPOINT=endpoint) client = _make_base_client( - project=PROJECT, credentials=credentials, client_options=client_options, + project=PROJECT, + credentials=credentials, + client_options=client_options, ) assert client._target_helper(client_class) == endpoint @@ -274,7 +280,10 @@ def test_baseclient__target_helper_wo_client_options(): credentials = _make_credentials() endpoint = "https://api.example.com/firestore" client_class = mock.Mock(instance=False, DEFAULT_ENDPOINT=endpoint) - client = _make_base_client(project=PROJECT, credentials=credentials,) + client = _make_base_client( + project=PROJECT, + credentials=credentials, + ) assert client._target_helper(client_class) == endpoint @@ -381,10 +390,10 @@ def test__get_reference_failure(): def _dummy_ref_string(): from google.cloud.firestore_v1.base_client import DEFAULT_DATABASE - project = u"bazzzz" - collection_id = u"fizz" - document_id = u"buzz" - return u"projects/{}/databases/{}/documents/{}/{}".format( + project = "bazzzz" + collection_id = "fizz" + document_id = "buzz" + return "projects/{}/databases/{}/documents/{}/{}".format( project, DEFAULT_DATABASE, collection_id, document_id ) @@ -406,7 +415,7 @@ def test__parse_batch_get_found(): name=ref_string, fields={ "foo": document.Value(double_value=1.5), - "bar": document.Value(string_value=u"skillz"), + "bar": document.Value(string_value="skillz"), }, create_time=create_time, update_time=update_time, @@ -417,7 +426,7 @@ def test__parse_batch_get_found(): snapshot = _parse_batch_get(response_pb, reference_map, mock.sentinel.client) assert isinstance(snapshot, DocumentSnapshot) assert snapshot._reference is mock.sentinel.reference - assert snapshot._data == {"foo": 1.5, "bar": u"skillz"} + assert snapshot._data == {"foo": 1.5, "bar": "skillz"} assert snapshot._exists assert snapshot.read_time.timestamp_pb() == read_time assert snapshot.create_time.timestamp_pb() == create_time diff --git a/tests/unit/v1/test_base_query.py b/tests/unit/v1/test_base_query.py index 8312df5ba9..790f170235 100644 --- a/tests/unit/v1/test_base_query.py +++ b/tests/unit/v1/test_base_query.py @@ -25,7 +25,11 @@ def _make_base_query(*args, **kwargs): def _make_base_query_all_fields( - limit=9876, offset=12, skip_fields=(), parent=None, all_descendants=True, + limit=9876, + offset=12, + skip_fields=(), + parent=None, + all_descendants=True, ): kwargs = { "projection": mock.sentinel.projection, @@ -1045,7 +1049,7 @@ def test_basequery__to_protobuf_where_only(): parent = mock.Mock(id="dog", spec=["id"]) query1 = _make_base_query(parent) - query2 = query1.where("a", "==", u"b") + query2 = query1.where("a", "==", "b") structured_query_pb = query2._to_protobuf() query_kwargs = { @@ -1054,7 +1058,7 @@ def test_basequery__to_protobuf_where_only(): field_filter=query.StructuredQuery.FieldFilter( field=query.StructuredQuery.FieldReference(field_path="a"), op=StructuredQuery.FieldFilter.Operator.EQUAL, - value=document.Value(string_value=u"b"), + value=document.Value(string_value="b"), ) ), } @@ -1088,15 +1092,13 @@ def test_basequery__to_protobuf_start_at_only(): from google.cloud.firestore_v1.types import query parent = mock.Mock(id="phish", spec=["id"]) - query_inst = ( - _make_base_query(parent).order_by("X.Y").start_after({"X": {"Y": u"Z"}}) - ) + query_inst = _make_base_query(parent).order_by("X.Y").start_after({"X": {"Y": "Z"}}) structured_query_pb = query_inst._to_protobuf() query_kwargs = { "from_": [StructuredQuery.CollectionSelector(collection_id=parent.id)], "order_by": [_make_order_pb("X.Y", StructuredQuery.Direction.ASCENDING)], - "start_at": query.Cursor(values=[document.Value(string_value=u"Z")]), + "start_at": query.Cursor(values=[document.Value(string_value="Z")]), } expected_pb = StructuredQuery(**query_kwargs) assert structured_query_pb == expected_pb diff --git a/tests/unit/v1/test_batch.py b/tests/unit/v1/test_batch.py index e69fa558fc..ba641751c4 100644 --- a/tests/unit/v1/test_batch.py +++ b/tests/unit/v1/test_batch.py @@ -40,7 +40,8 @@ def _commit_helper(retry=None, timeout=None): firestore_api = mock.Mock(spec=["commit"]) timestamp = timestamp_pb2.Timestamp(seconds=1234567, nanos=123456798) commit_response = firestore.CommitResponse( - write_results=[write.WriteResult(), write.WriteResult()], commit_time=timestamp, + write_results=[write.WriteResult(), write.WriteResult()], + commit_time=timestamp, ) firestore_api.commit.return_value = commit_response kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout) @@ -98,7 +99,8 @@ def test_writebatch_as_context_mgr_wo_error(): firestore_api = mock.Mock(spec=["commit"]) timestamp = timestamp_pb2.Timestamp(seconds=1234567, nanos=123456798) commit_response = firestore.CommitResponse( - write_results=[write.WriteResult(), write.WriteResult()], commit_time=timestamp, + write_results=[write.WriteResult(), write.WriteResult()], + commit_time=timestamp, ) firestore_api.commit.return_value = commit_response client = _make_client() diff --git a/tests/unit/v1/test_bulk_writer.py b/tests/unit/v1/test_bulk_writer.py index dc185d387e..ce62250e88 100644 --- a/tests/unit/v1/test_bulk_writer.py +++ b/tests/unit/v1/test_bulk_writer.py @@ -179,7 +179,19 @@ def test_basebulkwriter_create_calls_send_correctly(self): bw.flush() # Full batches with 20 items should have been sent 5 times, and a 1-item # batch should have been sent once. - self._verify_bw_activity(bw, [(20, 5,), (1, 1,)]) + self._verify_bw_activity( + bw, + [ + ( + 20, + 5, + ), + ( + 1, + 1, + ), + ], + ) def test_basebulkwriter_delete_calls_send_correctly(self): client = self._make_client() @@ -189,7 +201,19 @@ def test_basebulkwriter_delete_calls_send_correctly(self): bw.flush() # Full batches with 20 items should have been sent 5 times, and a 1-item # batch should have been sent once. - self._verify_bw_activity(bw, [(20, 5,), (1, 1,)]) + self._verify_bw_activity( + bw, + [ + ( + 20, + 5, + ), + ( + 1, + 1, + ), + ], + ) def test_basebulkwriter_delete_separates_batch(self): client = self._make_client() @@ -199,7 +223,15 @@ def test_basebulkwriter_delete_separates_batch(self): bw.delete(ref) bw.flush() # Consecutive batches each with 1 operation should have been sent - self._verify_bw_activity(bw, [(1, 2,)]) + self._verify_bw_activity( + bw, + [ + ( + 1, + 2, + ) + ], + ) def test_basebulkwriter_set_calls_send_correctly(self): client = self._make_client() @@ -209,7 +241,19 @@ def test_basebulkwriter_set_calls_send_correctly(self): bw.flush() # Full batches with 20 items should have been sent 5 times, and a 1-item # batch should have been sent once. - self._verify_bw_activity(bw, [(20, 5,), (1, 1,)]) + self._verify_bw_activity( + bw, + [ + ( + 20, + 5, + ), + ( + 1, + 1, + ), + ], + ) def test_basebulkwriter_update_calls_send_correctly(self): client = self._make_client() @@ -219,7 +263,19 @@ def test_basebulkwriter_update_calls_send_correctly(self): bw.flush() # Full batches with 20 items should have been sent 5 times, and a 1-item # batch should have been sent once. - self._verify_bw_activity(bw, [(20, 5,), (1, 1,)]) + self._verify_bw_activity( + bw, + [ + ( + 20, + 5, + ), + ( + 1, + 1, + ), + ], + ) def test_basebulkwriter_update_separates_batch(self): client = self._make_client() @@ -230,7 +286,15 @@ def test_basebulkwriter_update_separates_batch(self): bw.flush() # Full batches with 20 items should have been sent 5 times, and a 1-item # batch should have been sent once. - self._verify_bw_activity(bw, [(1, 2,)]) + self._verify_bw_activity( + bw, + [ + ( + 1, + 2, + ) + ], + ) def test_basebulkwriter_invokes_success_callbacks_successfully(self): from google.cloud.firestore_v1.base_document import BaseDocumentReference @@ -314,7 +378,8 @@ def test_basebulkwriter_invokes_error_callbacks_successfully_multiple_retries(se client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) # First document in each batch will "fail" bw._fail_indices = [0] @@ -356,7 +421,8 @@ def test_basebulkwriter_default_error_handler(self): client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) bw._attempts = 0 @@ -380,7 +446,8 @@ def test_basebulkwriter_handles_errors_and_successes_correctly(self): client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) # First document in each batch will "fail" bw._fail_indices = [0] @@ -424,7 +491,8 @@ def test_basebulkwriter_create_retriable(self): client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) # First document in each batch will "fail" bw._fail_indices = [0] @@ -454,7 +522,8 @@ def test_basebulkwriter_delete_retriable(self): client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) # First document in each batch will "fail" bw._fail_indices = [0] @@ -484,7 +553,8 @@ def test_basebulkwriter_set_retriable(self): client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) # First document in each batch will "fail" bw._fail_indices = [0] @@ -514,7 +584,8 @@ def test_basebulkwriter_update_retriable(self): client = self._make_client() bw = _make_no_send_bulk_writer( - client, options=BulkWriterOptions(retry=BulkRetry.immediate), + client, + options=BulkWriterOptions(retry=BulkRetry.immediate), ) # First document in each batch will "fail" bw._fail_indices = [0] @@ -550,7 +621,19 @@ def test_basebulkwriter_serial_calls_send_correctly(self): bw.flush() # Full batches with 20 items should have been sent 5 times, and a 1-item # batch should have been sent once. - self._verify_bw_activity(bw, [(20, 5,), (1, 1,)]) + self._verify_bw_activity( + bw, + [ + ( + 20, + 5, + ), + ( + 1, + 1, + ), + ], + ) def test_basebulkwriter_separates_same_document(self): client = self._make_client() @@ -560,7 +643,15 @@ def test_basebulkwriter_separates_same_document(self): bw.flush() # Seeing the same document twice should lead to separate batches # Expect to have sent 1-item batches twice. - self._verify_bw_activity(bw, [(1, 2,)]) + self._verify_bw_activity( + bw, + [ + ( + 1, + 2, + ) + ], + ) def test_basebulkwriter_separates_same_document_different_operation(self): client = self._make_client() @@ -571,7 +662,15 @@ def test_basebulkwriter_separates_same_document_different_operation(self): bw.flush() # Seeing the same document twice should lead to separate batches. # Expect to have sent 1-item batches twice. - self._verify_bw_activity(bw, [(1, 2,)]) + self._verify_bw_activity( + bw, + [ + ( + 1, + 2, + ) + ], + ) def test_basebulkwriter_ensure_sending_repeatedly_callable(self): client = self._make_client() @@ -591,7 +690,15 @@ def test_basebulkwriter_flush_sends_in_progress(self): bw = _make_no_send_bulk_writer(client) bw.create(_get_document_reference(client), {"whatever": "you want"}) bw.flush() - self._verify_bw_activity(bw, [(1, 1,)]) + self._verify_bw_activity( + bw, + [ + ( + 1, + 1, + ) + ], + ) def test_basebulkwriter_flush_sends_all_queued_batches(self): client = self._make_client() @@ -601,7 +708,15 @@ def test_basebulkwriter_flush_sends_all_queued_batches(self): bw._queued_batches.append(bw._operations) bw._reset_operations() bw.flush() - self._verify_bw_activity(bw, [(1, 2,)]) + self._verify_bw_activity( + bw, + [ + ( + 1, + 2, + ) + ], + ) def test_basebulkwriter_cannot_add_after_close(self): client = self._make_client() diff --git a/tests/unit/v1/test_bundle.py b/tests/unit/v1/test_bundle.py index 99803683be..6b480f84c8 100644 --- a/tests/unit/v1/test_bundle.py +++ b/tests/unit/v1/test_bundle.py @@ -99,7 +99,8 @@ def _bundled_query_helper( data: typing.Optional[typing.List[typing.Dict]] = None, ) -> base_query.BaseQuery: return self._bundled_collection_helper( - document_ids=document_ids, data=data, + document_ids=document_ids, + data=data, )._query() @@ -453,7 +454,9 @@ def test_roundtrip_binary_data(self): from google.cloud.firestore_bundle import FirestoreBundle from google.cloud.firestore_v1 import _helpers - query = self._bundled_query_helper(data=[{"binary_data": b"\x0f"}],) + query = self._bundled_query_helper( + data=[{"binary_data": b"\x0f"}], + ) bundle = FirestoreBundle("test") bundle.add_named_query("asdf", query) serialized = bundle.build() diff --git a/tests/unit/v1/test_client.py b/tests/unit/v1/test_client.py index 67425d4413..563419b30d 100644 --- a/tests/unit/v1/test_client.py +++ b/tests/unit/v1/test_client.py @@ -240,7 +240,9 @@ def __iter__(self): base_path = client._database_string + "/documents" firestore_api.list_collection_ids.assert_called_once_with( - request={"parent": base_path}, metadata=client._rpc_metadata, **kwargs, + request={"parent": base_path}, + metadata=client._rpc_metadata, + **kwargs, ) @@ -306,7 +308,11 @@ def _get_all_helper(num_snapshots=2, txn_id=None, retry=None, timeout=None): kwargs["transaction"] = transaction snapshots = _invoke_get_all( - client, documents, responses, field_paths=field_paths, **kwargs, + client, + documents, + responses, + field_paths=field_paths, + **kwargs, ) assert len(snapshots) == num_snapshots diff --git a/tests/unit/v1/test_collection.py b/tests/unit/v1/test_collection.py index 9bba2fd5b0..36492722e0 100644 --- a/tests/unit/v1/test_collection.py +++ b/tests/unit/v1/test_collection.py @@ -296,7 +296,9 @@ def test_get_w_retry_timeout(query_class): assert get_response is query_instance.get.return_value query_instance.get.assert_called_once_with( - transaction=None, retry=retry, timeout=timeout, + transaction=None, + retry=retry, + timeout=timeout, ) @@ -338,7 +340,9 @@ def test_stream_w_retry_timeout(query_class): query_instance = query_class.return_value assert stream_response is query_instance.stream.return_value query_instance.stream.assert_called_once_with( - transaction=None, retry=retry, timeout=timeout, + transaction=None, + retry=retry, + timeout=timeout, ) diff --git a/tests/unit/v1/test_cross_language.py b/tests/unit/v1/test_cross_language.py index 64cfacfb58..e9663b5442 100644 --- a/tests/unit/v1/test_cross_language.py +++ b/tests/unit/v1/test_cross_language.py @@ -118,7 +118,8 @@ def _run_testcase(testcase, call, firestore_api, client): } firestore_api.commit.assert_called_once_with( - request=expected_request, metadata=client._rpc_metadata, + request=expected_request, + metadata=client._rpc_metadata, ) @@ -157,7 +158,8 @@ def test_get_testprotos(test_proto): } firestore_api.batch_get_documents.assert_called_once_with( - request=expected_request, metadata=client._rpc_metadata, + request=expected_request, + metadata=client._rpc_metadata, ) diff --git a/tests/unit/v1/test_order.py b/tests/unit/v1/test_order.py index da37adcf7f..1287e77a08 100644 --- a/tests/unit/v1/test_order.py +++ b/tests/unit/v1/test_order.py @@ -27,9 +27,9 @@ def test_order_compare_across_heterogenous_values(): from google.cloud.firestore_v1.order import Order # Constants used to represent min/max values of storage types. - int_max_value = 2 ** 31 - 1 - int_min_value = -(2 ** 31) - float_min_value = 1.175494351 ** -38 + int_max_value = 2**31 - 1 + int_min_value = -(2**31) + float_min_value = 1.175494351**-38 float_nan = float("nan") inf = float("inf") diff --git a/tests/unit/v1/test_query.py b/tests/unit/v1/test_query.py index 17b82d3ede..f82036c4be 100644 --- a/tests/unit/v1/test_query.py +++ b/tests/unit/v1/test_query.py @@ -177,13 +177,22 @@ def test_query_chunkify_w_chunksize_lt_limit(): for index in range(5) ] responses1 = [ - RunQueryResponse(document=Document(name=doc_id),) for doc_id in doc_ids[:2] + RunQueryResponse( + document=Document(name=doc_id), + ) + for doc_id in doc_ids[:2] ] responses2 = [ - RunQueryResponse(document=Document(name=doc_id),) for doc_id in doc_ids[2:4] + RunQueryResponse( + document=Document(name=doc_id), + ) + for doc_id in doc_ids[2:4] ] responses3 = [ - RunQueryResponse(document=Document(name=doc_id),) for doc_id in doc_ids[4:] + RunQueryResponse( + document=Document(name=doc_id), + ) + for doc_id in doc_ids[4:] ] firestore_api.run_query.side_effect = [ iter(responses1), @@ -213,7 +222,10 @@ def test_query_chunkify_w_chunksize_gt_limit(): for index in range(5) ] responses = [ - RunQueryResponse(document=Document(name=doc_id),) for doc_id in doc_ids + RunQueryResponse( + document=Document(name=doc_id), + ) + for doc_id in doc_ids ] firestore_api.run_query.return_value = iter(responses) client._firestore_api_internal = firestore_api @@ -539,7 +551,10 @@ def test_query_stream_w_collection_group(): def _query_stream_w_retriable_exc_helper( - retry=_not_passed, timeout=None, transaction=None, expect_retry=True, + retry=_not_passed, + timeout=None, + transaction=None, + expect_retry=True, ): from google.api_core import exceptions from google.api_core import gapic_v1 @@ -718,7 +733,8 @@ def _collection_group_get_partitions_helper(retry=None, timeout=None): # Verify the mock call. parent_path, _ = parent._parent_info() partition_query = _make_collection_group( - parent, orders=(query._make_order("__name__", query.ASCENDING),), + parent, + orders=(query._make_order("__name__", query.ASCENDING),), ) firestore_api.partition_query.assert_called_once_with( request={ diff --git a/tests/unit/v1/test_rate_limiter.py b/tests/unit/v1/test_rate_limiter.py index e5068b3590..d27b7ee810 100644 --- a/tests/unit/v1/test_rate_limiter.py +++ b/tests/unit/v1/test_rate_limiter.py @@ -23,7 +23,10 @@ def now_plus_n(seconds: int = 0, microseconds: int = 0) -> datetime.timedelta: - return fake_now + datetime.timedelta(seconds=seconds, microseconds=microseconds,) + return fake_now + datetime.timedelta( + seconds=seconds, + microseconds=microseconds, + ) @mock.patch("google.cloud.firestore_v1.rate_limiter.utcnow") @@ -73,7 +76,8 @@ def test_rate_limiter_phase_length(mocked_now): assert ramp.take_tokens() == 0 # Advance the clock 1 phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length, microseconds=1, + seconds=rate_limiter.default_phase_length, + microseconds=1, ) for _ in range(round(rate_limiter.default_initial_tokens * 3 / 2)): assert ramp.take_tokens() @@ -94,7 +98,8 @@ def test_rate_limiter_idle_phase_length(mocked_now): assert ramp.take_tokens() == 0 # Advance the clock 1 phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length, microseconds=1, + seconds=rate_limiter.default_phase_length, + microseconds=1, ) for _ in range(round(rate_limiter.default_initial_tokens)): assert ramp.take_tokens() == 1 @@ -116,7 +121,8 @@ def test_take_batch_size(mocked_now): assert ramp.take_tokens(page_size, allow_less=True) == 15 # Advance the clock 1 phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length, microseconds=1, + seconds=rate_limiter.default_phase_length, + microseconds=1, ) ramp._check_phase() assert ramp._maximum_tokens == 750 @@ -140,7 +146,8 @@ def test_phase_progress(mocked_now): # Advance the clock 1 phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length, microseconds=1, + seconds=rate_limiter.default_phase_length, + microseconds=1, ) ramp.take_tokens() assert ramp._phase == 1 @@ -148,7 +155,8 @@ def test_phase_progress(mocked_now): # Advance the clock another phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length * 2, microseconds=1, + seconds=rate_limiter.default_phase_length * 2, + microseconds=1, ) ramp.take_tokens() assert ramp._phase == 2 @@ -156,7 +164,8 @@ def test_phase_progress(mocked_now): # Advance the clock another ms and the phase should not advance mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length * 2, microseconds=2, + seconds=rate_limiter.default_phase_length * 2, + microseconds=2, ) ramp.take_tokens() assert ramp._phase == 2 @@ -169,14 +178,17 @@ def test_global_max_tokens(mocked_now): mocked_now.return_value = fake_now - ramp = rate_limiter.RateLimiter(global_max_tokens=499,) + ramp = rate_limiter.RateLimiter( + global_max_tokens=499, + ) assert ramp._phase == 0 assert ramp._maximum_tokens == 499 ramp.take_tokens() # Advance the clock 1 phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length, microseconds=1, + seconds=rate_limiter.default_phase_length, + microseconds=1, ) ramp.take_tokens() assert ramp._phase == 1 @@ -184,7 +196,8 @@ def test_global_max_tokens(mocked_now): # Advance the clock another phase mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length * 2, microseconds=1, + seconds=rate_limiter.default_phase_length * 2, + microseconds=1, ) ramp.take_tokens() assert ramp._phase == 2 @@ -192,7 +205,8 @@ def test_global_max_tokens(mocked_now): # Advance the clock another ms and the phase should not advance mocked_now.return_value = now_plus_n( - seconds=rate_limiter.default_phase_length * 2, microseconds=2, + seconds=rate_limiter.default_phase_length * 2, + microseconds=2, ) ramp.take_tokens() assert ramp._phase == 2 diff --git a/tests/unit/v1/test_transaction.py b/tests/unit/v1/test_transaction.py index baad17c9e3..84f78b5532 100644 --- a/tests/unit/v1/test_transaction.py +++ b/tests/unit/v1/test_transaction.py @@ -300,7 +300,9 @@ def _transaction_get_all_helper(retry=None, timeout=None): result = transaction.get_all([ref1, ref2], **kwargs) client.get_all.assert_called_once_with( - [ref1, ref2], transaction=transaction, **kwargs, + [ref1, ref2], + transaction=transaction, + **kwargs, ) assert result is client.get_all.return_value diff --git a/tests/unit/v1/test_transforms.py b/tests/unit/v1/test_transforms.py index f5768bac4e..218650bb51 100644 --- a/tests/unit/v1/test_transforms.py +++ b/tests/unit/v1/test_transforms.py @@ -22,7 +22,7 @@ def _make_value_list(*args, **kwargs): def test__valuelist_ctor_w_non_list_non_tuple(): - invalid_values = (None, u"phred", b"DEADBEEF", 123, {}, object()) + invalid_values = (None, "phred", b"DEADBEEF", 123, {}, object()) for invalid_value in invalid_values: with pytest.raises(ValueError): _make_value_list(invalid_value) @@ -74,7 +74,8 @@ def _make_numeric_value(*args, **kwargs): @pytest.mark.parametrize( - "invalid_value", [(None, u"phred", b"DEADBEEF", [], {}, object())], + "invalid_value", + [(None, "phred", b"DEADBEEF", [], {}, object())], ) def test__numericvalue_ctor_w_invalid_types(invalid_value): with pytest.raises(ValueError): diff --git a/tests/unit/v1/test_watch.py b/tests/unit/v1/test_watch.py index e3e0adfce0..2d7927a1de 100644 --- a/tests/unit/v1/test_watch.py +++ b/tests/unit/v1/test_watch.py @@ -163,7 +163,8 @@ def _document_watch_comparator(doc1, doc2): # pragma: NO COVER def _make_watch_no_mocks( - snapshots=None, comparator=_document_watch_comparator, + snapshots=None, + comparator=_document_watch_comparator, ): from google.cloud.firestore_v1.watch import Watch @@ -227,7 +228,9 @@ def snapshot_callback(*args): # pragma: NO COVER with mock.patch("google.cloud.firestore_v1.watch.ResumableBidiRpc"): with mock.patch("google.cloud.firestore_v1.watch.BackgroundConsumer"): inst = Watch.for_document( - docref, snapshot_callback, document_snapshot_cls=DummyDocumentSnapshot, + docref, + snapshot_callback, + document_snapshot_cls=DummyDocumentSnapshot, ) inst._consumer.start.assert_called_once_with() @@ -257,7 +260,8 @@ def snapshot_callback(*args): # pragma: NO COVER inst._rpc.add_done_callback.assert_called_once_with(inst._on_rpc_done) parent_path, _ = parent._parent_info() target.QueryTarget.assert_called_once_with( - parent=parent_path, structured_query=query._to_protobuf(), + parent=parent_path, + structured_query=query._to_protobuf(), ) query_target = target.QueryTarget.return_value assert inst._targets["query"] is query_target._pb @@ -289,7 +293,8 @@ def snapshot_callback(*args): # pragma: NO COVER query_target = target.QueryTarget.return_value parent_path, _ = parent._parent_info() target.QueryTarget.assert_called_once_with( - parent=parent_path, structured_query=query._to_protobuf(), + parent=parent_path, + structured_query=query._to_protobuf(), ) query_target = target.QueryTarget.return_value assert inst._targets["query"] is query_target._pb From f7cf95ea6f074c42e1410a685070bae7e1b8a358 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 17:00:36 +0000 Subject: [PATCH 03/15] chore(python): add E231 to .flake8 ignore list (#554) Source-Link: https://github.com/googleapis/synthtool/commit/7ff4aad2ec5af0380e8bd6da1fa06eaadf24ec81 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 --- .flake8 | 2 +- .github/.OwlBot.lock.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 29227d4cf4..2e43874986 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 87dd006115..9e0a9356b6 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe + digest: sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 From 028adb5e28af0654883186c6a6baf20718e0ce47 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:10:18 +0000 Subject: [PATCH 04/15] chore(python): update .pre-commit-config.yaml to use black==22.3.0 (#555) Source-Link: https://github.com/googleapis/synthtool/commit/7804ade3daae0d66649bee8df6c55484c6580b8d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d --- .github/.OwlBot.lock.yaml | 3 ++- .pre-commit-config.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 9e0a9356b6..22cc254afa 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:462782b0b492346b2d9099aaff52206dd30bc8e031ea97082e6facecc2373244 + digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d +# created: 2022-03-30T23:44:26.560599165Z diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77d9..46d237160f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 From a92e1d0f80c2ef05fbf4452210cb6477eef5a82d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 02:12:27 +0000 Subject: [PATCH 05/15] chore(python): Enable size-label bot (#556) Source-Link: https://github.com/googleapis/synthtool/commit/06e82790dd719a165ad32b8a06f8f6ec3e3cae0f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .github/auto-label.yaml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 22cc254afa..58a0b153bf 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d -# created: 2022-03-30T23:44:26.560599165Z + digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce +# created: 2022-04-01T01:42:03.609279246Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000000..09c8d735b4 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,2 @@ +requestsize: + enabled: true From 8fcbf979e8ec84602a4a2aa52fc089796549ea69 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 21:00:17 +0000 Subject: [PATCH 06/15] chore(python): refactor unit / system test dependency install (#558) Source-Link: https://github.com/googleapis/synthtool/commit/993985f0fc4b37152e588f0549bcbdaf34666023 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd --- .github/.OwlBot.lock.yaml | 4 +- noxfile.py | 117 +++++++++++++++++++++++++++++--------- 2 files changed, 91 insertions(+), 30 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 58a0b153bf..fa5762290c 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce -# created: 2022-04-01T01:42:03.609279246Z + digest: sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd +# created: 2022-04-01T15:48:07.524222836Z diff --git a/noxfile.py b/noxfile.py index d27d2c81a1..69a18c23c9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,17 +20,45 @@ import os import pathlib import shutil +import warnings import nox - PYTYPE_VERSION = "pytype==2020.7.24" BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.7"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [ + "aiounittest", +] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.7"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [ + "pytest-asyncio", +] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -102,24 +130,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - session.install("aiounittest", "-c", constraints_path) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -143,6 +188,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system_emulated(session): import subprocess @@ -216,20 +290,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install( - "mock", - "pytest", - "google-cloud-testutils", - "pytest-asyncio", - "-c", - constraints_path, - ) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: From 2b1828a03c496cf0a378d457350c2ca7b7d75d03 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Mon, 4 Apr 2022 05:42:07 -0400 Subject: [PATCH 07/15] chore: allow releases on previous majors (#552) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: allow releases on previous majors * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .github/release-please.yml | 9 +++++++++ owlbot.py | 2 ++ 2 files changed, 11 insertions(+) diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e5b1..29601ad469 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,11 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v1 + handleGHRelease: true + releaseType: python +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/owlbot.py b/owlbot.py index c3c8812fae..f25c396776 100644 --- a/owlbot.py +++ b/owlbot.py @@ -145,6 +145,8 @@ def update_fixup_scripts(library): python.py_samples(skip_readmes=True) +python.configure_previous_major_version_branches() + # ---------------------------------------------------------------------------- # Customize noxfile.py # ---------------------------------------------------------------------------- From 984f98d551477d6ed60a8037ffeb26f31d31f808 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:48:15 +0000 Subject: [PATCH 08/15] chore(python): add license header to auto-label.yaml (#560) Source-Link: https://github.com/googleapis/synthtool/commit/eb78c980b52c7c6746d2edb77d9cf7aaa99a2aab Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index fa5762290c..bc893c979e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd -# created: 2022-04-01T15:48:07.524222836Z + digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 +# created: 2022-04-06T10:30:21.687684602Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml index 09c8d735b4..41bff0b537 100644 --- a/.github/auto-label.yaml +++ b/.github/auto-label.yaml @@ -1,2 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. requestsize: enabled: true From 4d054b0f1323e1564eaa9f11326129707b1b1872 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 21:46:26 +0000 Subject: [PATCH 09/15] chore: use gapic-generator-python 0.65.1 (#563) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 441524537 Source-Link: https://github.com/googleapis/googleapis/commit/2a273915b3f70fe86c9d2a75470a0b83e48d0abf Source-Link: https://github.com/googleapis/googleapis-gen/commit/ab6756a48c89b5bcb9fb73443cb8e55d574f4643 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWI2NzU2YTQ4Yzg5YjViY2I5ZmI3MzQ0M2NiOGU1NWQ1NzRmNDY0MyJ9 docs: clarifications for filters PiperOrigin-RevId: 441242400 Source-Link: https://github.com/googleapis/googleapis/commit/9ef00159f265f7fcbcee5645af1402f4d39b2f6a Source-Link: https://github.com/googleapis/googleapis-gen/commit/a0735cb5d613c910232479b487929cc45d7d4855 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTA3MzVjYjVkNjEzYzkxMDIzMjQ3OWI0ODc5MjljYzQ1ZDdkNDg1NSJ9 chore: Use gapic-generator-python 0.65.0 docs: fix type in docstring for map fields PiperOrigin-RevId: 440970084 Source-Link: https://github.com/googleapis/googleapis/commit/5e0a3d57254ab9857ccac77fc6ffade7b69a2dc7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b0c628a3fade768f225d76992791ea1ba2a881be Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBjNjI4YTNmYWRlNzY4ZjIyNWQ3Njk5Mjc5MWVhMWJhMmE4ODFiZSJ9 --- .../services/firestore_admin/async_client.py | 7 +- .../services/firestore_admin/client.py | 7 +- .../firestore_admin/transports/base.py | 5 + .../firestore_admin/transports/grpc.py | 4 + .../firestore_admin_v1/types/__init__.py | 16 +++- .../services/firestore/async_client.py | 6 +- .../firestore_v1/services/firestore/client.py | 17 ++-- .../services/firestore/transports/base.py | 5 + .../services/firestore/transports/grpc.py | 4 + google/cloud/firestore_v1/types/document.py | 4 +- google/cloud/firestore_v1/types/firestore.py | 6 +- google/cloud/firestore_v1/types/query.py | 5 +- .../test_firestore_admin.py | 87 ++++++++++++----- .../unit/gapic/firestore_v1/test_firestore.py | 93 ++++++++++++++----- 14 files changed, 189 insertions(+), 77 deletions(-) diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py index 66c3a6fd03..a007f80a73 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -268,7 +268,6 @@ async def create_index( metadata for the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -831,7 +830,6 @@ async def update_field( the special ``Field`` with resource name: ``projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*``. - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -957,7 +955,6 @@ async def list_fields( with the filter set to ``indexConfig.usesAncestorConfig:false`` . - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -1090,7 +1087,6 @@ async def export_documents( refer to: https://cloud.google.com/firestore/docs/manage-data/export-import - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -1209,7 +1205,6 @@ async def import_documents( cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore. - .. code-block:: python from google.cloud import firestore_admin_v1 diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/client.py index 3040aa6754..81f30a42ed 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -549,7 +549,6 @@ def create_index( metadata for the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -1068,7 +1067,6 @@ def update_field( the special ``Field`` with resource name: ``projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*``. - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -1194,7 +1192,6 @@ def list_fields( with the filter set to ``indexConfig.usesAncestorConfig:false`` . - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -1316,7 +1313,6 @@ def export_documents( refer to: https://cloud.google.com/firestore/docs/manage-data/export-import - .. code-block:: python from google.cloud import firestore_admin_v1 @@ -1435,7 +1431,6 @@ def import_documents( cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore. - .. code-block:: python from google.cloud import firestore_admin_v1 diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py index f4185f72c5..496731330d 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py @@ -89,6 +89,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -375,5 +376,9 @@ def update_database( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("FirestoreAdminTransport",) diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py index 3ac3627df9..600ac9cc31 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py @@ -641,5 +641,9 @@ def update_database( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("FirestoreAdminGrpcTransport",) diff --git a/google/cloud/firestore_admin_v1/types/__init__.py b/google/cloud/firestore_admin_v1/types/__init__.py index e97206f3f4..158f96a2f6 100644 --- a/google/cloud/firestore_admin_v1/types/__init__.py +++ b/google/cloud/firestore_admin_v1/types/__init__.py @@ -13,8 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .database import Database -from .field import Field +from .database import ( + Database, +) +from .field import ( + Field, +) from .firestore_admin import ( CreateIndexRequest, DeleteIndexRequest, @@ -33,8 +37,12 @@ UpdateDatabaseRequest, UpdateFieldRequest, ) -from .index import Index -from .location import LocationMetadata +from .index import ( + Index, +) +from .location import ( + LocationMetadata, +) from .operation import ( ExportDocumentsMetadata, ExportDocumentsResponse, diff --git a/google/cloud/firestore_v1/services/firestore/async_client.py b/google/cloud/firestore_v1/services/firestore/async_client.py index dbf1780333..68909abfb1 100644 --- a/google/cloud/firestore_v1/services/firestore/async_client.py +++ b/google/cloud/firestore_v1/services/firestore/async_client.py @@ -18,6 +18,7 @@ import re from typing import ( Dict, + Mapping, Optional, AsyncIterable, Awaitable, @@ -637,7 +638,6 @@ def batch_get_documents( Documents returned by this method are not guaranteed to be returned in the same order that they were requested. - .. code-block:: python from google.cloud import firestore_v1 @@ -835,7 +835,6 @@ async def commit( r"""Commits a transaction, while optionally updating documents. - .. code-block:: python from google.cloud import firestore_v1 @@ -1146,7 +1145,6 @@ async def partition_query( used by RunQuery as starting/end points for the query results. - .. code-block:: python from google.cloud import firestore_v1 @@ -1246,7 +1244,6 @@ def write( r"""Streams batches of document updates and deletes, in order. - .. code-block:: python from google.cloud import firestore_v1 @@ -1565,7 +1562,6 @@ async def batch_write( If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.Commit] instead. - .. code-block:: python from google.cloud import firestore_v1 diff --git a/google/cloud/firestore_v1/services/firestore/client.py b/google/cloud/firestore_v1/services/firestore/client.py index 3656ce84a3..5f55e7d640 100644 --- a/google/cloud/firestore_v1/services/firestore/client.py +++ b/google/cloud/firestore_v1/services/firestore/client.py @@ -16,7 +16,17 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Iterable, Iterator, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Mapping, + Optional, + Iterable, + Iterator, + Sequence, + Tuple, + Type, + Union, +) import pkg_resources from google.api_core import client_options as client_options_lib @@ -791,7 +801,6 @@ def batch_get_documents( Documents returned by this method are not guaranteed to be returned in the same order that they were requested. - .. code-block:: python from google.cloud import firestore_v1 @@ -966,7 +975,6 @@ def commit( r"""Commits a transaction, while optionally updating documents. - .. code-block:: python from google.cloud import firestore_v1 @@ -1244,7 +1252,6 @@ def partition_query( used by RunQuery as starting/end points for the query results. - .. code-block:: python from google.cloud import firestore_v1 @@ -1333,7 +1340,6 @@ def write( r"""Streams batches of document updates and deletes, in order. - .. code-block:: python from google.cloud import firestore_v1 @@ -1620,7 +1626,6 @@ def batch_write( If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.Commit] instead. - .. code-block:: python from google.cloud import firestore_v1 diff --git a/google/cloud/firestore_v1/services/firestore/transports/base.py b/google/cloud/firestore_v1/services/firestore/transports/base.py index d2fe931108..108256b054 100644 --- a/google/cloud/firestore_v1/services/firestore/transports/base.py +++ b/google/cloud/firestore_v1/services/firestore/transports/base.py @@ -86,6 +86,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -521,5 +522,9 @@ def create_document( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("FirestoreTransport",) diff --git a/google/cloud/firestore_v1/services/firestore/transports/grpc.py b/google/cloud/firestore_v1/services/firestore/transports/grpc.py index ee9c9963d6..6623670ce8 100644 --- a/google/cloud/firestore_v1/services/firestore/transports/grpc.py +++ b/google/cloud/firestore_v1/services/firestore/transports/grpc.py @@ -646,5 +646,9 @@ def create_document( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("FirestoreGrpcTransport",) diff --git a/google/cloud/firestore_v1/types/document.py b/google/cloud/firestore_v1/types/document.py index 750706ead7..330db6f54e 100644 --- a/google/cloud/firestore_v1/types/document.py +++ b/google/cloud/firestore_v1/types/document.py @@ -39,7 +39,7 @@ class Document(proto.Message): name (str): The resource name of the document, for example ``projects/{project_id}/databases/{database_id}/documents/{document_path}``. - fields (Sequence[google.cloud.firestore_v1.types.Document.FieldsEntry]): + fields (Mapping[str, google.cloud.firestore_v1.types.Value]): The document's fields. The map keys represent field names. @@ -256,7 +256,7 @@ class MapValue(proto.Message): r"""A map value. Attributes: - fields (Sequence[google.cloud.firestore_v1.types.MapValue.FieldsEntry]): + fields (Mapping[str, google.cloud.firestore_v1.types.Value]): The map's fields. The map keys represent field names. Field names matching the diff --git a/google/cloud/firestore_v1/types/firestore.py b/google/cloud/firestore_v1/types/firestore.py index 4741e2ffe9..2ab4836a67 100644 --- a/google/cloud/firestore_v1/types/firestore.py +++ b/google/cloud/firestore_v1/types/firestore.py @@ -924,7 +924,7 @@ class WriteRequest(proto.Message): ``stream_id`` field. Leave this field unset when creating a new stream. - labels (Sequence[google.cloud.firestore_v1.types.WriteRequest.LabelsEntry]): + labels (Mapping[str, str]): Labels associated with this write request. """ @@ -1020,7 +1020,7 @@ class ListenRequest(proto.Message): stream. This field is a member of `oneof`_ ``target_change``. - labels (Sequence[google.cloud.firestore_v1.types.ListenRequest.LabelsEntry]): + labels (Mapping[str, str]): Labels associated with this target change. """ @@ -1383,7 +1383,7 @@ class BatchWriteRequest(proto.Message): not guarantee ordering. Each write succeeds or fails independently. You cannot write to the same document more than once per request. - labels (Sequence[google.cloud.firestore_v1.types.BatchWriteRequest.LabelsEntry]): + labels (Mapping[str, str]): Labels associated with this batch write. """ diff --git a/google/cloud/firestore_v1/types/query.py b/google/cloud/firestore_v1/types/query.py index 54a50262a4..2ee3f8ec93 100644 --- a/google/cloud/firestore_v1/types/query.py +++ b/google/cloud/firestore_v1/types/query.py @@ -156,7 +156,10 @@ class CompositeFilter(proto.Message): The operator for combining multiple filters. filters (Sequence[google.cloud.firestore_v1.types.StructuredQuery.Filter]): The list of filters to combine. - Must contain at least one filter. + + Requires: + + - At least one filter is present. """ class Operator(proto.Enum): diff --git a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py index 61aa7edf89..057beef6ea 100644 --- a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py +++ b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py @@ -102,24 +102,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - FirestoreAdminClient, - FirestoreAdminAsyncClient, + (FirestoreAdminClient, "grpc"), + (FirestoreAdminAsyncClient, "grpc_asyncio"), ], ) -def test_firestore_admin_client_from_service_account_info(client_class): +def test_firestore_admin_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "firestore.googleapis.com:443" + assert client.transport._host == ("firestore.googleapis.com:443") @pytest.mark.parametrize( @@ -148,27 +148,31 @@ def test_firestore_admin_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - FirestoreAdminClient, - FirestoreAdminAsyncClient, + (FirestoreAdminClient, "grpc"), + (FirestoreAdminAsyncClient, "grpc_asyncio"), ], ) -def test_firestore_admin_client_from_service_account_file(client_class): +def test_firestore_admin_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "firestore.googleapis.com:443" + assert client.transport._host == ("firestore.googleapis.com:443") def test_firestore_admin_client_get_transport_class(): @@ -1263,7 +1267,7 @@ async def test_list_indexes_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1309,7 +1313,9 @@ async def test_list_indexes_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_indexes(request={})).pages: + async for page_ in ( + await client.list_indexes(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -2591,7 +2597,7 @@ async def test_list_fields_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -2637,7 +2643,9 @@ async def test_list_fields_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_fields(request={})).pages: + async for page_ in ( + await client.list_fields(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -3892,6 +3900,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = FirestoreAdminClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = FirestoreAdminClient( @@ -3950,6 +3971,14 @@ def test_firestore_admin_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_firestore_admin_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4107,24 +4136,40 @@ def test_firestore_admin_grpc_transport_client_cert_source_for_mtls(transport_cl ) -def test_firestore_admin_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_firestore_admin_host_no_port(transport_name): client = FirestoreAdminClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="firestore.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "firestore.googleapis.com:443" + assert client.transport._host == ("firestore.googleapis.com:443") -def test_firestore_admin_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_firestore_admin_host_with_port(transport_name): client = FirestoreAdminClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="firestore.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "firestore.googleapis.com:8000" + assert client.transport._host == ("firestore.googleapis.com:8000") def test_firestore_admin_grpc_transport_channel(): diff --git a/tests/unit/gapic/firestore_v1/test_firestore.py b/tests/unit/gapic/firestore_v1/test_firestore.py index f8c68848f4..589dfbe002 100644 --- a/tests/unit/gapic/firestore_v1/test_firestore.py +++ b/tests/unit/gapic/firestore_v1/test_firestore.py @@ -90,24 +90,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - FirestoreClient, - FirestoreAsyncClient, + (FirestoreClient, "grpc"), + (FirestoreAsyncClient, "grpc_asyncio"), ], ) -def test_firestore_client_from_service_account_info(client_class): +def test_firestore_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "firestore.googleapis.com:443" + assert client.transport._host == ("firestore.googleapis.com:443") @pytest.mark.parametrize( @@ -136,27 +136,31 @@ def test_firestore_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - FirestoreClient, - FirestoreAsyncClient, + (FirestoreClient, "grpc"), + (FirestoreAsyncClient, "grpc_asyncio"), ], ) -def test_firestore_client_from_service_account_file(client_class): +def test_firestore_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "firestore.googleapis.com:443" + assert client.transport._host == ("firestore.googleapis.com:443") def test_firestore_client_get_transport_class(): @@ -1059,7 +1063,7 @@ async def test_list_documents_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1105,7 +1109,9 @@ async def test_list_documents_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_documents(request={})).pages: + async for page_ in ( + await client.list_documents(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -2875,7 +2881,7 @@ async def test_partition_query_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -2921,7 +2927,9 @@ async def test_partition_query_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.partition_query(request={})).pages: + async for page_ in ( + await client.partition_query(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -3459,7 +3467,7 @@ async def test_list_collection_ids_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -3507,7 +3515,9 @@ async def test_list_collection_ids_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_collection_ids(request={})).pages: + async for page_ in ( + await client.list_collection_ids(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -3896,6 +3906,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = FirestoreClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = FirestoreClient( @@ -3952,6 +3975,14 @@ def test_firestore_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_firestore_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4106,24 +4137,40 @@ def test_firestore_grpc_transport_client_cert_source_for_mtls(transport_class): ) -def test_firestore_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_firestore_host_no_port(transport_name): client = FirestoreClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="firestore.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "firestore.googleapis.com:443" + assert client.transport._host == ("firestore.googleapis.com:443") -def test_firestore_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_firestore_host_with_port(transport_name): client = FirestoreClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="firestore.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "firestore.googleapis.com:8000" + assert client.transport._host == ("firestore.googleapis.com:8000") def test_firestore_grpc_transport_channel(): From ef9010286f18f61108acf9c51aec8861b9cb24b2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 20:22:15 -0400 Subject: [PATCH 10/15] chore(python): add nox session to sort python imports (#567) Source-Link: https://github.com/googleapis/synthtool/commit/1b71c10e20de7ed3f97f692f99a0e3399b67049f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- noxfile.py | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bc893c979e..7c454abf76 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 -# created: 2022-04-06T10:30:21.687684602Z + digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 +# created: 2022-04-20T23:42:53.970438194Z diff --git a/noxfile.py b/noxfile.py index 69a18c23c9..151fa88263 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,7 +26,8 @@ PYTYPE_VERSION = "pytype==2020.7.24" BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -90,7 +91,7 @@ def lint(session): session.run( "black", "--check", - *BLACK_PATHS, + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -101,7 +102,27 @@ def blacken(session): session.install(BLACK_VERSION) session.run( "black", - *BLACK_PATHS, + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) From 317ecc7460ae5c505aeab1f0804e89c2dfb00928 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:12:34 +0000 Subject: [PATCH 11/15] chore(python): use ubuntu 22.04 in docs image (#569) Source-Link: https://github.com/googleapis/synthtool/commit/f15cc72fb401b4861cedebb10af74afe428fb1f8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/docker/docs/Dockerfile | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7c454abf76..64f82d6bf4 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 -# created: 2022-04-20T23:42:53.970438194Z + digest: sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd +# created: 2022-04-21T15:43:16.246106921Z diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb8b5..238b87b9d1 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] From 3ec13dac8eb72dd5d5314528956a5aa8218fd5ba Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:15:29 -0400 Subject: [PATCH 12/15] feat: Enable RunQueryResponse.done (#572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.65.2 PiperOrigin-RevId: 444333013 Source-Link: https://github.com/googleapis/googleapis/commit/f91b6cf82e929280f6562f6110957c654bd9e2e6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/16eb36095c294e712c74a1bf23550817b42174e5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZlYjM2MDk1YzI5NGU3MTJjNzRhMWJmMjM1NTA4MTdiNDIxNzRlNSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat:Enable RunQueryResponse.done PiperOrigin-RevId: 444879243 Source-Link: https://github.com/googleapis/googleapis/commit/c4b98bf382bf34458dc3a8d96d0bf91dbe75fa22 Source-Link: https://github.com/googleapis/googleapis-gen/commit/497ddcdeadceff35b285c6ea43f399e71dc313af Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDk3ZGRjZGVhZGNlZmYzNWIyODVjNmVhNDNmMzk5ZTcxZGMzMTNhZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../services/firestore_admin/async_client.py | 72 +++++------ .../services/firestore/async_client.py | 112 ++++++++-------- .../firestore_v1/services/firestore/client.py | 14 +- google/cloud/firestore_v1/types/firestore.py | 14 ++ .../test_firestore_admin.py | 100 +++++++-------- .../unit/gapic/firestore_v1/test_firestore.py | 121 ++++++++++-------- 6 files changed, 238 insertions(+), 195 deletions(-) diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py index a007f80a73..79c75cd2d8 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py @@ -272,9 +272,9 @@ async def create_index( from google.cloud import firestore_admin_v1 - def sample_create_index(): + async def sample_create_index(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.CreateIndexRequest( @@ -286,7 +286,7 @@ def sample_create_index(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -390,9 +390,9 @@ async def list_indexes( from google.cloud import firestore_admin_v1 - def sample_list_indexes(): + async def sample_list_indexes(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.ListIndexesRequest( @@ -403,7 +403,7 @@ def sample_list_indexes(): page_result = client.list_indexes(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -509,9 +509,9 @@ async def get_index( from google.cloud import firestore_admin_v1 - def sample_get_index(): + async def sample_get_index(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.GetIndexRequest( @@ -519,7 +519,7 @@ def sample_get_index(): ) # Make the request - response = client.get_index(request=request) + response = await client.get_index(request=request) # Handle the response print(response) @@ -616,9 +616,9 @@ async def delete_index( from google.cloud import firestore_admin_v1 - def sample_delete_index(): + async def sample_delete_index(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.DeleteIndexRequest( @@ -626,7 +626,7 @@ def sample_delete_index(): ) # Make the request - client.delete_index(request=request) + await client.delete_index(request=request) Args: request (Union[google.cloud.firestore_admin_v1.types.DeleteIndexRequest, dict]): @@ -710,9 +710,9 @@ async def get_field( from google.cloud import firestore_admin_v1 - def sample_get_field(): + async def sample_get_field(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.GetFieldRequest( @@ -720,7 +720,7 @@ def sample_get_field(): ) # Make the request - response = client.get_field(request=request) + response = await client.get_field(request=request) # Handle the response print(response) @@ -834,9 +834,9 @@ async def update_field( from google.cloud import firestore_admin_v1 - def sample_update_field(): + async def sample_update_field(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) field = firestore_admin_v1.Field() @@ -851,7 +851,7 @@ def sample_update_field(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -959,9 +959,9 @@ async def list_fields( from google.cloud import firestore_admin_v1 - def sample_list_fields(): + async def sample_list_fields(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.ListFieldsRequest( @@ -972,7 +972,7 @@ def sample_list_fields(): page_result = client.list_fields(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1091,9 +1091,9 @@ async def export_documents( from google.cloud import firestore_admin_v1 - def sample_export_documents(): + async def sample_export_documents(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.ExportDocumentsRequest( @@ -1105,7 +1105,7 @@ def sample_export_documents(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1209,9 +1209,9 @@ async def import_documents( from google.cloud import firestore_admin_v1 - def sample_import_documents(): + async def sample_import_documents(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.ImportDocumentsRequest( @@ -1223,7 +1223,7 @@ def sample_import_documents(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1329,9 +1329,9 @@ async def get_database( from google.cloud import firestore_admin_v1 - def sample_get_database(): + async def sample_get_database(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.GetDatabaseRequest( @@ -1339,7 +1339,7 @@ def sample_get_database(): ) # Make the request - response = client.get_database(request=request) + response = await client.get_database(request=request) # Handle the response print(response) @@ -1426,9 +1426,9 @@ async def list_databases( from google.cloud import firestore_admin_v1 - def sample_list_databases(): + async def sample_list_databases(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.ListDatabasesRequest( @@ -1436,7 +1436,7 @@ def sample_list_databases(): ) # Make the request - response = client.list_databases(request=request) + response = await client.list_databases(request=request) # Handle the response print(response) @@ -1520,9 +1520,9 @@ async def update_database( from google.cloud import firestore_admin_v1 - def sample_update_database(): + async def sample_update_database(): # Create a client - client = firestore_admin_v1.FirestoreAdminClient() + client = firestore_admin_v1.FirestoreAdminAsyncClient() # Initialize request argument(s) request = firestore_admin_v1.UpdateDatabaseRequest( @@ -1533,7 +1533,7 @@ def sample_update_database(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) diff --git a/google/cloud/firestore_v1/services/firestore/async_client.py b/google/cloud/firestore_v1/services/firestore/async_client.py index 68909abfb1..c5a3435803 100644 --- a/google/cloud/firestore_v1/services/firestore/async_client.py +++ b/google/cloud/firestore_v1/services/firestore/async_client.py @@ -234,9 +234,9 @@ async def get_document( from google.cloud import firestore_v1 - def sample_get_document(): + async def sample_get_document(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.GetDocumentRequest( @@ -245,7 +245,7 @@ def sample_get_document(): ) # Make the request - response = client.get_document(request=request) + response = await client.get_document(request=request) # Handle the response print(response) @@ -320,9 +320,9 @@ async def list_documents( from google.cloud import firestore_v1 - def sample_list_documents(): + async def sample_list_documents(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.ListDocumentsRequest( @@ -335,7 +335,7 @@ def sample_list_documents(): page_result = client.list_documents(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -383,7 +383,12 @@ def sample_list_documents(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata( + ( + ("parent", request.parent), + ("collection_id", request.collection_id), + ) + ), ) # Send the request. @@ -422,16 +427,16 @@ async def update_document( from google.cloud import firestore_v1 - def sample_update_document(): + async def sample_update_document(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.UpdateDocumentRequest( ) # Make the request - response = client.update_document(request=request) + response = await client.update_document(request=request) # Handle the response print(response) @@ -545,9 +550,9 @@ async def delete_document( from google.cloud import firestore_v1 - def sample_delete_document(): + async def sample_delete_document(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.DeleteDocumentRequest( @@ -555,7 +560,7 @@ def sample_delete_document(): ) # Make the request - client.delete_document(request=request) + await client.delete_document(request=request) Args: request (Union[google.cloud.firestore_v1.types.DeleteDocumentRequest, dict]): @@ -642,9 +647,9 @@ def batch_get_documents( from google.cloud import firestore_v1 - def sample_batch_get_documents(): + async def sample_batch_get_documents(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.BatchGetDocumentsRequest( @@ -653,10 +658,10 @@ def sample_batch_get_documents(): ) # Make the request - stream = client.batch_get_documents(request=request) + stream = await client.batch_get_documents(request=request) # Handle the response - for response in stream: + async for response in stream: print(response) Args: @@ -730,9 +735,9 @@ async def begin_transaction( from google.cloud import firestore_v1 - def sample_begin_transaction(): + async def sample_begin_transaction(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.BeginTransactionRequest( @@ -740,7 +745,7 @@ def sample_begin_transaction(): ) # Make the request - response = client.begin_transaction(request=request) + response = await client.begin_transaction(request=request) # Handle the response print(response) @@ -839,9 +844,9 @@ async def commit( from google.cloud import firestore_v1 - def sample_commit(): + async def sample_commit(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.CommitRequest( @@ -849,7 +854,7 @@ def sample_commit(): ) # Make the request - response = client.commit(request=request) + response = await client.commit(request=request) # Handle the response print(response) @@ -954,9 +959,9 @@ async def rollback( from google.cloud import firestore_v1 - def sample_rollback(): + async def sample_rollback(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.RollbackRequest( @@ -965,7 +970,7 @@ def sample_rollback(): ) # Make the request - client.rollback(request=request) + await client.rollback(request=request) Args: request (Union[google.cloud.firestore_v1.types.RollbackRequest, dict]): @@ -1058,9 +1063,9 @@ def run_query( from google.cloud import firestore_v1 - def sample_run_query(): + async def sample_run_query(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.RunQueryRequest( @@ -1069,10 +1074,10 @@ def sample_run_query(): ) # Make the request - stream = client.run_query(request=request) + stream = await client.run_query(request=request) # Handle the response - for response in stream: + async for response in stream: print(response) Args: @@ -1149,9 +1154,9 @@ async def partition_query( from google.cloud import firestore_v1 - def sample_partition_query(): + async def sample_partition_query(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.PartitionQueryRequest( @@ -1162,7 +1167,7 @@ def sample_partition_query(): page_result = client.partition_query(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1248,9 +1253,9 @@ def write( from google.cloud import firestore_v1 - def sample_write(): + async def sample_write(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.WriteRequest( @@ -1268,10 +1273,10 @@ def request_generator(): yield request # Make the request - stream = client.write(requests=request_generator()) + stream = await client.write(requests=request_generator()) # Handle the response - for response in stream: + async for response in stream: print(response) Args: @@ -1338,9 +1343,9 @@ def listen( from google.cloud import firestore_v1 - def sample_listen(): + async def sample_listen(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) add_target = firestore_v1.Target() @@ -1362,10 +1367,10 @@ def request_generator(): yield request # Make the request - stream = client.listen(requests=request_generator()) + stream = await client.listen(requests=request_generator()) # Handle the response - for response in stream: + async for response in stream: print(response) Args: @@ -1435,9 +1440,9 @@ async def list_collection_ids( from google.cloud import firestore_v1 - def sample_list_collection_ids(): + async def sample_list_collection_ids(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.ListCollectionIdsRequest( @@ -1448,7 +1453,7 @@ def sample_list_collection_ids(): page_result = client.list_collection_ids(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1566,9 +1571,9 @@ async def batch_write( from google.cloud import firestore_v1 - def sample_batch_write(): + async def sample_batch_write(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.BatchWriteRequest( @@ -1576,7 +1581,7 @@ def sample_batch_write(): ) # Make the request - response = client.batch_write(request=request) + response = await client.batch_write(request=request) # Handle the response print(response) @@ -1650,9 +1655,9 @@ async def create_document( from google.cloud import firestore_v1 - def sample_create_document(): + async def sample_create_document(): # Create a client - client = firestore_v1.FirestoreClient() + client = firestore_v1.FirestoreAsyncClient() # Initialize request argument(s) request = firestore_v1.CreateDocumentRequest( @@ -1661,7 +1666,7 @@ def sample_create_document(): ) # Make the request - response = client.create_document(request=request) + response = await client.create_document(request=request) # Handle the response print(response) @@ -1706,7 +1711,12 @@ def sample_create_document(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata( + ( + ("parent", request.parent), + ("collection_id", request.collection_id), + ) + ), ) # Send the request. diff --git a/google/cloud/firestore_v1/services/firestore/client.py b/google/cloud/firestore_v1/services/firestore/client.py index 5f55e7d640..26cb666744 100644 --- a/google/cloud/firestore_v1/services/firestore/client.py +++ b/google/cloud/firestore_v1/services/firestore/client.py @@ -568,7 +568,12 @@ def sample_list_documents(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata( + ( + ("parent", request.parent), + ("collection_id", request.collection_id), + ) + ), ) # Send the request. @@ -1751,7 +1756,12 @@ def sample_create_document(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata( + ( + ("parent", request.parent), + ("collection_id", request.collection_id), + ) + ), ) # Send the request. diff --git a/google/cloud/firestore_v1/types/firestore.py b/google/cloud/firestore_v1/types/firestore.py index 2ab4836a67..e2bdc34dec 100644 --- a/google/cloud/firestore_v1/types/firestore.py +++ b/google/cloud/firestore_v1/types/firestore.py @@ -702,6 +702,9 @@ class RunQueryResponse(proto.Message): r"""The response for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: transaction (bytes): The transaction that was started as part of this request. @@ -725,6 +728,12 @@ class RunQueryResponse(proto.Message): The number of results that have been skipped due to an offset between the last response and the current response. + done (bool): + If present, Firestore has completely finished + the request and no more documents will be + returned. + + This field is a member of `oneof`_ ``continuation_selector``. """ transaction = proto.Field( @@ -745,6 +754,11 @@ class RunQueryResponse(proto.Message): proto.INT32, number=4, ) + done = proto.Field( + proto.BOOL, + number=6, + oneof="continuation_selector", + ) class PartitionQueryRequest(proto.Message): diff --git a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py index 057beef6ea..923fe1958c 100644 --- a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py +++ b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py @@ -757,7 +757,7 @@ def test_create_index_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.CreateIndexRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_index), "__call__") as call: @@ -773,7 +773,7 @@ def test_create_index_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -787,7 +787,7 @@ async def test_create_index_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.CreateIndexRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_index), "__call__") as call: @@ -805,7 +805,7 @@ async def test_create_index_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -999,7 +999,7 @@ def test_list_indexes_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.ListIndexesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: @@ -1015,7 +1015,7 @@ def test_list_indexes_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1029,7 +1029,7 @@ async def test_list_indexes_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.ListIndexesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: @@ -1047,7 +1047,7 @@ async def test_list_indexes_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1178,7 +1178,7 @@ def test_list_indexes_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, index.Index) for i in results) @@ -1427,7 +1427,7 @@ def test_get_index_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.GetIndexRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: @@ -1443,7 +1443,7 @@ def test_get_index_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1457,7 +1457,7 @@ async def test_get_index_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.GetIndexRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: @@ -1473,7 +1473,7 @@ async def test_get_index_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1647,7 +1647,7 @@ def test_delete_index_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.DeleteIndexRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_index), "__call__") as call: @@ -1663,7 +1663,7 @@ def test_delete_index_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1677,7 +1677,7 @@ async def test_delete_index_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.DeleteIndexRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_index), "__call__") as call: @@ -1693,7 +1693,7 @@ async def test_delete_index_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1875,7 +1875,7 @@ def test_get_field_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.GetFieldRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_field), "__call__") as call: @@ -1891,7 +1891,7 @@ def test_get_field_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1905,7 +1905,7 @@ async def test_get_field_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.GetFieldRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_field), "__call__") as call: @@ -1921,7 +1921,7 @@ async def test_get_field_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2097,7 +2097,7 @@ def test_update_field_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.UpdateFieldRequest() - request.field.name = "field.name/value" + request.field.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_field), "__call__") as call: @@ -2113,7 +2113,7 @@ def test_update_field_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "field.name=field.name/value", + "field.name=name_value", ) in kw["metadata"] @@ -2127,7 +2127,7 @@ async def test_update_field_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.UpdateFieldRequest() - request.field.name = "field.name/value" + request.field.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_field), "__call__") as call: @@ -2145,7 +2145,7 @@ async def test_update_field_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "field.name=field.name/value", + "field.name=name_value", ) in kw["metadata"] @@ -2329,7 +2329,7 @@ def test_list_fields_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.ListFieldsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_fields), "__call__") as call: @@ -2345,7 +2345,7 @@ def test_list_fields_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2359,7 +2359,7 @@ async def test_list_fields_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.ListFieldsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_fields), "__call__") as call: @@ -2377,7 +2377,7 @@ async def test_list_fields_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2508,7 +2508,7 @@ def test_list_fields_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, field.Field) for i in results) @@ -2743,7 +2743,7 @@ def test_export_documents_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.ExportDocumentsRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_documents), "__call__") as call: @@ -2759,7 +2759,7 @@ def test_export_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2773,7 +2773,7 @@ async def test_export_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.ExportDocumentsRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_documents), "__call__") as call: @@ -2791,7 +2791,7 @@ async def test_export_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2969,7 +2969,7 @@ def test_import_documents_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.ImportDocumentsRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_documents), "__call__") as call: @@ -2985,7 +2985,7 @@ def test_import_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2999,7 +2999,7 @@ async def test_import_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.ImportDocumentsRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_documents), "__call__") as call: @@ -3017,7 +3017,7 @@ async def test_import_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -3217,7 +3217,7 @@ def test_get_database_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.GetDatabaseRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database), "__call__") as call: @@ -3233,7 +3233,7 @@ def test_get_database_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -3247,7 +3247,7 @@ async def test_get_database_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.GetDatabaseRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database), "__call__") as call: @@ -3263,7 +3263,7 @@ async def test_get_database_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -3439,7 +3439,7 @@ def test_list_databases_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.ListDatabasesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_databases), "__call__") as call: @@ -3455,7 +3455,7 @@ def test_list_databases_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -3469,7 +3469,7 @@ async def test_list_databases_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.ListDatabasesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_databases), "__call__") as call: @@ -3487,7 +3487,7 @@ async def test_list_databases_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -3665,7 +3665,7 @@ def test_update_database_field_headers(): # a field header. Set these to a non-empty value. request = firestore_admin.UpdateDatabaseRequest() - request.database.name = "database.name/value" + request.database.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_database), "__call__") as call: @@ -3681,7 +3681,7 @@ def test_update_database_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database.name=database.name/value", + "database.name=name_value", ) in kw["metadata"] @@ -3695,7 +3695,7 @@ async def test_update_database_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore_admin.UpdateDatabaseRequest() - request.database.name = "database.name/value" + request.database.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_database), "__call__") as call: @@ -3713,7 +3713,7 @@ async def test_update_database_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database.name=database.name/value", + "database.name=name_value", ) in kw["metadata"] diff --git a/tests/unit/gapic/firestore_v1/test_firestore.py b/tests/unit/gapic/firestore_v1/test_firestore.py index 589dfbe002..89774b939d 100644 --- a/tests/unit/gapic/firestore_v1/test_firestore.py +++ b/tests/unit/gapic/firestore_v1/test_firestore.py @@ -729,7 +729,7 @@ def test_get_document_field_headers(): # a field header. Set these to a non-empty value. request = firestore.GetDocumentRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_document), "__call__") as call: @@ -745,7 +745,7 @@ def test_get_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -759,7 +759,7 @@ async def test_get_document_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.GetDocumentRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_document), "__call__") as call: @@ -775,7 +775,7 @@ async def test_get_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -877,7 +877,8 @@ def test_list_documents_field_headers(): # a field header. Set these to a non-empty value. request = firestore.ListDocumentsRequest() - request.parent = "parent/value" + request.parent = "parent_value" + request.collection_id = "collection_id_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_documents), "__call__") as call: @@ -893,7 +894,7 @@ def test_list_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value&collection_id=collection_id_value", ) in kw["metadata"] @@ -907,7 +908,8 @@ async def test_list_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.ListDocumentsRequest() - request.parent = "parent/value" + request.parent = "parent_value" + request.collection_id = "collection_id_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_documents), "__call__") as call: @@ -925,7 +927,7 @@ async def test_list_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value&collection_id=collection_id_value", ) in kw["metadata"] @@ -968,13 +970,18 @@ def test_list_documents_pager(transport_name: str = "grpc"): metadata = () metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + gapic_v1.routing_header.to_grpc_metadata( + ( + ("parent", ""), + ("collection_id", ""), + ) + ), ) pager = client.list_documents(request={}) assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, document.Document) for i in results) @@ -1215,7 +1222,7 @@ def test_update_document_field_headers(): # a field header. Set these to a non-empty value. request = firestore.UpdateDocumentRequest() - request.document.name = "document.name/value" + request.document.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_document), "__call__") as call: @@ -1231,7 +1238,7 @@ def test_update_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "document.name=document.name/value", + "document.name=name_value", ) in kw["metadata"] @@ -1245,7 +1252,7 @@ async def test_update_document_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.UpdateDocumentRequest() - request.document.name = "document.name/value" + request.document.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_document), "__call__") as call: @@ -1263,7 +1270,7 @@ async def test_update_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "document.name=document.name/value", + "document.name=name_value", ) in kw["metadata"] @@ -1449,7 +1456,7 @@ def test_delete_document_field_headers(): # a field header. Set these to a non-empty value. request = firestore.DeleteDocumentRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_document), "__call__") as call: @@ -1465,7 +1472,7 @@ def test_delete_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1479,7 +1486,7 @@ async def test_delete_document_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.DeleteDocumentRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_document), "__call__") as call: @@ -1495,7 +1502,7 @@ async def test_delete_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1680,7 +1687,7 @@ def test_batch_get_documents_field_headers(): # a field header. Set these to a non-empty value. request = firestore.BatchGetDocumentsRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1698,7 +1705,7 @@ def test_batch_get_documents_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -1712,7 +1719,7 @@ async def test_batch_get_documents_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.BatchGetDocumentsRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1733,7 +1740,7 @@ async def test_batch_get_documents_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -1841,7 +1848,7 @@ def test_begin_transaction_field_headers(): # a field header. Set these to a non-empty value. request = firestore.BeginTransactionRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1859,7 +1866,7 @@ def test_begin_transaction_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -1873,7 +1880,7 @@ async def test_begin_transaction_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.BeginTransactionRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1893,7 +1900,7 @@ async def test_begin_transaction_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -2075,7 +2082,7 @@ def test_commit_field_headers(): # a field header. Set these to a non-empty value. request = firestore.CommitRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.commit), "__call__") as call: @@ -2091,7 +2098,7 @@ def test_commit_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -2105,7 +2112,7 @@ async def test_commit_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.CommitRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.commit), "__call__") as call: @@ -2123,7 +2130,7 @@ async def test_commit_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -2309,7 +2316,7 @@ def test_rollback_field_headers(): # a field header. Set these to a non-empty value. request = firestore.RollbackRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.rollback), "__call__") as call: @@ -2325,7 +2332,7 @@ def test_rollback_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -2339,7 +2346,7 @@ async def test_rollback_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.RollbackRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.rollback), "__call__") as call: @@ -2355,7 +2362,7 @@ async def test_rollback_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -2544,7 +2551,7 @@ def test_run_query_field_headers(): # a field header. Set these to a non-empty value. request = firestore.RunQueryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_query), "__call__") as call: @@ -2560,7 +2567,7 @@ def test_run_query_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2574,7 +2581,7 @@ async def test_run_query_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.RunQueryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_query), "__call__") as call: @@ -2593,7 +2600,7 @@ async def test_run_query_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2695,7 +2702,7 @@ def test_partition_query_field_headers(): # a field header. Set these to a non-empty value. request = firestore.PartitionQueryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.partition_query), "__call__") as call: @@ -2711,7 +2718,7 @@ def test_partition_query_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2725,7 +2732,7 @@ async def test_partition_query_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.PartitionQueryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.partition_query), "__call__") as call: @@ -2743,7 +2750,7 @@ async def test_partition_query_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -2792,7 +2799,7 @@ def test_partition_query_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, query.Cursor) for i in results) @@ -3185,7 +3192,7 @@ def test_list_collection_ids_field_headers(): # a field header. Set these to a non-empty value. request = firestore.ListCollectionIdsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3203,7 +3210,7 @@ def test_list_collection_ids_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -3217,7 +3224,7 @@ async def test_list_collection_ids_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.ListCollectionIdsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3237,7 +3244,7 @@ async def test_list_collection_ids_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -3374,7 +3381,7 @@ def test_list_collection_ids_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, str) for i in results) @@ -3615,7 +3622,7 @@ def test_batch_write_field_headers(): # a field header. Set these to a non-empty value. request = firestore.BatchWriteRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.batch_write), "__call__") as call: @@ -3631,7 +3638,7 @@ def test_batch_write_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -3645,7 +3652,7 @@ async def test_batch_write_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.BatchWriteRequest() - request.database = "database/value" + request.database = "database_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.batch_write), "__call__") as call: @@ -3663,7 +3670,7 @@ async def test_batch_write_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "database=database/value", + "database=database_value", ) in kw["metadata"] @@ -3765,7 +3772,8 @@ def test_create_document_field_headers(): # a field header. Set these to a non-empty value. request = firestore.CreateDocumentRequest() - request.parent = "parent/value" + request.parent = "parent_value" + request.collection_id = "collection_id_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_document), "__call__") as call: @@ -3781,7 +3789,7 @@ def test_create_document_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value&collection_id=collection_id_value", ) in kw["metadata"] @@ -3795,7 +3803,8 @@ async def test_create_document_field_headers_async(): # a field header. Set these to a non-empty value. request = firestore.CreateDocumentRequest() - request.parent = "parent/value" + request.parent = "parent_value" + request.collection_id = "collection_id_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_document), "__call__") as call: @@ -3811,7 +3820,7 @@ async def test_create_document_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value&collection_id=collection_id_value", ) in kw["metadata"] From 5d6a97f980ab46327036bb2d36fc78ed0890ccf4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 12:11:17 -0400 Subject: [PATCH 13/15] chore: [autoapprove] update readme_gen.py to include autoescape True (#573) Source-Link: https://github.com/googleapis/synthtool/commit/6b4d5a6407d740beb4158b302194a62a4108a8a6 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- scripts/readme-gen/readme_gen.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 64f82d6bf4..b631901e99 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd -# created: 2022-04-21T15:43:16.246106921Z + digest: sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 +# created: 2022-05-05T15:17:27.599381182Z diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e975..91b59676bf 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') From bd0fe7b9b062079f3e2f8a378ad3c46277f110a2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 22:58:42 +0000 Subject: [PATCH 14/15] chore(python): auto approve template changes (#575) Source-Link: https://github.com/googleapis/synthtool/commit/453a5d9c9a55d1969240a37d36cec626d20a9024 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-approve.yml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .github/auto-approve.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index b631901e99..757c9dca75 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 -# created: 2022-05-05T15:17:27.599381182Z + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 0000000000..311ebbb853 --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" From 9c830fee630876c30bf2651d7e5cc07482cf5d4d Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 09:04:11 -0400 Subject: [PATCH 15/15] chore(main): release 2.5.0 (#566) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou --- CHANGELOG.md | 13 +++++++++++++ setup.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d5154f24..baa0730188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ [1]: https://pypi.org/project/google-cloud-firestore/#history +## [2.5.0](https://github.com/googleapis/python-firestore/compare/v2.4.0...v2.5.0) (2022-05-05) + + +### Features + +* Enable RunQueryResponse.done ([#572](https://github.com/googleapis/python-firestore/issues/572)) ([3ec13da](https://github.com/googleapis/python-firestore/commit/3ec13dac8eb72dd5d5314528956a5aa8218fd5ba)) + + +### Documentation + +* clarifications for filters ([4d054b0](https://github.com/googleapis/python-firestore/commit/4d054b0f1323e1564eaa9f11326129707b1b1872)) +* fix type in docstring for map fields ([4d054b0](https://github.com/googleapis/python-firestore/commit/4d054b0f1323e1564eaa9f11326129707b1b1872)) + ## [2.4.0](https://github.com/googleapis/python-firestore/compare/v2.3.4...v2.4.0) (2022-03-08) diff --git a/setup.py b/setup.py index 3e109b793f..e97f8455dd 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-firestore" description = "Google Cloud Firestore API client library" -version = "2.4.0" +version = "2.5.0" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x