diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000000..d22d084c8c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - v2 +name: docs +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docs + run: | + nox -s docs + docfx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docfx + run: | + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..8aac157955 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - v2 +name: lint +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + run: | + nox -s lint + - name: Run lint_setup_py + run: | + nox -s lint_setup_py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 0000000000..135e93a6c8 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - v2 +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.6', '3.7', '3.8'] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v3 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v3 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=99 diff --git a/.kokoro/release.sh b/.kokoro/release.sh index d15be7e62c..7690560713 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") cd github/python-spanner python3 setup.py sdist bdist_wheel -twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/* +twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 47b6a1fba3..e073e15d1c 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,18 @@ env_vars: { value: "github/python-spanner/.kokoro/release.sh" } -# Fetch PyPI password -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google_cloud_pypi_password" - } - } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google-cloud-pypi-token-keystore-1" + } + } } # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d7907b0dc..918fa5ec6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-spanner/#history +### [2.1.1](https://github.com/googleapis/python-spanner/compare/v2.1.0...v2.1.1) (2022-04-07) + + +### Bug Fixes + +* **deps:** require google-api-core >= 1.31.5, >= 2.3.2 on v2 release ([#688](https://github.com/googleapis/python-spanner/issues/688)) ([ad8ba58](https://github.com/googleapis/python-spanner/commit/ad8ba5851c400ecbbd69c166700d619f691e4e61)) + ## [2.1.0](https://www.github.com/googleapis/python-spanner/compare/v2.0.0...v2.1.0) (2020-11-24) diff --git a/docs/conf.py b/docs/conf.py index 7d53976561..ee44f87e33 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -347,7 +347,10 @@ intersphinx_mapping = { "python": ("http://python.readthedocs.org/en/latest/", None), "google-auth": ("https://google-auth.readthedocs.io/en/stable", 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.io/grpc/python/", None), } diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py index 4f15f2e2c8..835b152e83 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py @@ -225,7 +225,8 @@ async def list_databases( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -239,12 +240,20 @@ async def 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, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListDatabasesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -344,7 +353,12 @@ async def create_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( @@ -417,7 +431,8 @@ async def get_database( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -431,7 +446,12 @@ async def 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 @@ -546,7 +566,8 @@ async def update_database_ddl( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -560,7 +581,12 @@ async def update_database_ddl( ) # 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( @@ -629,7 +655,8 @@ async def drop_database( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -644,7 +671,10 @@ async def drop_database( # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_database_ddl( @@ -711,7 +741,8 @@ async def get_database_ddl( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -725,7 +756,12 @@ async def get_database_ddl( ) # 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 @@ -853,7 +889,9 @@ async def set_iam_policy( request = iam_policy.SetIamPolicyRequest(**request) elif not request: - request = iam_policy.SetIamPolicyRequest(resource=resource,) + request = iam_policy.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -870,7 +908,12 @@ async def set_iam_policy( ) # 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 @@ -999,7 +1042,9 @@ async def get_iam_policy( request = iam_policy.GetIamPolicyRequest(**request) elif not request: - request = iam_policy.GetIamPolicyRequest(resource=resource,) + request = iam_policy.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1010,7 +1055,8 @@ async def get_iam_policy( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -1024,7 +1070,12 @@ async def get_iam_policy( ) # 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 @@ -1098,7 +1149,8 @@ async def test_iam_permissions( elif not request: request = iam_policy.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1116,7 +1168,12 @@ async def test_iam_permissions( ) # 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 @@ -1227,7 +1284,12 @@ async def create_backup( ) # 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( @@ -1300,7 +1362,8 @@ async def get_backup( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -1314,7 +1377,12 @@ async def get_backup( ) # 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 @@ -1398,7 +1466,8 @@ async def update_backup( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -1414,7 +1483,12 @@ async def update_backup( ) # 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 @@ -1476,7 +1550,8 @@ async def delete_backup( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -1491,7 +1566,10 @@ async def delete_backup( # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def list_backups( @@ -1560,7 +1638,8 @@ async def list_backups( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -1574,12 +1653,20 @@ async def list_backups( ) # 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.ListBackupsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1698,7 +1785,12 @@ async def restore_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( @@ -1785,7 +1877,8 @@ async def list_database_operations( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -1799,12 +1892,20 @@ async def list_database_operations( ) # 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.ListDatabaseOperationsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1886,7 +1987,8 @@ async def list_backup_operations( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -1900,12 +2002,20 @@ async def list_backup_operations( ) # 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.ListBackupOperationsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py index 3edfd9c9ed..9818c2ae40 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py @@ -62,7 +62,10 @@ class DatabaseAdminClientMeta(type): _transport_registry["grpc"] = DatabaseAdminGrpcTransport _transport_registry["grpc_asyncio"] = DatabaseAdminGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[DatabaseAdminTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[DatabaseAdminTransport]: """Return an appropriate transport class. Args: @@ -154,10 +157,16 @@ def transport(self) -> DatabaseAdminTransport: return self._transport @staticmethod - def backup_path(project: str, instance: str, backup: str,) -> str: + def backup_path( + project: str, + instance: str, + backup: str, + ) -> str: """Return a fully-qualified backup string.""" return "projects/{project}/instances/{instance}/backups/{backup}".format( - project=project, instance=instance, backup=backup, + project=project, + instance=instance, + backup=backup, ) @staticmethod @@ -170,10 +179,16 @@ def parse_backup_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def database_path(project: str, instance: str, database: str,) -> str: + def database_path( + project: str, + instance: str, + database: str, + ) -> str: """Return a fully-qualified database string.""" return "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) @staticmethod @@ -186,10 +201,14 @@ def parse_database_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def instance_path(project: str, instance: str,) -> str: + def instance_path( + project: str, + instance: str, + ) -> str: """Return a fully-qualified instance string.""" return "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) @staticmethod @@ -199,7 +218,9 @@ def parse_instance_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: """Return a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -212,9 +233,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: """Return 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]: @@ -223,9 +248,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: """Return 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]: @@ -234,9 +263,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: """Return 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]: @@ -245,10 +278,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: """Return a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -446,12 +483,20 @@ def list_databases( ) # 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.ListDatabasesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -552,7 +597,12 @@ def create_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 = operation.from_gapic( @@ -632,7 +682,12 @@ def 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 @@ -754,7 +809,12 @@ def update_database_ddl( ) # 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 = operation.from_gapic( @@ -831,7 +891,10 @@ def drop_database( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_database_ddl( @@ -905,7 +968,12 @@ def get_database_ddl( ) # 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 @@ -1033,7 +1101,9 @@ def set_iam_policy( request = iam_policy.SetIamPolicyRequest(**request) elif not request: - request = iam_policy.SetIamPolicyRequest(resource=resource,) + request = iam_policy.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1046,7 +1116,12 @@ def set_iam_policy( ) # 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 @@ -1175,7 +1250,9 @@ def get_iam_policy( request = iam_policy.GetIamPolicyRequest(**request) elif not request: - request = iam_policy.GetIamPolicyRequest(resource=resource,) + request = iam_policy.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1188,7 +1265,12 @@ def get_iam_policy( ) # 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 @@ -1262,7 +1344,8 @@ def test_iam_permissions( elif not request: request = iam_policy.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1276,7 +1359,12 @@ def test_iam_permissions( ) # 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 @@ -1388,7 +1476,12 @@ def create_backup( ) # 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 = operation.from_gapic( @@ -1468,7 +1561,12 @@ def get_backup( ) # 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 @@ -1561,7 +1659,12 @@ def update_backup( ) # 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 @@ -1631,7 +1734,10 @@ def delete_backup( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def list_backups( @@ -1707,12 +1813,20 @@ def list_backups( ) # 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.ListBackupsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1832,7 +1946,12 @@ def restore_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 = operation.from_gapic( @@ -1928,12 +2047,20 @@ def list_database_operations( ) # 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.ListDatabaseOperationsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2022,12 +2149,20 @@ def list_backup_operations( ) # 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.ListBackupOperationsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py index 779f02e840..448b8e6552 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py @@ -79,10 +79,10 @@ def __init__( scope (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. @@ -123,14 +123,17 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, client_info=client_info, ), self.create_database: gapic_v1.method.wrap_method( - self.create_database, default_timeout=3600.0, client_info=client_info, + self.create_database, + default_timeout=3600.0, + client_info=client_info, ), self.get_database: gapic_v1.method.wrap_method( self.get_database, @@ -139,7 +142,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -152,7 +156,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -165,7 +170,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -178,14 +184,17 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=30.0, client_info=client_info, + self.set_iam_policy, + default_timeout=30.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -194,7 +203,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -206,7 +216,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_backup: gapic_v1.method.wrap_method( - self.create_backup, default_timeout=3600.0, client_info=client_info, + self.create_backup, + default_timeout=3600.0, + client_info=client_info, ), self.get_backup: gapic_v1.method.wrap_method( self.get_backup, @@ -215,7 +227,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -228,7 +241,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -241,7 +255,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -254,14 +269,17 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, client_info=client_info, ), self.restore_database: gapic_v1.method.wrap_method( - self.restore_database, default_timeout=3600.0, client_info=client_info, + self.restore_database, + default_timeout=3600.0, + client_info=client_info, ), self.list_database_operations: gapic_v1.method.wrap_method( self.list_database_operations, @@ -270,7 +288,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -283,7 +302,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py index 0f8d56f05a..5efe2b55e5 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py @@ -233,8 +233,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/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py index 45f2e2d9e6..b4392136b5 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py @@ -146,10 +146,10 @@ def __init__( for grpc channel. It is ignored if ``channel`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: diff --git a/google/cloud/spanner_admin_database_v1/types/backup.py b/google/cloud/spanner_admin_database_v1/types/backup.py index 4ab6237f04..82a7ce2170 100644 --- a/google/cloud/spanner_admin_database_v1/types/backup.py +++ b/google/cloud/spanner_admin_database_v1/types/backup.py @@ -109,15 +109,27 @@ class State(proto.Enum): database = proto.Field(proto.STRING, number=2) - expire_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + expire_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) name = proto.Field(proto.STRING, number=1) - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp.Timestamp, + ) size_bytes = proto.Field(proto.INT64, number=5) - state = proto.Field(proto.ENUM, number=6, enum=State,) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) referencing_databases = proto.RepeatedField(proto.STRING, number=7) @@ -147,7 +159,11 @@ class CreateBackupRequest(proto.Message): backup_id = proto.Field(proto.STRING, number=2) - backup = proto.Field(proto.MESSAGE, number=3, message="Backup",) + backup = proto.Field( + proto.MESSAGE, + number=3, + message="Backup", + ) class CreateBackupMetadata(proto.Message): @@ -185,9 +201,17 @@ class CreateBackupMetadata(proto.Message): database = proto.Field(proto.STRING, number=2) - progress = proto.Field(proto.MESSAGE, number=3, message=common.OperationProgress,) + progress = proto.Field( + proto.MESSAGE, + number=3, + message=common.OperationProgress, + ) - cancel_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + cancel_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp.Timestamp, + ) class UpdateBackupRequest(proto.Message): @@ -211,9 +235,17 @@ class UpdateBackupRequest(proto.Message): accidentally by clients that do not know about them. """ - backup = proto.Field(proto.MESSAGE, number=1, message="Backup",) + backup = proto.Field( + proto.MESSAGE, + number=1, + message="Backup", + ) - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask.FieldMask, + ) class GetBackupRequest(proto.Message): @@ -336,7 +368,11 @@ class ListBackupsResponse(proto.Message): def raw_page(self): return self - backups = proto.RepeatedField(proto.MESSAGE, number=1, message="Backup",) + backups = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Backup", + ) next_page_token = proto.Field(proto.STRING, number=2) @@ -449,7 +485,9 @@ def raw_page(self): return self operations = proto.RepeatedField( - proto.MESSAGE, number=1, message=gl_operations.Operation, + proto.MESSAGE, + number=1, + message=gl_operations.Operation, ) next_page_token = proto.Field(proto.STRING, number=2) @@ -472,7 +510,11 @@ class BackupInfo(proto.Message): backup = proto.Field(proto.STRING, number=1) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp.Timestamp, + ) source_database = proto.Field(proto.STRING, number=3) diff --git a/google/cloud/spanner_admin_database_v1/types/common.py b/google/cloud/spanner_admin_database_v1/types/common.py index ccd8de2819..3bb1358c9e 100644 --- a/google/cloud/spanner_admin_database_v1/types/common.py +++ b/google/cloud/spanner_admin_database_v1/types/common.py @@ -22,7 +22,10 @@ __protobuf__ = proto.module( - package="google.spanner.admin.database.v1", manifest={"OperationProgress",}, + package="google.spanner.admin.database.v1", + manifest={ + "OperationProgress", + }, ) @@ -43,9 +46,17 @@ class OperationProgress(proto.Message): progress_percent = proto.Field(proto.INT32, number=1) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp.Timestamp, + ) + + end_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py index b2b5939f5b..0d2ff1a45f 100644 --- a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +++ b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py @@ -66,10 +66,17 @@ class RestoreInfo(proto.Message): the database. The backup may no longer exist. """ - source_type = proto.Field(proto.ENUM, number=1, enum="RestoreSourceType",) + source_type = proto.Field( + proto.ENUM, + number=1, + enum="RestoreSourceType", + ) backup_info = proto.Field( - proto.MESSAGE, number=2, oneof="source_info", message=gsad_backup.BackupInfo, + proto.MESSAGE, + number=2, + oneof="source_info", + message=gsad_backup.BackupInfo, ) @@ -103,11 +110,23 @@ class State(proto.Enum): name = proto.Field(proto.STRING, number=1) - state = proto.Field(proto.ENUM, number=2, enum=State,) + state = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) - restore_info = proto.Field(proto.MESSAGE, number=4, message="RestoreInfo",) + restore_info = proto.Field( + proto.MESSAGE, + number=4, + message="RestoreInfo", + ) class ListDatabasesRequest(proto.Message): @@ -154,7 +173,11 @@ class ListDatabasesResponse(proto.Message): def raw_page(self): return self - databases = proto.RepeatedField(proto.MESSAGE, number=1, message="Database",) + databases = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Database", + ) next_page_token = proto.Field(proto.STRING, number=2) @@ -294,7 +317,9 @@ class UpdateDatabaseDdlMetadata(proto.Message): statements = proto.RepeatedField(proto.STRING, number=2) commit_timestamps = proto.RepeatedField( - proto.MESSAGE, number=3, message=timestamp.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, ) @@ -439,7 +464,9 @@ def raw_page(self): return self operations = proto.RepeatedField( - proto.MESSAGE, number=1, message=gl_operations.Operation, + proto.MESSAGE, + number=1, + message=gl_operations.Operation, ) next_page_token = proto.Field(proto.STRING, number=2) @@ -525,15 +552,30 @@ class RestoreDatabaseMetadata(proto.Message): name = proto.Field(proto.STRING, number=1) - source_type = proto.Field(proto.ENUM, number=2, enum="RestoreSourceType",) + source_type = proto.Field( + proto.ENUM, + number=2, + enum="RestoreSourceType", + ) backup_info = proto.Field( - proto.MESSAGE, number=3, oneof="source_info", message=gsad_backup.BackupInfo, + proto.MESSAGE, + number=3, + oneof="source_info", + message=gsad_backup.BackupInfo, ) - progress = proto.Field(proto.MESSAGE, number=4, message=common.OperationProgress,) + progress = proto.Field( + proto.MESSAGE, + number=4, + message=common.OperationProgress, + ) - cancel_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) + cancel_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp.Timestamp, + ) optimize_database_operation_name = proto.Field(proto.STRING, number=6) @@ -556,7 +598,11 @@ class OptimizeRestoredDatabaseMetadata(proto.Message): name = proto.Field(proto.STRING, number=1) - progress = proto.Field(proto.MESSAGE, number=2, message=common.OperationProgress,) + progress = proto.Field( + proto.MESSAGE, + number=2, + message=common.OperationProgress, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py index fd4cd3d18d..92d23fd55f 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py @@ -236,7 +236,8 @@ async def list_instance_configs( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -250,12 +251,20 @@ async def list_instance_configs( ) # 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.ListInstanceConfigsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -326,7 +335,8 @@ async def get_instance_config( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -340,7 +350,12 @@ async def get_instance_config( ) # 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 @@ -410,7 +425,8 @@ async def list_instances( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -424,12 +440,20 @@ async def list_instances( ) # 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.ListInstancesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -497,7 +521,8 @@ async def get_instance( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -511,7 +536,12 @@ async def get_instance( ) # 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 @@ -644,7 +674,12 @@ async def create_instance( ) # 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( @@ -791,7 +826,12 @@ async def update_instance( ) # 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( @@ -870,7 +910,8 @@ async def delete_instance( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -885,7 +926,10 @@ async def delete_instance( # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def set_iam_policy( @@ -1007,7 +1051,9 @@ async def set_iam_policy( request = iam_policy.SetIamPolicyRequest(**request) elif not request: - request = iam_policy.SetIamPolicyRequest(resource=resource,) + request = iam_policy.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1024,7 +1070,12 @@ async def set_iam_policy( ) # 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 @@ -1149,7 +1200,9 @@ async def get_iam_policy( request = iam_policy.GetIamPolicyRequest(**request) elif not request: - request = iam_policy.GetIamPolicyRequest(resource=resource,) + request = iam_policy.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1160,7 +1213,8 @@ async def get_iam_policy( maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -1174,7 +1228,12 @@ async def get_iam_policy( ) # 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 @@ -1245,7 +1304,8 @@ async def test_iam_permissions( elif not request: request = iam_policy.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1263,7 +1323,12 @@ async def test_iam_permissions( ) # 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 diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py index c82a2065bc..663176340a 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py @@ -57,7 +57,10 @@ class InstanceAdminClientMeta(type): _transport_registry["grpc"] = InstanceAdminGrpcTransport _transport_registry["grpc_asyncio"] = InstanceAdminGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[InstanceAdminTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[InstanceAdminTransport]: """Return an appropriate transport class. Args: @@ -164,10 +167,14 @@ def transport(self) -> InstanceAdminTransport: return self._transport @staticmethod - def instance_path(project: str, instance: str,) -> str: + def instance_path( + project: str, + instance: str, + ) -> str: """Return a fully-qualified instance string.""" return "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) @staticmethod @@ -177,10 +184,14 @@ def parse_instance_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def instance_config_path(project: str, instance_config: str,) -> str: + def instance_config_path( + project: str, + instance_config: str, + ) -> str: """Return a fully-qualified instance_config string.""" return "projects/{project}/instanceConfigs/{instance_config}".format( - project=project, instance_config=instance_config, + project=project, + instance_config=instance_config, ) @staticmethod @@ -193,7 +204,9 @@ def parse_instance_config_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: """Return a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -206,9 +219,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: """Return 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]: @@ -217,9 +234,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: """Return 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]: @@ -228,9 +249,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: """Return 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]: @@ -239,10 +264,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: """Return a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -441,12 +470,20 @@ def list_instance_configs( ) # 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.ListInstanceConfigsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -524,7 +561,12 @@ def get_instance_config( ) # 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 @@ -601,12 +643,20 @@ def list_instances( ) # 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.ListInstancesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -681,7 +731,12 @@ def get_instance( ) # 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 @@ -815,7 +870,12 @@ def create_instance( ) # 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 = operation.from_gapic( @@ -963,7 +1023,12 @@ def update_instance( ) # 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 = operation.from_gapic( @@ -1050,7 +1115,10 @@ def delete_instance( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def set_iam_policy( @@ -1172,7 +1240,9 @@ def set_iam_policy( request = iam_policy.SetIamPolicyRequest(**request) elif not request: - request = iam_policy.SetIamPolicyRequest(resource=resource,) + request = iam_policy.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1185,7 +1255,12 @@ def set_iam_policy( ) # 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 @@ -1310,7 +1385,9 @@ def get_iam_policy( request = iam_policy.GetIamPolicyRequest(**request) elif not request: - request = iam_policy.GetIamPolicyRequest(resource=resource,) + request = iam_policy.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1323,7 +1400,12 @@ def get_iam_policy( ) # 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 @@ -1394,7 +1476,8 @@ def test_iam_permissions( elif not request: request = iam_policy.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1408,7 +1491,12 @@ def test_iam_permissions( ) # 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 diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py index fa07b95eeb..753ce12dd9 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py @@ -77,10 +77,10 @@ def __init__( scope (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. @@ -121,7 +121,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -134,7 +135,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -147,7 +149,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, @@ -160,17 +163,22 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, client_info=client_info, ), self.create_instance: gapic_v1.method.wrap_method( - self.create_instance, default_timeout=3600.0, client_info=client_info, + self.create_instance, + default_timeout=3600.0, + client_info=client_info, ), self.update_instance: gapic_v1.method.wrap_method( - self.update_instance, default_timeout=3600.0, client_info=client_info, + self.update_instance, + default_timeout=3600.0, + client_info=client_info, ), self.delete_instance: gapic_v1.method.wrap_method( self.delete_instance, @@ -179,14 +187,17 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=3600.0, client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=30.0, client_info=client_info, + self.set_iam_policy, + default_timeout=30.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -195,7 +206,8 @@ def _prep_wrapped_messages(self, client_info): maximum=32.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py index a758bb6ad4..d4841db4e3 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py @@ -246,8 +246,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/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py index 91fb40d1e7..8b1709a9b6 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py @@ -159,10 +159,10 @@ def __init__( for grpc channel. It is ignored if ``channel`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: diff --git a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py index cf2dc11a33..ad48eb9429 100644 --- a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +++ b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py @@ -72,7 +72,11 @@ class ReplicaType(proto.Enum): location = proto.Field(proto.STRING, number=1) - type_ = proto.Field(proto.ENUM, number=2, enum=ReplicaType,) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=ReplicaType, + ) default_leader_location = proto.Field(proto.BOOL, number=3) @@ -100,7 +104,11 @@ class InstanceConfig(proto.Message): display_name = proto.Field(proto.STRING, number=2) - replicas = proto.RepeatedField(proto.MESSAGE, number=3, message="ReplicaInfo",) + replicas = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="ReplicaInfo", + ) class Instance(proto.Message): @@ -189,7 +197,11 @@ class State(proto.Enum): node_count = proto.Field(proto.INT32, number=5) - state = proto.Field(proto.ENUM, number=6, enum=State,) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) labels = proto.MapField(proto.STRING, proto.STRING, number=7) @@ -242,7 +254,9 @@ def raw_page(self): return self instance_configs = proto.RepeatedField( - proto.MESSAGE, number=1, message="InstanceConfig", + proto.MESSAGE, + number=1, + message="InstanceConfig", ) next_page_token = proto.Field(proto.STRING, number=2) @@ -280,7 +294,11 @@ class GetInstanceRequest(proto.Message): name = proto.Field(proto.STRING, number=1) - field_mask = proto.Field(proto.MESSAGE, number=2, message=gp_field_mask.FieldMask,) + field_mask = proto.Field( + proto.MESSAGE, + number=2, + message=gp_field_mask.FieldMask, + ) class CreateInstanceRequest(proto.Message): @@ -305,7 +323,11 @@ class CreateInstanceRequest(proto.Message): instance_id = proto.Field(proto.STRING, number=2) - instance = proto.Field(proto.MESSAGE, number=3, message="Instance",) + instance = proto.Field( + proto.MESSAGE, + number=3, + message="Instance", + ) class ListInstancesRequest(proto.Message): @@ -376,7 +398,11 @@ class ListInstancesResponse(proto.Message): def raw_page(self): return self - instances = proto.RepeatedField(proto.MESSAGE, number=1, message="Instance",) + instances = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Instance", + ) next_page_token = proto.Field(proto.STRING, number=2) @@ -401,9 +427,17 @@ class UpdateInstanceRequest(proto.Message): them. """ - instance = proto.Field(proto.MESSAGE, number=1, message="Instance",) + instance = proto.Field( + proto.MESSAGE, + number=1, + message="Instance", + ) - field_mask = proto.Field(proto.MESSAGE, number=2, message=gp_field_mask.FieldMask,) + field_mask = proto.Field( + proto.MESSAGE, + number=2, + message=gp_field_mask.FieldMask, + ) class DeleteInstanceRequest(proto.Message): @@ -440,13 +474,29 @@ class CreateInstanceMetadata(proto.Message): was completed successfully. """ - instance = proto.Field(proto.MESSAGE, number=1, message="Instance",) + instance = proto.Field( + proto.MESSAGE, + number=1, + message="Instance", + ) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp.Timestamp, + ) - cancel_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + cancel_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) - end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + end_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp.Timestamp, + ) class UpdateInstanceMetadata(proto.Message): @@ -470,13 +520,29 @@ class UpdateInstanceMetadata(proto.Message): was completed successfully. """ - instance = proto.Field(proto.MESSAGE, number=1, message="Instance",) + instance = proto.Field( + proto.MESSAGE, + number=1, + message="Instance", + ) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp.Timestamp, + ) - cancel_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + cancel_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) - end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + end_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_dbapi/connection.py b/google/cloud/spanner_dbapi/connection.py index a397028287..10022666dc 100644 --- a/google/cloud/spanner_dbapi/connection.py +++ b/google/cloud/spanner_dbapi/connection.py @@ -293,7 +293,9 @@ def run_statement(self, statement, retried=False): return ( transaction.execute_sql( - statement.sql, statement.params, param_types=statement.param_types, + statement.sql, + statement.params, + param_types=statement.param_types, ), ResultsChecksum() if retried else statement.checksum, ) diff --git a/google/cloud/spanner_dbapi/cursor.py b/google/cloud/spanner_dbapi/cursor.py index e2667f0599..e4680686cf 100644 --- a/google/cloud/spanner_dbapi/cursor.py +++ b/google/cloud/spanner_dbapi/cursor.py @@ -174,11 +174,15 @@ def execute(self, sql, args=None): sql, params = sql_pyformat_args_to_spanner(sql, args) statement = Statement( - sql, params, get_param_types(params), ResultsChecksum(), - ) - (self._result_set, self._checksum,) = self.connection.run_statement( - statement + sql, + params, + get_param_types(params), + ResultsChecksum(), ) + ( + self._result_set, + self._checksum, + ) = self.connection.run_statement(statement) self._itr = PeekIterator(self._result_set) return diff --git a/google/cloud/spanner_v1/backup.py b/google/cloud/spanner_v1/backup.py index 405a9e2be2..8cf580ab88 100644 --- a/google/cloud/spanner_v1/backup.py +++ b/google/cloud/spanner_v1/backup.py @@ -190,7 +190,10 @@ def create(self): raise ValueError("database not set") api = self._instance._client.database_admin_api metadata = _metadata_with_prefix(self.name) - backup = BackupPB(database=self._database, expire_time=self.expire_time,) + backup = BackupPB( + database=self._database, + expire_time=self.expire_time, + ) future = api.create_backup( parent=self._instance.name, @@ -240,7 +243,10 @@ def update_expire_time(self, new_expire_time): """ api = self._instance._client.database_admin_api metadata = _metadata_with_prefix(self.name) - backup_update = BackupPB(name=self.name, expire_time=new_expire_time,) + backup_update = BackupPB( + name=self.name, + expire_time=new_expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup( backup=backup_update, update_mask=update_mask, metadata=metadata diff --git a/google/cloud/spanner_v1/batch.py b/google/cloud/spanner_v1/batch.py index 27cd3c8b58..c28e4d10e4 100644 --- a/google/cloud/spanner_v1/batch.py +++ b/google/cloud/spanner_v1/batch.py @@ -119,8 +119,7 @@ def delete(self, table, keyset): class Batch(_BatchBase): - """Accumulate mutations for transmission during :meth:`commit`. - """ + """Accumulate mutations for transmission during :meth:`commit`.""" committed = None """Timestamp at which the batch was successfully committed.""" diff --git a/google/cloud/spanner_v1/database.py b/google/cloud/spanner_v1/database.py index c1c7953648..68a85d3fba 100644 --- a/google/cloud/spanner_v1/database.py +++ b/google/cloud/spanner_v1/database.py @@ -336,7 +336,9 @@ def update_ddl(self, ddl_statements, operation_id=""): metadata = _metadata_with_prefix(self.name) request = UpdateDatabaseDdlRequest( - database=self.name, statements=ddl_statements, operation_id=operation_id, + database=self.name, + statements=ddl_statements, + operation_id=operation_id, ) future = api.update_database_ddl(request=request, metadata=metadata) @@ -418,7 +420,9 @@ def execute_pdml(): query_options=query_options, ) restart = functools.partial( - api.execute_streaming_sql, request=request, metadata=metadata, + api.execute_streaming_sql, + request=request, + metadata=metadata, ) iterator = _restart_on_unavailable(restart) diff --git a/google/cloud/spanner_v1/instance.py b/google/cloud/spanner_v1/instance.py index be49dd2d84..ecd9461fbb 100644 --- a/google/cloud/spanner_v1/instance.py +++ b/google/cloud/spanner_v1/instance.py @@ -432,7 +432,9 @@ def list_backups(self, filter_="", page_size=None): """ metadata = _metadata_with_prefix(self.name) request = ListBackupsRequest( - parent=self.name, filter=filter_, page_size=page_size, + parent=self.name, + filter=filter_, + page_size=page_size, ) page_iter = self._client.database_admin_api.list_backups( request=request, metadata=metadata @@ -460,7 +462,9 @@ def list_backup_operations(self, filter_="", page_size=None): """ metadata = _metadata_with_prefix(self.name) request = ListBackupOperationsRequest( - parent=self.name, filter=filter_, page_size=page_size, + parent=self.name, + filter=filter_, + page_size=page_size, ) page_iter = self._client.database_admin_api.list_backup_operations( request=request, metadata=metadata @@ -488,7 +492,9 @@ def list_database_operations(self, filter_="", page_size=None): """ metadata = _metadata_with_prefix(self.name) request = ListDatabaseOperationsRequest( - parent=self.name, filter=filter_, page_size=page_size, + parent=self.name, + filter=filter_, + page_size=page_size, ) page_iter = self._client.database_admin_api.list_database_operations( request=request, metadata=metadata diff --git a/google/cloud/spanner_v1/services/spanner/async_client.py b/google/cloud/spanner_v1/services/spanner/async_client.py index ab84b7d885..47f113d76b 100644 --- a/google/cloud/spanner_v1/services/spanner/async_client.py +++ b/google/cloud/spanner_v1/services/spanner/async_client.py @@ -219,7 +219,9 @@ async def create_session( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -232,7 +234,12 @@ async def create_session( ) # 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 @@ -314,7 +321,9 @@ async def batch_create_sessions( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=60.0, client_info=DEFAULT_CLIENT_INFO, @@ -327,7 +336,12 @@ async def batch_create_sessions( ) # 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 @@ -392,7 +406,9 @@ async def get_session( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -405,7 +421,12 @@ async def get_session( ) # 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 @@ -473,7 +494,9 @@ async def list_sessions( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=3600.0, client_info=DEFAULT_CLIENT_INFO, @@ -486,12 +509,20 @@ async def list_sessions( ) # 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.ListSessionsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -553,7 +584,9 @@ async def delete_session( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -567,7 +600,10 @@ async def delete_session( # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def execute_sql( @@ -623,7 +659,9 @@ async def execute_sql( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -636,7 +674,12 @@ async def execute_sql( ) # 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 @@ -696,7 +739,12 @@ def execute_streaming_sql( ) # 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 @@ -789,7 +837,9 @@ async def execute_batch_dml( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -802,7 +852,12 @@ async def execute_batch_dml( ) # 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 @@ -861,7 +916,9 @@ async def read( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -874,7 +931,12 @@ async def read( ) # 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 @@ -934,7 +996,12 @@ def streaming_read( ) # 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 @@ -1010,7 +1077,9 @@ async def begin_transaction( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -1023,7 +1092,12 @@ async def 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 @@ -1136,7 +1210,9 @@ async def commit( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=3600.0, client_info=DEFAULT_CLIENT_INFO, @@ -1149,7 +1225,12 @@ async def 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 @@ -1226,7 +1307,9 @@ async def rollback( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -1240,7 +1323,10 @@ async def rollback( # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def partition_query( @@ -1297,7 +1383,9 @@ async def partition_query( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -1310,7 +1398,12 @@ async def 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, + ) # Done; return the response. return response @@ -1372,7 +1465,9 @@ async def partition_read( initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=DEFAULT_CLIENT_INFO, @@ -1385,7 +1480,12 @@ async def partition_read( ) # 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 @@ -1393,7 +1493,9 @@ async def partition_read( try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-spanner",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-spanner", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/spanner_v1/services/spanner/client.py b/google/cloud/spanner_v1/services/spanner/client.py index 50e4792b76..f9774e56c1 100644 --- a/google/cloud/spanner_v1/services/spanner/client.py +++ b/google/cloud/spanner_v1/services/spanner/client.py @@ -58,7 +58,10 @@ class SpannerClientMeta(type): _transport_registry["grpc"] = SpannerGrpcTransport _transport_registry["grpc_asyncio"] = SpannerGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[SpannerTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[SpannerTransport]: """Return an appropriate transport class. Args: @@ -147,10 +150,16 @@ def transport(self) -> SpannerTransport: return self._transport @staticmethod - def database_path(project: str, instance: str, database: str,) -> str: + def database_path( + project: str, + instance: str, + database: str, + ) -> str: """Return a fully-qualified database string.""" return "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) @staticmethod @@ -163,10 +172,18 @@ def parse_database_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def session_path(project: str, instance: str, database: str, session: str,) -> str: + def session_path( + project: str, + instance: str, + database: str, + session: str, + ) -> str: """Return a fully-qualified session string.""" return "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}".format( - project=project, instance=instance, database=database, session=session, + project=project, + instance=instance, + database=database, + session=session, ) @staticmethod @@ -179,7 +196,9 @@ def parse_session_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: """Return a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -192,9 +211,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: """Return 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]: @@ -203,9 +226,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: """Return 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]: @@ -214,9 +241,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: """Return 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]: @@ -225,10 +256,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: """Return a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -438,7 +473,12 @@ def create_session( ) # 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 @@ -528,7 +568,12 @@ def batch_create_sessions( ) # 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 @@ -601,7 +646,12 @@ def get_session( ) # 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 @@ -677,12 +727,20 @@ def list_sessions( ) # 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.ListSessionsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -753,7 +811,10 @@ def delete_session( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def execute_sql( @@ -817,7 +878,12 @@ def execute_sql( ) # 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 @@ -878,7 +944,12 @@ def execute_streaming_sql( ) # 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 @@ -979,7 +1050,12 @@ def execute_batch_dml( ) # 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 @@ -1046,7 +1122,12 @@ def read( ) # 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 @@ -1107,7 +1188,12 @@ def streaming_read( ) # 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 @@ -1191,7 +1277,12 @@ def 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 @@ -1312,7 +1403,12 @@ def 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 @@ -1398,7 +1494,10 @@ def rollback( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def partition_query( @@ -1463,7 +1562,12 @@ def partition_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 @@ -1533,7 +1637,12 @@ def partition_read( ) # 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 @@ -1541,7 +1650,9 @@ def partition_read( try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-spanner",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-spanner", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/spanner_v1/services/spanner/transports/base.py b/google/cloud/spanner_v1/services/spanner/transports/base.py index 36e3c0cb52..7ccf47100a 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/base.py +++ b/google/cloud/spanner_v1/services/spanner/transports/base.py @@ -33,7 +33,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-spanner",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-spanner", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -73,10 +75,10 @@ def __init__( scope (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. @@ -116,7 +118,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -127,7 +131,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=60.0, client_info=client_info, @@ -138,7 +144,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -149,7 +157,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=3600.0, client_info=client_info, @@ -160,7 +170,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -171,7 +183,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -187,7 +201,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -198,13 +214,17 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, ), self.streaming_read: gapic_v1.method.wrap_method( - self.streaming_read, default_timeout=3600.0, client_info=client_info, + self.streaming_read, + default_timeout=3600.0, + client_info=client_info, ), self.begin_transaction: gapic_v1.method.wrap_method( self.begin_transaction, @@ -212,7 +232,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -223,7 +245,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=3600.0, client_info=client_info, @@ -234,7 +258,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -245,7 +271,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, @@ -256,7 +284,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.25, maximum=32.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + exceptions.ServiceUnavailable, + ), ), default_timeout=30.0, client_info=client_info, diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc.py b/google/cloud/spanner_v1/services/spanner/transports/grpc.py index 620a971775..5ed1d06fa1 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/grpc.py +++ b/google/cloud/spanner_v1/services/spanner/transports/grpc.py @@ -226,8 +226,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/spanner_v1/services/spanner/transports/grpc_asyncio.py b/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py index 79ab4a1f94..9eeba9a049 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +++ b/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py @@ -139,10 +139,10 @@ def __init__( for grpc channel. It is ignored if ``channel`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: diff --git a/google/cloud/spanner_v1/session.py b/google/cloud/spanner_v1/session.py index 8b33221cf9..15a9cdfde5 100644 --- a/google/cloud/spanner_v1/session.py +++ b/google/cloud/spanner_v1/session.py @@ -123,7 +123,10 @@ def create(self): request.session.labels = self._labels with trace_call("CloudSpanner.CreateSession", self, self._labels): - session_pb = api.create_session(request=request, metadata=metadata,) + session_pb = api.create_session( + request=request, + metadata=metadata, + ) self._session_id = session_pb.name.split("/")[-1] def exists(self): diff --git a/google/cloud/spanner_v1/snapshot.py b/google/cloud/spanner_v1/snapshot.py index d417bfd1f1..52cc1942b0 100644 --- a/google/cloud/spanner_v1/snapshot.py +++ b/google/cloud/spanner_v1/snapshot.py @@ -163,7 +163,9 @@ def read(self, table, columns, keyset, index="", limit=0, partition=None): partition_token=partition, ) restart = functools.partial( - api.streaming_read, request=request, metadata=metadata, + api.streaming_read, + request=request, + metadata=metadata, ) trace_attributes = {"table_id": table, "columns": columns} @@ -357,7 +359,10 @@ def partition_read( with trace_call( "CloudSpanner.PartitionReadOnlyTransaction", self._session, trace_attributes ): - response = api.partition_read(request=request, metadata=metadata,) + response = api.partition_read( + request=request, + metadata=metadata, + ) return [partition.partition_token for partition in response.partitions] @@ -438,7 +443,10 @@ def partition_query( self._session, trace_attributes, ): - response = api.partition_query(request=request, metadata=metadata,) + response = api.partition_query( + request=request, + metadata=metadata, + ) return [partition.partition_token for partition in response.partitions] diff --git a/google/cloud/spanner_v1/streamed.py b/google/cloud/spanner_v1/streamed.py index a8b15a8f2b..a693a9ddba 100644 --- a/google/cloud/spanner_v1/streamed.py +++ b/google/cloud/spanner_v1/streamed.py @@ -202,7 +202,11 @@ class Unmergeable(ValueError): """ def __init__(self, lhs, rhs, type_): - message = "Cannot merge %s values: %s %s" % (TypeCode(type_.code), lhs, rhs,) + message = "Cannot merge %s values: %s %s" % ( + TypeCode(type_.code), + lhs, + rhs, + ) super(Unmergeable, self).__init__(message) diff --git a/google/cloud/spanner_v1/types/keys.py b/google/cloud/spanner_v1/types/keys.py index 342d14829c..3c7962307f 100644 --- a/google/cloud/spanner_v1/types/keys.py +++ b/google/cloud/spanner_v1/types/keys.py @@ -22,7 +22,11 @@ __protobuf__ = proto.module( - package="google.spanner.v1", manifest={"KeyRange", "KeySet",}, + package="google.spanner.v1", + manifest={ + "KeyRange", + "KeySet", + }, ) @@ -157,19 +161,31 @@ class KeyRange(proto.Message): """ start_closed = proto.Field( - proto.MESSAGE, number=1, oneof="start_key_type", message=struct.ListValue, + proto.MESSAGE, + number=1, + oneof="start_key_type", + message=struct.ListValue, ) start_open = proto.Field( - proto.MESSAGE, number=2, oneof="start_key_type", message=struct.ListValue, + proto.MESSAGE, + number=2, + oneof="start_key_type", + message=struct.ListValue, ) end_closed = proto.Field( - proto.MESSAGE, number=3, oneof="end_key_type", message=struct.ListValue, + proto.MESSAGE, + number=3, + oneof="end_key_type", + message=struct.ListValue, ) end_open = proto.Field( - proto.MESSAGE, number=4, oneof="end_key_type", message=struct.ListValue, + proto.MESSAGE, + number=4, + oneof="end_key_type", + message=struct.ListValue, ) @@ -200,9 +216,17 @@ class KeySet(proto.Message): only yielded once. """ - keys = proto.RepeatedField(proto.MESSAGE, number=1, message=struct.ListValue,) + keys = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=struct.ListValue, + ) - ranges = proto.RepeatedField(proto.MESSAGE, number=2, message="KeyRange",) + ranges = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="KeyRange", + ) all_ = proto.Field(proto.BOOL, number=3) diff --git a/google/cloud/spanner_v1/types/mutation.py b/google/cloud/spanner_v1/types/mutation.py index 5c22aae7ee..1ec4f6a99c 100644 --- a/google/cloud/spanner_v1/types/mutation.py +++ b/google/cloud/spanner_v1/types/mutation.py @@ -22,7 +22,12 @@ from google.protobuf import struct_pb2 as struct # type: ignore -__protobuf__ = proto.module(package="google.spanner.v1", manifest={"Mutation",},) +__protobuf__ = proto.module( + package="google.spanner.v1", + manifest={ + "Mutation", + }, +) class Mutation(proto.Message): @@ -106,7 +111,11 @@ class Write(proto.Message): columns = proto.RepeatedField(proto.STRING, number=2) - values = proto.RepeatedField(proto.MESSAGE, number=3, message=struct.ListValue,) + values = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=struct.ListValue, + ) class Delete(proto.Message): r"""Arguments to [delete][google.spanner.v1.Mutation.delete] operations. @@ -127,19 +136,46 @@ class Delete(proto.Message): table = proto.Field(proto.STRING, number=1) - key_set = proto.Field(proto.MESSAGE, number=2, message=keys.KeySet,) - - insert = proto.Field(proto.MESSAGE, number=1, oneof="operation", message=Write,) + key_set = proto.Field( + proto.MESSAGE, + number=2, + message=keys.KeySet, + ) + + insert = proto.Field( + proto.MESSAGE, + number=1, + oneof="operation", + message=Write, + ) - update = proto.Field(proto.MESSAGE, number=2, oneof="operation", message=Write,) + update = proto.Field( + proto.MESSAGE, + number=2, + oneof="operation", + message=Write, + ) insert_or_update = proto.Field( - proto.MESSAGE, number=3, oneof="operation", message=Write, + proto.MESSAGE, + number=3, + oneof="operation", + message=Write, ) - replace = proto.Field(proto.MESSAGE, number=4, oneof="operation", message=Write,) + replace = proto.Field( + proto.MESSAGE, + number=4, + oneof="operation", + message=Write, + ) - delete = proto.Field(proto.MESSAGE, number=5, oneof="operation", message=Delete,) + delete = proto.Field( + proto.MESSAGE, + number=5, + oneof="operation", + message=Delete, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/query_plan.py b/google/cloud/spanner_v1/types/query_plan.py index 5a0f8b5fbb..dcd17d1c84 100644 --- a/google/cloud/spanner_v1/types/query_plan.py +++ b/google/cloud/spanner_v1/types/query_plan.py @@ -22,7 +22,11 @@ __protobuf__ = proto.module( - package="google.spanner.v1", manifest={"PlanNode", "QueryPlan",}, + package="google.spanner.v1", + manifest={ + "PlanNode", + "QueryPlan", + }, ) @@ -132,19 +136,37 @@ class ShortRepresentation(proto.Message): index = proto.Field(proto.INT32, number=1) - kind = proto.Field(proto.ENUM, number=2, enum=Kind,) + kind = proto.Field( + proto.ENUM, + number=2, + enum=Kind, + ) display_name = proto.Field(proto.STRING, number=3) - child_links = proto.RepeatedField(proto.MESSAGE, number=4, message=ChildLink,) + child_links = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=ChildLink, + ) short_representation = proto.Field( - proto.MESSAGE, number=5, message=ShortRepresentation, + proto.MESSAGE, + number=5, + message=ShortRepresentation, ) - metadata = proto.Field(proto.MESSAGE, number=6, message=struct.Struct,) + metadata = proto.Field( + proto.MESSAGE, + number=6, + message=struct.Struct, + ) - execution_stats = proto.Field(proto.MESSAGE, number=7, message=struct.Struct,) + execution_stats = proto.Field( + proto.MESSAGE, + number=7, + message=struct.Struct, + ) class QueryPlan(proto.Message): @@ -159,7 +181,11 @@ class QueryPlan(proto.Message): to its index in ``plan_nodes``. """ - plan_nodes = proto.RepeatedField(proto.MESSAGE, number=1, message="PlanNode",) + plan_nodes = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PlanNode", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/result_set.py b/google/cloud/spanner_v1/types/result_set.py index 71b4dceac2..51dff206d6 100644 --- a/google/cloud/spanner_v1/types/result_set.py +++ b/google/cloud/spanner_v1/types/result_set.py @@ -26,7 +26,12 @@ __protobuf__ = proto.module( package="google.spanner.v1", - manifest={"ResultSet", "PartialResultSet", "ResultSetMetadata", "ResultSetStats",}, + manifest={ + "ResultSet", + "PartialResultSet", + "ResultSetMetadata", + "ResultSetStats", + }, ) @@ -58,11 +63,23 @@ class ResultSet(proto.Message): [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. """ - metadata = proto.Field(proto.MESSAGE, number=1, message="ResultSetMetadata",) + metadata = proto.Field( + proto.MESSAGE, + number=1, + message="ResultSetMetadata", + ) - rows = proto.RepeatedField(proto.MESSAGE, number=2, message=struct.ListValue,) + rows = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=struct.ListValue, + ) - stats = proto.Field(proto.MESSAGE, number=3, message="ResultSetStats",) + stats = proto.Field( + proto.MESSAGE, + number=3, + message="ResultSetStats", + ) class PartialResultSet(proto.Message): @@ -180,15 +197,27 @@ class PartialResultSet(proto.Message): statements. """ - metadata = proto.Field(proto.MESSAGE, number=1, message="ResultSetMetadata",) + metadata = proto.Field( + proto.MESSAGE, + number=1, + message="ResultSetMetadata", + ) - values = proto.RepeatedField(proto.MESSAGE, number=2, message=struct.Value,) + values = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=struct.Value, + ) chunked_value = proto.Field(proto.BOOL, number=3) resume_token = proto.Field(proto.BYTES, number=4) - stats = proto.Field(proto.MESSAGE, number=5, message="ResultSetStats",) + stats = proto.Field( + proto.MESSAGE, + number=5, + message="ResultSetStats", + ) class ResultSetMetadata(proto.Message): @@ -214,10 +243,16 @@ class ResultSetMetadata(proto.Message): transaction is yielded here. """ - row_type = proto.Field(proto.MESSAGE, number=1, message=gs_type.StructType,) + row_type = proto.Field( + proto.MESSAGE, + number=1, + message=gs_type.StructType, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.Transaction, + proto.MESSAGE, + number=2, + message=gs_transaction.Transaction, ) @@ -251,9 +286,17 @@ class ResultSetStats(proto.Message): rows modified. """ - query_plan = proto.Field(proto.MESSAGE, number=1, message=gs_query_plan.QueryPlan,) + query_plan = proto.Field( + proto.MESSAGE, + number=1, + message=gs_query_plan.QueryPlan, + ) - query_stats = proto.Field(proto.MESSAGE, number=2, message=struct.Struct,) + query_stats = proto.Field( + proto.MESSAGE, + number=2, + message=struct.Struct, + ) row_count_exact = proto.Field(proto.INT64, number=3, oneof="row_count") diff --git a/google/cloud/spanner_v1/types/spanner.py b/google/cloud/spanner_v1/types/spanner.py index eeffd2bde5..a6434161c5 100644 --- a/google/cloud/spanner_v1/types/spanner.py +++ b/google/cloud/spanner_v1/types/spanner.py @@ -70,7 +70,11 @@ class CreateSessionRequest(proto.Message): database = proto.Field(proto.STRING, number=1) - session = proto.Field(proto.MESSAGE, number=2, message="Session",) + session = proto.Field( + proto.MESSAGE, + number=2, + message="Session", + ) class BatchCreateSessionsRequest(proto.Message): @@ -96,7 +100,11 @@ class BatchCreateSessionsRequest(proto.Message): database = proto.Field(proto.STRING, number=1) - session_template = proto.Field(proto.MESSAGE, number=2, message="Session",) + session_template = proto.Field( + proto.MESSAGE, + number=2, + message="Session", + ) session_count = proto.Field(proto.INT32, number=3) @@ -110,7 +118,11 @@ class BatchCreateSessionsResponse(proto.Message): The freshly created sessions. """ - session = proto.RepeatedField(proto.MESSAGE, number=1, message="Session",) + session = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Session", + ) class Session(proto.Message): @@ -148,10 +160,16 @@ class Session(proto.Message): labels = proto.MapField(proto.STRING, proto.STRING, number=2) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp.Timestamp, + ) approximate_last_use_time = proto.Field( - proto.MESSAGE, number=4, message=timestamp.Timestamp, + proto.MESSAGE, + number=4, + message=timestamp.Timestamp, ) @@ -224,7 +242,11 @@ class ListSessionsResponse(proto.Message): def raw_page(self): return self - sessions = proto.RepeatedField(proto.MESSAGE, number=1, message="Session",) + sessions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Session", + ) next_page_token = proto.Field(proto.STRING, number=2) @@ -373,26 +395,43 @@ class QueryOptions(proto.Message): session = proto.Field(proto.STRING, number=1) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, ) sql = proto.Field(proto.STRING, number=3) - params = proto.Field(proto.MESSAGE, number=4, message=struct.Struct,) + params = proto.Field( + proto.MESSAGE, + number=4, + message=struct.Struct, + ) param_types = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message=gs_type.Type, + proto.STRING, + proto.MESSAGE, + number=5, + message=gs_type.Type, ) resume_token = proto.Field(proto.BYTES, number=6) - query_mode = proto.Field(proto.ENUM, number=7, enum=QueryMode,) + query_mode = proto.Field( + proto.ENUM, + number=7, + enum=QueryMode, + ) partition_token = proto.Field(proto.BYTES, number=8) seqno = proto.Field(proto.INT64, number=9) - query_options = proto.Field(proto.MESSAGE, number=10, message=QueryOptions,) + query_options = proto.Field( + proto.MESSAGE, + number=10, + message=QueryOptions, + ) class ExecuteBatchDmlRequest(proto.Message): @@ -473,19 +512,32 @@ class Statement(proto.Message): sql = proto.Field(proto.STRING, number=1) - params = proto.Field(proto.MESSAGE, number=2, message=struct.Struct,) + params = proto.Field( + proto.MESSAGE, + number=2, + message=struct.Struct, + ) param_types = proto.MapField( - proto.STRING, proto.MESSAGE, number=3, message=gs_type.Type, + proto.STRING, + proto.MESSAGE, + number=3, + message=gs_type.Type, ) session = proto.Field(proto.STRING, number=1) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, ) - statements = proto.RepeatedField(proto.MESSAGE, number=3, message=Statement,) + statements = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=Statement, + ) seqno = proto.Field(proto.INT64, number=4) @@ -546,10 +598,16 @@ class ExecuteBatchDmlResponse(proto.Message): """ result_sets = proto.RepeatedField( - proto.MESSAGE, number=1, message=result_set.ResultSet, + proto.MESSAGE, + number=1, + message=result_set.ResultSet, ) - status = proto.Field(proto.MESSAGE, number=2, message=gr_status.Status,) + status = proto.Field( + proto.MESSAGE, + number=2, + message=gr_status.Status, + ) class PartitionOptions(proto.Message): @@ -644,19 +702,30 @@ class PartitionQueryRequest(proto.Message): session = proto.Field(proto.STRING, number=1) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, ) sql = proto.Field(proto.STRING, number=3) - params = proto.Field(proto.MESSAGE, number=4, message=struct.Struct,) + params = proto.Field( + proto.MESSAGE, + number=4, + message=struct.Struct, + ) param_types = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message=gs_type.Type, + proto.STRING, + proto.MESSAGE, + number=5, + message=gs_type.Type, ) partition_options = proto.Field( - proto.MESSAGE, number=6, message="PartitionOptions", + proto.MESSAGE, + number=6, + message="PartitionOptions", ) @@ -712,7 +781,9 @@ class PartitionReadRequest(proto.Message): session = proto.Field(proto.STRING, number=1) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, ) table = proto.Field(proto.STRING, number=3) @@ -721,10 +792,16 @@ class PartitionReadRequest(proto.Message): columns = proto.RepeatedField(proto.STRING, number=5) - key_set = proto.Field(proto.MESSAGE, number=6, message=keys.KeySet,) + key_set = proto.Field( + proto.MESSAGE, + number=6, + message=keys.KeySet, + ) partition_options = proto.Field( - proto.MESSAGE, number=9, message="PartitionOptions", + proto.MESSAGE, + number=9, + message="PartitionOptions", ) @@ -756,10 +833,16 @@ class PartitionResponse(proto.Message): Transaction created by this request. """ - partitions = proto.RepeatedField(proto.MESSAGE, number=1, message="Partition",) + partitions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Partition", + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.Transaction, + proto.MESSAGE, + number=2, + message=gs_transaction.Transaction, ) @@ -838,7 +921,9 @@ class ReadRequest(proto.Message): session = proto.Field(proto.STRING, number=1) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, ) table = proto.Field(proto.STRING, number=3) @@ -847,7 +932,11 @@ class ReadRequest(proto.Message): columns = proto.RepeatedField(proto.STRING, number=5) - key_set = proto.Field(proto.MESSAGE, number=6, message=keys.KeySet,) + key_set = proto.Field( + proto.MESSAGE, + number=6, + message=keys.KeySet, + ) limit = proto.Field(proto.INT64, number=8) @@ -871,7 +960,9 @@ class BeginTransactionRequest(proto.Message): session = proto.Field(proto.STRING, number=1) options = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionOptions, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionOptions, ) @@ -912,7 +1003,11 @@ class CommitRequest(proto.Message): message=gs_transaction.TransactionOptions, ) - mutations = proto.RepeatedField(proto.MESSAGE, number=4, message=mutation.Mutation,) + mutations = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=mutation.Mutation, + ) class CommitResponse(proto.Message): @@ -925,7 +1020,9 @@ class CommitResponse(proto.Message): """ commit_timestamp = proto.Field( - proto.MESSAGE, number=1, message=timestamp.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp.Timestamp, ) diff --git a/google/cloud/spanner_v1/types/transaction.py b/google/cloud/spanner_v1/types/transaction.py index 7b50f228e5..ba7bc1e3bd 100644 --- a/google/cloud/spanner_v1/types/transaction.py +++ b/google/cloud/spanner_v1/types/transaction.py @@ -24,7 +24,11 @@ __protobuf__ = proto.module( package="google.spanner.v1", - manifest={"TransactionOptions", "Transaction", "TransactionSelector",}, + manifest={ + "TransactionOptions", + "Transaction", + "TransactionSelector", + }, ) @@ -140,7 +144,10 @@ class ReadOnly(proto.Message): ) max_staleness = proto.Field( - proto.MESSAGE, number=3, oneof="timestamp_bound", message=duration.Duration, + proto.MESSAGE, + number=3, + oneof="timestamp_bound", + message=duration.Duration, ) read_timestamp = proto.Field( @@ -151,18 +158,34 @@ class ReadOnly(proto.Message): ) exact_staleness = proto.Field( - proto.MESSAGE, number=5, oneof="timestamp_bound", message=duration.Duration, + proto.MESSAGE, + number=5, + oneof="timestamp_bound", + message=duration.Duration, ) return_read_timestamp = proto.Field(proto.BOOL, number=6) - read_write = proto.Field(proto.MESSAGE, number=1, oneof="mode", message=ReadWrite,) + read_write = proto.Field( + proto.MESSAGE, + number=1, + oneof="mode", + message=ReadWrite, + ) partitioned_dml = proto.Field( - proto.MESSAGE, number=3, oneof="mode", message=PartitionedDml, + proto.MESSAGE, + number=3, + oneof="mode", + message=PartitionedDml, ) - read_only = proto.Field(proto.MESSAGE, number=2, oneof="mode", message=ReadOnly,) + read_only = proto.Field( + proto.MESSAGE, + number=2, + oneof="mode", + message=ReadOnly, + ) class Transaction(proto.Message): @@ -189,7 +212,11 @@ class Transaction(proto.Message): id = proto.Field(proto.BYTES, number=1) - read_timestamp = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) + read_timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp.Timestamp, + ) class TransactionSelector(proto.Message): @@ -218,13 +245,19 @@ class TransactionSelector(proto.Message): """ single_use = proto.Field( - proto.MESSAGE, number=1, oneof="selector", message="TransactionOptions", + proto.MESSAGE, + number=1, + oneof="selector", + message="TransactionOptions", ) id = proto.Field(proto.BYTES, number=2, oneof="selector") begin = proto.Field( - proto.MESSAGE, number=3, oneof="selector", message="TransactionOptions", + proto.MESSAGE, + number=3, + oneof="selector", + message="TransactionOptions", ) diff --git a/google/cloud/spanner_v1/types/type.py b/google/cloud/spanner_v1/types/type.py index 19a0ffe5be..29857d73f0 100644 --- a/google/cloud/spanner_v1/types/type.py +++ b/google/cloud/spanner_v1/types/type.py @@ -19,7 +19,12 @@ __protobuf__ = proto.module( - package="google.spanner.v1", manifest={"TypeCode", "Type", "StructType",}, + package="google.spanner.v1", + manifest={ + "TypeCode", + "Type", + "StructType", + }, ) @@ -64,11 +69,23 @@ class Type(proto.Message): fields. """ - code = proto.Field(proto.ENUM, number=1, enum="TypeCode",) + code = proto.Field( + proto.ENUM, + number=1, + enum="TypeCode", + ) - array_element_type = proto.Field(proto.MESSAGE, number=2, message="Type",) + array_element_type = proto.Field( + proto.MESSAGE, + number=2, + message="Type", + ) - struct_type = proto.Field(proto.MESSAGE, number=3, message="StructType",) + struct_type = proto.Field( + proto.MESSAGE, + number=3, + message="StructType", + ) class StructType(proto.Message): @@ -105,9 +122,17 @@ class Field(proto.Message): name = proto.Field(proto.STRING, number=1) - type_ = proto.Field(proto.MESSAGE, number=2, message="Type",) - - fields = proto.RepeatedField(proto.MESSAGE, number=1, message=Field,) + type_ = proto.Field( + proto.MESSAGE, + number=2, + message="Type", + ) + + fields = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=Field, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 1a6227824a..2f1b0f1b98 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,7 +23,8 @@ import nox -BLACK_VERSION = "black==19.10b0" +# This is the last version to support Python 2.7 +BLACK_VERSION = "black==21.12b0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -38,14 +39,16 @@ def lint(session): Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.install("flake8", BLACK_VERSION) + session.install("flake8", BLACK_VERSION, "click<8.1") session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") -@nox.session(python="3.6") +@nox.session(python=DEFAULT_PYTHON_VERSION) def blacken(session): """Run black. @@ -55,9 +58,10 @@ def blacken(session): That run uses an image that doesn't have 3.6 installed. Before updating this check the state of the `gcp_ubuntu_config` we use for that Kokoro run. """ - session.install(BLACK_VERSION) + session.install(BLACK_VERSION, "click<8.1") session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) @@ -72,7 +76,7 @@ def default(session): # Install all test dependencies, then install this package in-place. session.install("asyncmock", "pytest-asyncio") - session.install("mock", "pytest", "pytest-cov") + session.install("mock", "pytest", "pytest-cov", "pytz") session.install("-e", ".") # Run py.test against the unit tests. @@ -143,7 +147,10 @@ def system(session): # Install all test dependencies, then install this package into the # virtualenv's dist-packages. session.install( - "mock", "pytest", "google-cloud-testutils", + "mock", + "pytest", + "google-cloud-testutils", + "pytz", ) session.install("-e", ".[tracing]") @@ -194,9 +201,9 @@ def docfx(session): """Build the docfx yaml files for this library.""" session.install("-e", ".[tracing]") - # sphinx-docfx-yaml supports up to sphinx version 1.5.5. - # https://github.com/docascode/sphinx-docfx-yaml/issues/97 - session.install("sphinx==1.5.5", "alabaster", "recommonmark", "sphinx-docfx-yaml") + session.install( + "sphinx==4.0.1", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml" + ) shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( diff --git a/setup.py b/setup.py index 87f3e26874..2f1dc0fbfd 100644 --- a/setup.py +++ b/setup.py @@ -22,15 +22,15 @@ name = "google-cloud-spanner" description = "Cloud Spanner API client library" -version = "2.1.0" +version = "2.1.1" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' # 'Development Status :: 5 - Production/Stable' release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - "google-api-core[grpc] >= 1.22.0, < 2.0.0dev", - "google-cloud-core >= 1.4.1, < 2.0dev", + "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", + "google-cloud-core >= 1.4.1, < 3.0dev", "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", "libcst >= 0.2.5", "proto-plus == 1.11.0", diff --git a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py index ea79f63e86..e985fb42b6 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py +++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py @@ -390,7 +390,9 @@ def test_database_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) @@ -458,7 +460,8 @@ def test_list_databases( transport: str = "grpc", request_type=spanner_database_admin.ListDatabasesRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -497,7 +500,8 @@ async def test_list_databases_async( request_type=spanner_database_admin.ListDatabasesRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -533,7 +537,9 @@ async def test_list_databases_async_from_dict(): def test_list_databases_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -553,12 +559,17 @@ 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 async def test_list_databases_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -580,11 +591,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 = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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: @@ -593,7 +609,9 @@ def test_list_databases_flattened(): # 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. @@ -604,19 +622,24 @@ def test_list_databases_flattened(): def test_list_databases_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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( - spanner_database_admin.ListDatabasesRequest(), parent="parent_value", + spanner_database_admin.ListDatabasesRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_databases_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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: @@ -628,7 +651,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. @@ -640,18 +665,23 @@ async def test_list_databases_flattened_async(): @pytest.mark.asyncio async def test_list_databases_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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_databases( - spanner_database_admin.ListDatabasesRequest(), parent="parent_value", + spanner_database_admin.ListDatabasesRequest(), + parent="parent_value", ) def test_list_databases_pager(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=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: @@ -666,10 +696,14 @@ def test_list_databases_pager(): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -694,7 +728,9 @@ def test_list_databases_pager(): def test_list_databases_pages(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=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: @@ -709,10 +745,14 @@ def test_list_databases_pages(): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -729,7 +769,9 @@ def test_list_databases_pages(): @pytest.mark.asyncio async def test_list_databases_async_pager(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -746,10 +788,14 @@ async def test_list_databases_async_pager(): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -759,7 +805,9 @@ async def test_list_databases_async_pager(): ), RuntimeError, ) - async_pager = await client.list_databases(request={},) + async_pager = await client.list_databases( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -771,7 +819,9 @@ async def test_list_databases_async_pager(): @pytest.mark.asyncio async def test_list_databases_async_pages(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -788,10 +838,14 @@ async def test_list_databases_async_pages(): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -812,7 +866,8 @@ def test_create_database( transport: str = "grpc", request_type=spanner_database_admin.CreateDatabaseRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -846,7 +901,8 @@ async def test_create_database_async( request_type=spanner_database_admin.CreateDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -878,7 +934,9 @@ async def test_create_database_async_from_dict(): def test_create_database_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -898,12 +956,17 @@ def test_create_database_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_database_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -925,11 +988,16 @@ async def test_create_database_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_database_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_database), "__call__") as call: @@ -939,7 +1007,8 @@ def test_create_database_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_database( - parent="parent_value", create_statement="create_statement_value", + parent="parent_value", + create_statement="create_statement_value", ) # Establish that the underlying call was made with the expected @@ -953,7 +1022,9 @@ def test_create_database_flattened(): def test_create_database_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -967,7 +1038,9 @@ def test_create_database_flattened_error(): @pytest.mark.asyncio async def test_create_database_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_database), "__call__") as call: @@ -980,7 +1053,8 @@ async def test_create_database_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_database( - parent="parent_value", create_statement="create_statement_value", + parent="parent_value", + create_statement="create_statement_value", ) # Establish that the underlying call was made with the expected @@ -995,7 +1069,9 @@ async def test_create_database_flattened_async(): @pytest.mark.asyncio async def test_create_database_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1011,7 +1087,8 @@ def test_get_database( transport: str = "grpc", request_type=spanner_database_admin.GetDatabaseRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1022,7 +1099,8 @@ def test_get_database( with mock.patch.object(type(client.transport.get_database), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = spanner_database_admin.Database( - name="name_value", state=spanner_database_admin.Database.State.CREATING, + name="name_value", + state=spanner_database_admin.Database.State.CREATING, ) response = client.get_database(request) @@ -1052,7 +1130,8 @@ async def test_get_database_async( request_type=spanner_database_admin.GetDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1064,7 +1143,8 @@ async def test_get_database_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( spanner_database_admin.Database( - name="name_value", state=spanner_database_admin.Database.State.CREATING, + name="name_value", + state=spanner_database_admin.Database.State.CREATING, ) ) @@ -1090,7 +1170,9 @@ async def test_get_database_async_from_dict(): def test_get_database_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -1110,12 +1192,17 @@ 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 async def test_get_database_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -1137,11 +1224,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 = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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: @@ -1150,7 +1242,9 @@ def test_get_database_flattened(): # 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. @@ -1161,19 +1255,24 @@ def test_get_database_flattened(): def test_get_database_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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( - spanner_database_admin.GetDatabaseRequest(), name="name_value", + spanner_database_admin.GetDatabaseRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_database_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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: @@ -1185,7 +1284,9 @@ async def test_get_database_flattened_async(): ) # 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. @@ -1197,13 +1298,16 @@ async def test_get_database_flattened_async(): @pytest.mark.asyncio async def test_get_database_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_database( - spanner_database_admin.GetDatabaseRequest(), name="name_value", + spanner_database_admin.GetDatabaseRequest(), + name="name_value", ) @@ -1212,7 +1316,8 @@ def test_update_database_ddl( request_type=spanner_database_admin.UpdateDatabaseDdlRequest, ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1248,7 +1353,8 @@ async def test_update_database_ddl_async( request_type=spanner_database_admin.UpdateDatabaseDdlRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1282,7 +1388,9 @@ async def test_update_database_ddl_async_from_dict(): def test_update_database_ddl_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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,12 +1412,17 @@ def test_update_database_ddl_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_update_database_ddl_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -1333,11 +1446,16 @@ async def test_update_database_ddl_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_update_database_ddl_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1349,7 +1467,8 @@ def test_update_database_ddl_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_database_ddl( - database="database_value", statements=["statements_value"], + database="database_value", + statements=["statements_value"], ) # Establish that the underlying call was made with the expected @@ -1363,7 +1482,9 @@ def test_update_database_ddl_flattened(): def test_update_database_ddl_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1377,7 +1498,9 @@ def test_update_database_ddl_flattened_error(): @pytest.mark.asyncio async def test_update_database_ddl_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1392,7 +1515,8 @@ async def test_update_database_ddl_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_database_ddl( - database="database_value", statements=["statements_value"], + database="database_value", + statements=["statements_value"], ) # Establish that the underlying call was made with the expected @@ -1407,7 +1531,9 @@ async def test_update_database_ddl_flattened_async(): @pytest.mark.asyncio async def test_update_database_ddl_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1423,7 +1549,8 @@ def test_drop_database( transport: str = "grpc", request_type=spanner_database_admin.DropDatabaseRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1457,7 +1584,8 @@ async def test_drop_database_async( request_type=spanner_database_admin.DropDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1487,7 +1615,9 @@ async def test_drop_database_async_from_dict(): def test_drop_database_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -1507,12 +1637,17 @@ def test_drop_database_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_drop_database_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -1532,11 +1667,16 @@ async def test_drop_database_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_drop_database_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.drop_database), "__call__") as call: @@ -1545,7 +1685,9 @@ def test_drop_database_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.drop_database(database="database_value",) + client.drop_database( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1556,19 +1698,24 @@ def test_drop_database_flattened(): def test_drop_database_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.drop_database( - spanner_database_admin.DropDatabaseRequest(), database="database_value", + spanner_database_admin.DropDatabaseRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_drop_database_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.drop_database), "__call__") as call: @@ -1578,7 +1725,9 @@ async def test_drop_database_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.drop_database(database="database_value",) + response = await client.drop_database( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1590,13 +1739,16 @@ async def test_drop_database_flattened_async(): @pytest.mark.asyncio async def test_drop_database_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.drop_database( - spanner_database_admin.DropDatabaseRequest(), database="database_value", + spanner_database_admin.DropDatabaseRequest(), + database="database_value", ) @@ -1604,7 +1756,8 @@ def test_get_database_ddl( transport: str = "grpc", request_type=spanner_database_admin.GetDatabaseDdlRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1643,7 +1796,8 @@ async def test_get_database_ddl_async( request_type=spanner_database_admin.GetDatabaseDdlRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1679,7 +1833,9 @@ async def test_get_database_ddl_async_from_dict(): def test_get_database_ddl_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -1699,12 +1855,17 @@ def test_get_database_ddl_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_get_database_ddl_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -1726,11 +1887,16 @@ async def test_get_database_ddl_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_get_database_ddl_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database_ddl), "__call__") as call: @@ -1739,7 +1905,9 @@ def test_get_database_ddl_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_database_ddl(database="database_value",) + client.get_database_ddl( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1750,19 +1918,24 @@ def test_get_database_ddl_flattened(): def test_get_database_ddl_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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_ddl( - spanner_database_admin.GetDatabaseDdlRequest(), database="database_value", + spanner_database_admin.GetDatabaseDdlRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_get_database_ddl_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database_ddl), "__call__") as call: @@ -1774,7 +1947,9 @@ async def test_get_database_ddl_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_database_ddl(database="database_value",) + response = await client.get_database_ddl( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1786,13 +1961,16 @@ async def test_get_database_ddl_flattened_async(): @pytest.mark.asyncio async def test_get_database_ddl_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_database_ddl( - spanner_database_admin.GetDatabaseDdlRequest(), database="database_value", + spanner_database_admin.GetDatabaseDdlRequest(), + database="database_value", ) @@ -1800,7 +1978,8 @@ def test_set_iam_policy( transport: str = "grpc", request_type=iam_policy.SetIamPolicyRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1810,7 +1989,10 @@ def test_set_iam_policy( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) @@ -1838,7 +2020,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1849,7 +2032,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy.Policy(version=774, etag=b"etag_blob",) + policy.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -1874,7 +2060,9 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -1894,12 +2082,17 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -1919,11 +2112,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -1939,7 +2137,9 @@ def test_set_iam_policy_from_dict_foreign(): def test_set_iam_policy_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -1948,7 +2148,9 @@ def test_set_iam_policy_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1959,19 +2161,24 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy.SetIamPolicyRequest(), resource="resource_value", + iam_policy.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_set_iam_policy_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -1981,7 +2188,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1993,13 +2202,16 @@ async def test_set_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_set_iam_policy_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy.SetIamPolicyRequest(), resource="resource_value", + iam_policy.SetIamPolicyRequest(), + resource="resource_value", ) @@ -2007,7 +2219,8 @@ def test_get_iam_policy( transport: str = "grpc", request_type=iam_policy.GetIamPolicyRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2017,7 +2230,10 @@ def test_get_iam_policy( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) @@ -2045,7 +2261,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2056,7 +2273,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy.Policy(version=774, etag=b"etag_blob",) + policy.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2081,7 +2301,9 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -2101,12 +2323,17 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -2126,11 +2353,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2146,7 +2378,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2155,7 +2389,9 @@ def test_get_iam_policy_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2166,19 +2402,24 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy.GetIamPolicyRequest(), resource="resource_value", + iam_policy.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_get_iam_policy_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2188,7 +2429,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2200,13 +2443,16 @@ async def test_get_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_get_iam_policy_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy.GetIamPolicyRequest(), resource="resource_value", + iam_policy.GetIamPolicyRequest(), + resource="resource_value", ) @@ -2214,7 +2460,8 @@ def test_test_iam_permissions( transport: str = "grpc", request_type=iam_policy.TestIamPermissionsRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2254,7 +2501,8 @@ async def test_test_iam_permissions_async( transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2267,7 +2515,9 @@ async def test_test_iam_permissions_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy.TestIamPermissionsResponse(permissions=["permissions_value"],) + iam_policy.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) ) response = await client.test_iam_permissions(request) @@ -2290,7 +2540,9 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -2312,12 +2564,17 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -2341,11 +2598,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2363,7 +2625,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2375,7 +2639,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2389,7 +2654,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2403,7 +2670,9 @@ def test_test_iam_permissions_flattened_error(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2418,7 +2687,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2433,7 +2703,9 @@ async def test_test_iam_permissions_flattened_async(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2449,7 +2721,8 @@ def test_create_backup( transport: str = "grpc", request_type=gsad_backup.CreateBackupRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2482,7 +2755,8 @@ async def test_create_backup_async( transport: str = "grpc_asyncio", request_type=gsad_backup.CreateBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2514,7 +2788,9 @@ async def test_create_backup_async_from_dict(): def test_create_backup_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -2534,12 +2810,17 @@ def test_create_backup_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_backup_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -2561,11 +2842,16 @@ async def test_create_backup_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_backup_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_backup), "__call__") as call: @@ -2593,7 +2879,9 @@ def test_create_backup_flattened(): def test_create_backup_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2608,7 +2896,9 @@ def test_create_backup_flattened_error(): @pytest.mark.asyncio async def test_create_backup_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_backup), "__call__") as call: @@ -2640,7 +2930,9 @@ async def test_create_backup_flattened_async(): @pytest.mark.asyncio async def test_create_backup_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2655,7 +2947,8 @@ async def test_create_backup_flattened_error_async(): def test_get_backup(transport: str = "grpc", request_type=backup.GetBackupRequest): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2705,7 +2998,8 @@ async def test_get_backup_async( transport: str = "grpc_asyncio", request_type=backup.GetBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2753,7 +3047,9 @@ async def test_get_backup_async_from_dict(): def test_get_backup_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -2773,12 +3069,17 @@ def test_get_backup_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_backup_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -2798,11 +3099,16 @@ async def test_get_backup_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_backup_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_backup), "__call__") as call: @@ -2811,7 +3117,9 @@ def test_get_backup_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_backup(name="name_value",) + client.get_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2822,19 +3130,24 @@ def test_get_backup_flattened(): def test_get_backup_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_backup( - backup.GetBackupRequest(), name="name_value", + backup.GetBackupRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_backup_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_backup), "__call__") as call: @@ -2844,7 +3157,9 @@ async def test_get_backup_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_backup(name="name_value",) + response = await client.get_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2856,13 +3171,16 @@ async def test_get_backup_flattened_async(): @pytest.mark.asyncio async def test_get_backup_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_backup( - backup.GetBackupRequest(), name="name_value", + backup.GetBackupRequest(), + name="name_value", ) @@ -2870,7 +3188,8 @@ def test_update_backup( transport: str = "grpc", request_type=gsad_backup.UpdateBackupRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2920,7 +3239,8 @@ async def test_update_backup_async( transport: str = "grpc_asyncio", request_type=gsad_backup.UpdateBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2968,7 +3288,9 @@ async def test_update_backup_async_from_dict(): def test_update_backup_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -2988,12 +3310,17 @@ def test_update_backup_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "backup.name=backup.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "backup.name=backup.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_backup_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -3013,11 +3340,16 @@ async def test_update_backup_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "backup.name=backup.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "backup.name=backup.name/value", + ) in kw["metadata"] def test_update_backup_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_backup), "__call__") as call: @@ -3042,7 +3374,9 @@ def test_update_backup_flattened(): def test_update_backup_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3056,7 +3390,9 @@ def test_update_backup_flattened_error(): @pytest.mark.asyncio async def test_update_backup_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_backup), "__call__") as call: @@ -3083,7 +3419,9 @@ async def test_update_backup_flattened_async(): @pytest.mark.asyncio async def test_update_backup_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3099,7 +3437,8 @@ def test_delete_backup( transport: str = "grpc", request_type=backup.DeleteBackupRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3132,7 +3471,8 @@ async def test_delete_backup_async( transport: str = "grpc_asyncio", request_type=backup.DeleteBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3162,7 +3502,9 @@ async def test_delete_backup_async_from_dict(): def test_delete_backup_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -3182,12 +3524,17 @@ def test_delete_backup_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_backup_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -3207,11 +3554,16 @@ async def test_delete_backup_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_backup_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_backup), "__call__") as call: @@ -3220,7 +3572,9 @@ def test_delete_backup_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_backup(name="name_value",) + client.delete_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3231,19 +3585,24 @@ def test_delete_backup_flattened(): def test_delete_backup_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_backup( - backup.DeleteBackupRequest(), name="name_value", + backup.DeleteBackupRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_backup_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_backup), "__call__") as call: @@ -3253,7 +3612,9 @@ async def test_delete_backup_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_backup(name="name_value",) + response = await client.delete_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3265,19 +3626,23 @@ async def test_delete_backup_flattened_async(): @pytest.mark.asyncio async def test_delete_backup_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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_backup( - backup.DeleteBackupRequest(), name="name_value", + backup.DeleteBackupRequest(), + name="name_value", ) def test_list_backups(transport: str = "grpc", request_type=backup.ListBackupsRequest): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3315,7 +3680,8 @@ async def test_list_backups_async( transport: str = "grpc_asyncio", request_type=backup.ListBackupsRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3326,7 +3692,9 @@ async def test_list_backups_async( with mock.patch.object(type(client.transport.list_backups), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - backup.ListBackupsResponse(next_page_token="next_page_token_value",) + backup.ListBackupsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_backups(request) @@ -3349,7 +3717,9 @@ async def test_list_backups_async_from_dict(): def test_list_backups_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -3369,12 +3739,17 @@ def test_list_backups_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_backups_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -3396,11 +3771,16 @@ async def test_list_backups_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_backups_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_backups), "__call__") as call: @@ -3409,7 +3789,9 @@ def test_list_backups_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_backups(parent="parent_value",) + client.list_backups( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3420,19 +3802,24 @@ def test_list_backups_flattened(): def test_list_backups_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_backups( - backup.ListBackupsRequest(), parent="parent_value", + backup.ListBackupsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_backups_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_backups), "__call__") as call: @@ -3444,7 +3831,9 @@ async def test_list_backups_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_backups(parent="parent_value",) + response = await client.list_backups( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3456,32 +3845,52 @@ async def test_list_backups_flattened_async(): @pytest.mark.asyncio async def test_list_backups_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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_backups( - backup.ListBackupsRequest(), parent="parent_value", + backup.ListBackupsRequest(), + parent="parent_value", ) def test_list_backups_pager(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_backups), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], next_page_token="abc", ), - backup.ListBackupsResponse(backups=[], next_page_token="def",), backup.ListBackupsResponse( - backups=[backup.Backup(),], next_page_token="ghi", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) @@ -3499,21 +3908,38 @@ def test_list_backups_pager(): def test_list_backups_pages(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_backups), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], next_page_token="abc", ), - backup.ListBackupsResponse(backups=[], next_page_token="def",), backup.ListBackupsResponse( - backups=[backup.Backup(),], next_page_token="ghi", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) pages = list(client.list_backups(request={}).pages) @@ -3523,7 +3949,9 @@ def test_list_backups_pages(): @pytest.mark.asyncio async def test_list_backups_async_pager(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3532,17 +3960,34 @@ async def test_list_backups_async_pager(): # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], next_page_token="abc", ), - backup.ListBackupsResponse(backups=[], next_page_token="def",), backup.ListBackupsResponse( - backups=[backup.Backup(),], next_page_token="ghi", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) - async_pager = await client.list_backups(request={},) + async_pager = await client.list_backups( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -3554,7 +3999,9 @@ async def test_list_backups_async_pager(): @pytest.mark.asyncio async def test_list_backups_async_pages(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3563,14 +4010,29 @@ async def test_list_backups_async_pages(): # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], next_page_token="abc", ), - backup.ListBackupsResponse(backups=[], next_page_token="def",), backup.ListBackupsResponse( - backups=[backup.Backup(),], next_page_token="ghi", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) pages = [] @@ -3584,7 +4046,8 @@ def test_restore_database( transport: str = "grpc", request_type=spanner_database_admin.RestoreDatabaseRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3618,7 +4081,8 @@ async def test_restore_database_async( request_type=spanner_database_admin.RestoreDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3650,7 +4114,9 @@ async def test_restore_database_async_from_dict(): def test_restore_database_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -3670,12 +4136,17 @@ def test_restore_database_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_restore_database_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -3697,11 +4168,16 @@ async def test_restore_database_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_restore_database_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.restore_database), "__call__") as call: @@ -3729,7 +4205,9 @@ def test_restore_database_flattened(): def test_restore_database_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3744,7 +4222,9 @@ def test_restore_database_flattened_error(): @pytest.mark.asyncio async def test_restore_database_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.restore_database), "__call__") as call: @@ -3776,7 +4256,9 @@ async def test_restore_database_flattened_async(): @pytest.mark.asyncio async def test_restore_database_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3794,7 +4276,8 @@ def test_list_database_operations( request_type=spanner_database_admin.ListDatabaseOperationsRequest, ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3835,7 +4318,8 @@ async def test_list_database_operations_async( request_type=spanner_database_admin.ListDatabaseOperationsRequest, ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3873,7 +4357,9 @@ async def test_list_database_operations_async_from_dict(): def test_list_database_operations_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -3895,12 +4381,17 @@ def test_list_database_operations_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_database_operations_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -3924,11 +4415,16 @@ async def test_list_database_operations_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_database_operations_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3939,7 +4435,9 @@ def test_list_database_operations_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_database_operations(parent="parent_value",) + client.list_database_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3950,7 +4448,9 @@ def test_list_database_operations_flattened(): def test_list_database_operations_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3963,7 +4463,9 @@ def test_list_database_operations_flattened_error(): @pytest.mark.asyncio async def test_list_database_operations_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3977,7 +4479,9 @@ async def test_list_database_operations_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_database_operations(parent="parent_value",) + response = await client.list_database_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3989,7 +4493,9 @@ async def test_list_database_operations_flattened_async(): @pytest.mark.asyncio async def test_list_database_operations_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4001,7 +4507,9 @@ async def test_list_database_operations_flattened_error_async(): def test_list_database_operations_pager(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4018,13 +4526,20 @@ def test_list_database_operations_pager(): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) @@ -4043,7 +4558,9 @@ def test_list_database_operations_pager(): def test_list_database_operations_pages(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4060,13 +4577,20 @@ def test_list_database_operations_pages(): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) @@ -4077,7 +4601,9 @@ def test_list_database_operations_pages(): @pytest.mark.asyncio async def test_list_database_operations_async_pager(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4096,17 +4622,26 @@ async def test_list_database_operations_async_pager(): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) - async_pager = await client.list_database_operations(request={},) + async_pager = await client.list_database_operations( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -4118,7 +4653,9 @@ async def test_list_database_operations_async_pager(): @pytest.mark.asyncio async def test_list_database_operations_async_pages(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4137,13 +4674,20 @@ async def test_list_database_operations_async_pages(): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) @@ -4158,7 +4702,8 @@ def test_list_backup_operations( transport: str = "grpc", request_type=backup.ListBackupOperationsRequest ): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4198,7 +4743,8 @@ async def test_list_backup_operations_async( transport: str = "grpc_asyncio", request_type=backup.ListBackupOperationsRequest ): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4236,7 +4782,9 @@ async def test_list_backup_operations_async_from_dict(): def test_list_backup_operations_field_headers(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=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. @@ -4258,12 +4806,17 @@ def test_list_backup_operations_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_backup_operations_field_headers_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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. @@ -4287,11 +4840,16 @@ async def test_list_backup_operations_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_backup_operations_flattened(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4302,7 +4860,9 @@ def test_list_backup_operations_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_backup_operations(parent="parent_value",) + client.list_backup_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4313,19 +4873,24 @@ def test_list_backup_operations_flattened(): def test_list_backup_operations_flattened_error(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_backup_operations( - backup.ListBackupOperationsRequest(), parent="parent_value", + backup.ListBackupOperationsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_backup_operations_flattened_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4339,7 +4904,9 @@ async def test_list_backup_operations_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_backup_operations(parent="parent_value",) + response = await client.list_backup_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4351,18 +4918,23 @@ async def test_list_backup_operations_flattened_async(): @pytest.mark.asyncio async def test_list_backup_operations_flattened_error_async(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatabaseAdminAsyncClient( + credentials=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_backup_operations( - backup.ListBackupOperationsRequest(), parent="parent_value", + backup.ListBackupOperationsRequest(), + parent="parent_value", ) def test_list_backup_operations_pager(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4378,12 +4950,21 @@ def test_list_backup_operations_pager(): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) @@ -4402,7 +4983,9 @@ def test_list_backup_operations_pager(): def test_list_backup_operations_pages(): - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4418,12 +5001,21 @@ def test_list_backup_operations_pages(): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) @@ -4434,7 +5026,9 @@ def test_list_backup_operations_pages(): @pytest.mark.asyncio async def test_list_backup_operations_async_pager(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4452,16 +5046,27 @@ async def test_list_backup_operations_async_pager(): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) - async_pager = await client.list_backup_operations(request={},) + async_pager = await client.list_backup_operations( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -4473,7 +5078,9 @@ async def test_list_backup_operations_async_pager(): @pytest.mark.asyncio async def test_list_backup_operations_async_pages(): - client = DatabaseAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4491,12 +5098,21 @@ async def test_list_backup_operations_async_pages(): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations.Operation(), operations.Operation(),], + operations=[ + operations.Operation(), + operations.Operation(), + ], ), RuntimeError, ) @@ -4514,7 +5130,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -4533,7 +5150,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DatabaseAdminClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -4578,8 +5196,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = DatabaseAdminClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.DatabaseAdminGrpcTransport,) + client = DatabaseAdminClient( + credentials=credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.DatabaseAdminGrpcTransport, + ) def test_database_admin_base_transport_error(): @@ -4642,7 +5265,8 @@ def test_database_admin_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (credentials.AnonymousCredentials(), None) transport = transports.DatabaseAdminTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -4721,7 +5345,8 @@ def test_database_admin_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.DatabaseAdminGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4732,7 +5357,8 @@ def test_database_admin_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.DatabaseAdminGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4831,12 +5457,16 @@ def test_database_admin_transport_channel_mtls_with_adc(transport_class): def test_database_admin_grpc_lro_client(): client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=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 @@ -4844,12 +5474,16 @@ def test_database_admin_grpc_lro_client(): def test_database_admin_grpc_lro_async_client(): client = DatabaseAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=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 @@ -4861,7 +5495,9 @@ def test_backup_path(): backup = "whelk" expected = "projects/{project}/instances/{instance}/backups/{backup}".format( - project=project, instance=instance, backup=backup, + project=project, + instance=instance, + backup=backup, ) actual = DatabaseAdminClient.backup_path(project, instance, backup) assert expected == actual @@ -4886,7 +5522,9 @@ def test_database_path(): database = "winkle" expected = "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) actual = DatabaseAdminClient.database_path(project, instance, database) assert expected == actual @@ -4910,7 +5548,8 @@ def test_instance_path(): instance = "clam" expected = "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) actual = DatabaseAdminClient.instance_path(project, instance) assert expected == actual @@ -4952,7 +5591,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = DatabaseAdminClient.common_folder_path(folder) assert expected == actual @@ -4971,7 +5612,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = DatabaseAdminClient.common_organization_path(organization) assert expected == actual @@ -4990,7 +5633,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = DatabaseAdminClient.common_project_path(project) assert expected == actual @@ -5011,7 +5656,8 @@ def test_common_location_path(): location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = DatabaseAdminClient.common_location_path(project, location) assert expected == actual @@ -5036,7 +5682,8 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.DatabaseAdminTransport, "_prep_wrapped_messages" ) as prep: client = DatabaseAdminClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5045,6 +5692,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = DatabaseAdminClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py index 0db8185b79..080b9b08df 100644 --- a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py +++ b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py @@ -387,7 +387,9 @@ def test_instance_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) @@ -456,7 +458,8 @@ def test_list_instance_configs( request_type=spanner_instance_admin.ListInstanceConfigsRequest, ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -497,7 +500,8 @@ async def test_list_instance_configs_async( request_type=spanner_instance_admin.ListInstanceConfigsRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -535,7 +539,9 @@ async def test_list_instance_configs_async_from_dict(): def test_list_instance_configs_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -557,12 +563,17 @@ def test_list_instance_configs_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_instance_configs_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -586,11 +597,16 @@ async def test_list_instance_configs_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_instance_configs_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -601,7 +617,9 @@ def test_list_instance_configs_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_instance_configs(parent="parent_value",) + client.list_instance_configs( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -612,19 +630,24 @@ def test_list_instance_configs_flattened(): def test_list_instance_configs_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_instance_configs( - spanner_instance_admin.ListInstanceConfigsRequest(), parent="parent_value", + spanner_instance_admin.ListInstanceConfigsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_instance_configs_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -638,7 +661,9 @@ async def test_list_instance_configs_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_instance_configs(parent="parent_value",) + response = await client.list_instance_configs( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -650,18 +675,23 @@ async def test_list_instance_configs_flattened_async(): @pytest.mark.asyncio async def test_list_instance_configs_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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_instance_configs( - spanner_instance_admin.ListInstanceConfigsRequest(), parent="parent_value", + spanner_instance_admin.ListInstanceConfigsRequest(), + parent="parent_value", ) def test_list_instance_configs_pager(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -678,10 +708,13 @@ def test_list_instance_configs_pager(): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -709,7 +742,9 @@ def test_list_instance_configs_pager(): def test_list_instance_configs_pages(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -726,10 +761,13 @@ def test_list_instance_configs_pages(): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -747,7 +785,9 @@ def test_list_instance_configs_pages(): @pytest.mark.asyncio async def test_list_instance_configs_async_pager(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -766,10 +806,13 @@ async def test_list_instance_configs_async_pager(): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -780,7 +823,9 @@ async def test_list_instance_configs_async_pager(): ), RuntimeError, ) - async_pager = await client.list_instance_configs(request={},) + async_pager = await client.list_instance_configs( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -794,7 +839,9 @@ async def test_list_instance_configs_async_pager(): @pytest.mark.asyncio async def test_list_instance_configs_async_pages(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -813,10 +860,13 @@ async def test_list_instance_configs_async_pages(): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -839,7 +889,8 @@ def test_get_instance_config( request_type=spanner_instance_admin.GetInstanceConfigRequest, ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -852,7 +903,8 @@ def test_get_instance_config( ) as call: # Designate an appropriate return value for the call. call.return_value = spanner_instance_admin.InstanceConfig( - name="name_value", display_name="display_name_value", + name="name_value", + display_name="display_name_value", ) response = client.get_instance_config(request) @@ -882,7 +934,8 @@ async def test_get_instance_config_async( request_type=spanner_instance_admin.GetInstanceConfigRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -896,7 +949,8 @@ async def test_get_instance_config_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( spanner_instance_admin.InstanceConfig( - name="name_value", display_name="display_name_value", + name="name_value", + display_name="display_name_value", ) ) @@ -922,7 +976,9 @@ async def test_get_instance_config_async_from_dict(): def test_get_instance_config_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -944,12 +1000,17 @@ def test_get_instance_config_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_instance_config_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -973,11 +1034,16 @@ async def test_get_instance_config_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_instance_config_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -988,7 +1054,9 @@ def test_get_instance_config_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_instance_config(name="name_value",) + client.get_instance_config( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -999,19 +1067,24 @@ def test_get_instance_config_flattened(): def test_get_instance_config_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_instance_config( - spanner_instance_admin.GetInstanceConfigRequest(), name="name_value", + spanner_instance_admin.GetInstanceConfigRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_instance_config_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1025,7 +1098,9 @@ async def test_get_instance_config_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_instance_config(name="name_value",) + response = await client.get_instance_config( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1037,13 +1112,16 @@ async def test_get_instance_config_flattened_async(): @pytest.mark.asyncio async def test_get_instance_config_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_instance_config( - spanner_instance_admin.GetInstanceConfigRequest(), name="name_value", + spanner_instance_admin.GetInstanceConfigRequest(), + name="name_value", ) @@ -1051,7 +1129,8 @@ def test_list_instances( transport: str = "grpc", request_type=spanner_instance_admin.ListInstancesRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1090,7 +1169,8 @@ async def test_list_instances_async( request_type=spanner_instance_admin.ListInstancesRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1126,7 +1206,9 @@ async def test_list_instances_async_from_dict(): def test_list_instances_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -1146,12 +1228,17 @@ def test_list_instances_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_instances_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -1173,11 +1260,16 @@ async def test_list_instances_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_instances_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1186,7 +1278,9 @@ def test_list_instances_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_instances(parent="parent_value",) + client.list_instances( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1197,19 +1291,24 @@ def test_list_instances_flattened(): def test_list_instances_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_instances( - spanner_instance_admin.ListInstancesRequest(), parent="parent_value", + spanner_instance_admin.ListInstancesRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_instances_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1221,7 +1320,9 @@ async def test_list_instances_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_instances(parent="parent_value",) + response = await client.list_instances( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1233,18 +1334,23 @@ async def test_list_instances_flattened_async(): @pytest.mark.asyncio async def test_list_instances_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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_instances( - spanner_instance_admin.ListInstancesRequest(), parent="parent_value", + spanner_instance_admin.ListInstancesRequest(), + parent="parent_value", ) def test_list_instances_pager(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1259,10 +1365,14 @@ def test_list_instances_pager(): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1287,7 +1397,9 @@ def test_list_instances_pager(): def test_list_instances_pages(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1302,10 +1414,14 @@ def test_list_instances_pages(): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1322,7 +1438,9 @@ def test_list_instances_pages(): @pytest.mark.asyncio async def test_list_instances_async_pager(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1339,10 +1457,14 @@ async def test_list_instances_async_pager(): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1352,7 +1474,9 @@ async def test_list_instances_async_pager(): ), RuntimeError, ) - async_pager = await client.list_instances(request={},) + async_pager = await client.list_instances( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1364,7 +1488,9 @@ async def test_list_instances_async_pager(): @pytest.mark.asyncio async def test_list_instances_async_pages(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1381,10 +1507,14 @@ async def test_list_instances_async_pages(): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1405,7 +1535,8 @@ def test_get_instance( transport: str = "grpc", request_type=spanner_instance_admin.GetInstanceRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1459,7 +1590,8 @@ async def test_get_instance_async( request_type=spanner_instance_admin.GetInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1510,7 +1642,9 @@ async def test_get_instance_async_from_dict(): def test_get_instance_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -1530,12 +1664,17 @@ def test_get_instance_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_instance_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -1557,11 +1696,16 @@ async def test_get_instance_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_instance_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_instance), "__call__") as call: @@ -1570,7 +1714,9 @@ def test_get_instance_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_instance(name="name_value",) + client.get_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1581,19 +1727,24 @@ def test_get_instance_flattened(): def test_get_instance_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_instance( - spanner_instance_admin.GetInstanceRequest(), name="name_value", + spanner_instance_admin.GetInstanceRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_instance_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_instance), "__call__") as call: @@ -1605,7 +1756,9 @@ async def test_get_instance_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_instance(name="name_value",) + response = await client.get_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1617,13 +1770,16 @@ async def test_get_instance_flattened_async(): @pytest.mark.asyncio async def test_get_instance_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_instance( - spanner_instance_admin.GetInstanceRequest(), name="name_value", + spanner_instance_admin.GetInstanceRequest(), + name="name_value", ) @@ -1631,7 +1787,8 @@ def test_create_instance( transport: str = "grpc", request_type=spanner_instance_admin.CreateInstanceRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1665,7 +1822,8 @@ async def test_create_instance_async( request_type=spanner_instance_admin.CreateInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1697,7 +1855,9 @@ async def test_create_instance_async_from_dict(): def test_create_instance_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -1717,12 +1877,17 @@ def test_create_instance_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_instance_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -1744,11 +1909,16 @@ async def test_create_instance_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_instance_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_instance), "__call__") as call: @@ -1776,7 +1946,9 @@ def test_create_instance_flattened(): def test_create_instance_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1791,7 +1963,9 @@ def test_create_instance_flattened_error(): @pytest.mark.asyncio async def test_create_instance_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_instance), "__call__") as call: @@ -1823,7 +1997,9 @@ async def test_create_instance_flattened_async(): @pytest.mark.asyncio async def test_create_instance_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1840,7 +2016,8 @@ def test_update_instance( transport: str = "grpc", request_type=spanner_instance_admin.UpdateInstanceRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1874,7 +2051,8 @@ async def test_update_instance_async( request_type=spanner_instance_admin.UpdateInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1906,7 +2084,9 @@ async def test_update_instance_async_from_dict(): def test_update_instance_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -1926,14 +2106,17 @@ def test_update_instance_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "instance.name=instance.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "instance.name=instance.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_instance_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -1955,13 +2138,16 @@ async def test_update_instance_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "instance.name=instance.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "instance.name=instance.name/value", + ) in kw["metadata"] def test_update_instance_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_instance), "__call__") as call: @@ -1986,7 +2172,9 @@ def test_update_instance_flattened(): def test_update_instance_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2000,7 +2188,9 @@ def test_update_instance_flattened_error(): @pytest.mark.asyncio async def test_update_instance_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_instance), "__call__") as call: @@ -2029,7 +2219,9 @@ async def test_update_instance_flattened_async(): @pytest.mark.asyncio async def test_update_instance_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2045,7 +2237,8 @@ def test_delete_instance( transport: str = "grpc", request_type=spanner_instance_admin.DeleteInstanceRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2079,7 +2272,8 @@ async def test_delete_instance_async( request_type=spanner_instance_admin.DeleteInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2109,7 +2303,9 @@ async def test_delete_instance_async_from_dict(): def test_delete_instance_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -2129,12 +2325,17 @@ def test_delete_instance_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_instance_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -2154,11 +2355,16 @@ async def test_delete_instance_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_instance_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: @@ -2167,7 +2373,9 @@ def test_delete_instance_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_instance(name="name_value",) + client.delete_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2178,19 +2386,24 @@ def test_delete_instance_flattened(): def test_delete_instance_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_instance( - spanner_instance_admin.DeleteInstanceRequest(), name="name_value", + spanner_instance_admin.DeleteInstanceRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_instance_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: @@ -2200,7 +2413,9 @@ async def test_delete_instance_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_instance(name="name_value",) + response = await client.delete_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2212,13 +2427,16 @@ async def test_delete_instance_flattened_async(): @pytest.mark.asyncio async def test_delete_instance_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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_instance( - spanner_instance_admin.DeleteInstanceRequest(), name="name_value", + spanner_instance_admin.DeleteInstanceRequest(), + name="name_value", ) @@ -2226,7 +2444,8 @@ def test_set_iam_policy( transport: str = "grpc", request_type=iam_policy.SetIamPolicyRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2236,7 +2455,10 @@ def test_set_iam_policy( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) @@ -2264,7 +2486,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2275,7 +2498,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy.Policy(version=774, etag=b"etag_blob",) + policy.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2300,7 +2526,9 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -2320,12 +2548,17 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -2345,11 +2578,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2365,7 +2603,9 @@ def test_set_iam_policy_from_dict_foreign(): def test_set_iam_policy_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2374,7 +2614,9 @@ def test_set_iam_policy_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2385,19 +2627,24 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy.SetIamPolicyRequest(), resource="resource_value", + iam_policy.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_set_iam_policy_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2407,7 +2654,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2419,13 +2668,16 @@ async def test_set_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_set_iam_policy_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy.SetIamPolicyRequest(), resource="resource_value", + iam_policy.SetIamPolicyRequest(), + resource="resource_value", ) @@ -2433,7 +2685,8 @@ def test_get_iam_policy( transport: str = "grpc", request_type=iam_policy.GetIamPolicyRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2443,7 +2696,10 @@ def test_get_iam_policy( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) @@ -2471,7 +2727,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2482,7 +2739,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy.Policy(version=774, etag=b"etag_blob",) + policy.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2507,7 +2767,9 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -2527,12 +2789,17 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -2552,11 +2819,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2572,7 +2844,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2581,7 +2855,9 @@ def test_get_iam_policy_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2592,19 +2868,24 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy.GetIamPolicyRequest(), resource="resource_value", + iam_policy.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_get_iam_policy_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2614,7 +2895,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2626,13 +2909,16 @@ async def test_get_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_get_iam_policy_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy.GetIamPolicyRequest(), resource="resource_value", + iam_policy.GetIamPolicyRequest(), + resource="resource_value", ) @@ -2640,7 +2926,8 @@ def test_test_iam_permissions( transport: str = "grpc", request_type=iam_policy.TestIamPermissionsRequest ): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2680,7 +2967,8 @@ async def test_test_iam_permissions_async( transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest ): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2693,7 +2981,9 @@ async def test_test_iam_permissions_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy.TestIamPermissionsResponse(permissions=["permissions_value"],) + iam_policy.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) ) response = await client.test_iam_permissions(request) @@ -2716,7 +3006,9 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=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. @@ -2738,12 +3030,17 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=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. @@ -2767,11 +3064,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2789,7 +3091,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2801,7 +3105,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2815,7 +3120,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2829,7 +3136,9 @@ def test_test_iam_permissions_flattened_error(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2844,7 +3153,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2859,7 +3169,9 @@ async def test_test_iam_permissions_flattened_async(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_error_async(): - client = InstanceAdminAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = InstanceAdminAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2878,7 +3190,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2897,7 +3210,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = InstanceAdminClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2942,8 +3256,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = InstanceAdminClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.InstanceAdminGrpcTransport,) + client = InstanceAdminClient( + credentials=credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.InstanceAdminGrpcTransport, + ) def test_instance_admin_base_transport_error(): @@ -2999,7 +3318,8 @@ def test_instance_admin_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (credentials.AnonymousCredentials(), None) transport = transports.InstanceAdminTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3078,7 +3398,8 @@ def test_instance_admin_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.InstanceAdminGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3089,7 +3410,8 @@ def test_instance_admin_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.InstanceAdminGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3188,12 +3510,16 @@ def test_instance_admin_transport_channel_mtls_with_adc(transport_class): def test_instance_admin_grpc_lro_client(): client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=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 @@ -3201,12 +3527,16 @@ def test_instance_admin_grpc_lro_client(): def test_instance_admin_grpc_lro_async_client(): client = InstanceAdminAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=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 @@ -3217,7 +3547,8 @@ def test_instance_path(): instance = "clam" expected = "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) actual = InstanceAdminClient.instance_path(project, instance) assert expected == actual @@ -3240,7 +3571,8 @@ def test_instance_config_path(): instance_config = "nudibranch" expected = "projects/{project}/instanceConfigs/{instance_config}".format( - project=project, instance_config=instance_config, + project=project, + instance_config=instance_config, ) actual = InstanceAdminClient.instance_config_path(project, instance_config) assert expected == actual @@ -3282,7 +3614,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = InstanceAdminClient.common_folder_path(folder) assert expected == actual @@ -3301,7 +3635,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = InstanceAdminClient.common_organization_path(organization) assert expected == actual @@ -3320,7 +3656,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = InstanceAdminClient.common_project_path(project) assert expected == actual @@ -3341,7 +3679,8 @@ def test_common_location_path(): location = "nudibranch" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = InstanceAdminClient.common_location_path(project, location) assert expected == actual @@ -3366,7 +3705,8 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.InstanceAdminTransport, "_prep_wrapped_messages" ) as prep: client = InstanceAdminClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3375,6 +3715,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = InstanceAdminClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/spanner_v1/test_spanner.py b/tests/unit/gapic/spanner_v1/test_spanner.py index d891f27d94..d16d805299 100644 --- a/tests/unit/gapic/spanner_v1/test_spanner.py +++ b/tests/unit/gapic/spanner_v1/test_spanner.py @@ -356,7 +356,9 @@ def test_spanner_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) @@ -418,7 +420,8 @@ def test_create_session( transport: str = "grpc", request_type=spanner.CreateSessionRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -428,7 +431,9 @@ def test_create_session( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_session), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = spanner.Session(name="name_value",) + call.return_value = spanner.Session( + name="name_value", + ) response = client.create_session(request) @@ -454,7 +459,8 @@ async def test_create_session_async( transport: str = "grpc_asyncio", request_type=spanner.CreateSessionRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -465,7 +471,9 @@ async def test_create_session_async( with mock.patch.object(type(client.transport.create_session), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - spanner.Session(name="name_value",) + spanner.Session( + name="name_value", + ) ) response = await client.create_session(request) @@ -488,7 +496,9 @@ async def test_create_session_async_from_dict(): def test_create_session_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -508,12 +518,17 @@ def test_create_session_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_create_session_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -533,11 +548,16 @@ async def test_create_session_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_create_session_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_session), "__call__") as call: @@ -546,7 +566,9 @@ def test_create_session_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_session(database="database_value",) + client.create_session( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -557,19 +579,24 @@ def test_create_session_flattened(): def test_create_session_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.create_session( - spanner.CreateSessionRequest(), database="database_value", + spanner.CreateSessionRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_create_session_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_session), "__call__") as call: @@ -579,7 +606,9 @@ async def test_create_session_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(spanner.Session()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_session(database="database_value",) + response = await client.create_session( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -591,13 +620,16 @@ async def test_create_session_flattened_async(): @pytest.mark.asyncio async def test_create_session_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.create_session( - spanner.CreateSessionRequest(), database="database_value", + spanner.CreateSessionRequest(), + database="database_value", ) @@ -605,7 +637,8 @@ def test_batch_create_sessions( transport: str = "grpc", request_type=spanner.BatchCreateSessionsRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -641,7 +674,8 @@ async def test_batch_create_sessions_async( transport: str = "grpc_asyncio", request_type=spanner.BatchCreateSessionsRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -675,7 +709,9 @@ async def test_batch_create_sessions_async_from_dict(): def test_batch_create_sessions_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -697,12 +733,17 @@ def test_batch_create_sessions_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_create_sessions_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -726,11 +767,16 @@ async def test_batch_create_sessions_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_batch_create_sessions_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -742,7 +788,8 @@ def test_batch_create_sessions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_create_sessions( - database="database_value", session_count=1420, + database="database_value", + session_count=1420, ) # Establish that the underlying call was made with the expected @@ -756,7 +803,9 @@ def test_batch_create_sessions_flattened(): def test_batch_create_sessions_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -770,7 +819,9 @@ def test_batch_create_sessions_flattened_error(): @pytest.mark.asyncio async def test_batch_create_sessions_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -785,7 +836,8 @@ async def test_batch_create_sessions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.batch_create_sessions( - database="database_value", session_count=1420, + database="database_value", + session_count=1420, ) # Establish that the underlying call was made with the expected @@ -800,7 +852,9 @@ async def test_batch_create_sessions_flattened_async(): @pytest.mark.asyncio async def test_batch_create_sessions_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -814,7 +868,8 @@ async def test_batch_create_sessions_flattened_error_async(): def test_get_session(transport: str = "grpc", request_type=spanner.GetSessionRequest): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -824,7 +879,9 @@ def test_get_session(transport: str = "grpc", request_type=spanner.GetSessionReq # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_session), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = spanner.Session(name="name_value",) + call.return_value = spanner.Session( + name="name_value", + ) response = client.get_session(request) @@ -850,7 +907,8 @@ async def test_get_session_async( transport: str = "grpc_asyncio", request_type=spanner.GetSessionRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -861,7 +919,9 @@ async def test_get_session_async( with mock.patch.object(type(client.transport.get_session), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - spanner.Session(name="name_value",) + spanner.Session( + name="name_value", + ) ) response = await client.get_session(request) @@ -884,7 +944,9 @@ async def test_get_session_async_from_dict(): def test_get_session_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -904,12 +966,17 @@ def test_get_session_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_session_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -929,11 +996,16 @@ async def test_get_session_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_session_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_session), "__call__") as call: @@ -942,7 +1014,9 @@ def test_get_session_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_session(name="name_value",) + client.get_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -953,19 +1027,24 @@ def test_get_session_flattened(): def test_get_session_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_session( - spanner.GetSessionRequest(), name="name_value", + spanner.GetSessionRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_session_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_session), "__call__") as call: @@ -975,7 +1054,9 @@ async def test_get_session_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(spanner.Session()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_session(name="name_value",) + response = await client.get_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -987,13 +1068,16 @@ async def test_get_session_flattened_async(): @pytest.mark.asyncio async def test_get_session_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_session( - spanner.GetSessionRequest(), name="name_value", + spanner.GetSessionRequest(), + name="name_value", ) @@ -1001,7 +1085,8 @@ def test_list_sessions( transport: str = "grpc", request_type=spanner.ListSessionsRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1039,7 +1124,8 @@ async def test_list_sessions_async( transport: str = "grpc_asyncio", request_type=spanner.ListSessionsRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1050,7 +1136,9 @@ async def test_list_sessions_async( with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - spanner.ListSessionsResponse(next_page_token="next_page_token_value",) + spanner.ListSessionsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_sessions(request) @@ -1073,7 +1161,9 @@ async def test_list_sessions_async_from_dict(): def test_list_sessions_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -1093,12 +1183,17 @@ def test_list_sessions_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_list_sessions_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -1120,11 +1215,16 @@ async def test_list_sessions_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_list_sessions_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: @@ -1133,7 +1233,9 @@ def test_list_sessions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_sessions(database="database_value",) + client.list_sessions( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1144,19 +1246,24 @@ def test_list_sessions_flattened(): def test_list_sessions_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_sessions( - spanner.ListSessionsRequest(), database="database_value", + spanner.ListSessionsRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_list_sessions_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: @@ -1168,7 +1275,9 @@ async def test_list_sessions_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_sessions(database="database_value",) + response = await client.list_sessions( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1180,33 +1289,51 @@ async def test_list_sessions_flattened_async(): @pytest.mark.asyncio async def test_list_sessions_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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_sessions( - spanner.ListSessionsRequest(), database="database_value", + spanner.ListSessionsRequest(), + database="database_value", ) def test_list_sessions_pager(): - client = SpannerClient(credentials=credentials.AnonymousCredentials,) + client = SpannerClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) @@ -1225,22 +1352,37 @@ def test_list_sessions_pager(): def test_list_sessions_pages(): - client = SpannerClient(credentials=credentials.AnonymousCredentials,) + client = SpannerClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) @@ -1251,7 +1393,9 @@ def test_list_sessions_pages(): @pytest.mark.asyncio async def test_list_sessions_async_pager(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1260,19 +1404,34 @@ async def test_list_sessions_async_pager(): # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) - async_pager = await client.list_sessions(request={},) + async_pager = await client.list_sessions( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1284,7 +1443,9 @@ async def test_list_sessions_async_pager(): @pytest.mark.asyncio async def test_list_sessions_async_pages(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1293,15 +1454,28 @@ async def test_list_sessions_async_pages(): # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) @@ -1316,7 +1490,8 @@ def test_delete_session( transport: str = "grpc", request_type=spanner.DeleteSessionRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1349,7 +1524,8 @@ async def test_delete_session_async( transport: str = "grpc_asyncio", request_type=spanner.DeleteSessionRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1379,7 +1555,9 @@ async def test_delete_session_async_from_dict(): def test_delete_session_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -1399,12 +1577,17 @@ def test_delete_session_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_session_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -1424,11 +1607,16 @@ async def test_delete_session_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_session_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_session), "__call__") as call: @@ -1437,7 +1625,9 @@ def test_delete_session_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_session(name="name_value",) + client.delete_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1448,19 +1638,24 @@ def test_delete_session_flattened(): def test_delete_session_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_session( - spanner.DeleteSessionRequest(), name="name_value", + spanner.DeleteSessionRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_session_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_session), "__call__") as call: @@ -1470,7 +1665,9 @@ async def test_delete_session_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_session(name="name_value",) + response = await client.delete_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1482,19 +1679,23 @@ async def test_delete_session_flattened_async(): @pytest.mark.asyncio async def test_delete_session_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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_session( - spanner.DeleteSessionRequest(), name="name_value", + spanner.DeleteSessionRequest(), + name="name_value", ) def test_execute_sql(transport: str = "grpc", request_type=spanner.ExecuteSqlRequest): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1528,7 +1729,8 @@ async def test_execute_sql_async( transport: str = "grpc_asyncio", request_type=spanner.ExecuteSqlRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1560,7 +1762,9 @@ async def test_execute_sql_async_from_dict(): def test_execute_sql_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -1580,12 +1784,17 @@ def test_execute_sql_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_execute_sql_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -1607,14 +1816,18 @@ async def test_execute_sql_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_execute_streaming_sql( transport: str = "grpc", request_type=spanner.ExecuteSqlRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1650,7 +1863,8 @@ async def test_execute_streaming_sql_async( transport: str = "grpc_asyncio", request_type=spanner.ExecuteSqlRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1686,7 +1900,9 @@ async def test_execute_streaming_sql_async_from_dict(): def test_execute_streaming_sql_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -1708,12 +1924,17 @@ def test_execute_streaming_sql_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_execute_streaming_sql_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -1738,14 +1959,18 @@ async def test_execute_streaming_sql_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_execute_batch_dml( transport: str = "grpc", request_type=spanner.ExecuteBatchDmlRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1781,7 +2006,8 @@ async def test_execute_batch_dml_async( transport: str = "grpc_asyncio", request_type=spanner.ExecuteBatchDmlRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1815,7 +2041,9 @@ async def test_execute_batch_dml_async_from_dict(): def test_execute_batch_dml_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -1837,12 +2065,17 @@ def test_execute_batch_dml_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_execute_batch_dml_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -1866,12 +2099,16 @@ async def test_execute_batch_dml_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_read(transport: str = "grpc", request_type=spanner.ReadRequest): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1905,7 +2142,8 @@ async def test_read_async( transport: str = "grpc_asyncio", request_type=spanner.ReadRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1937,7 +2175,9 @@ async def test_read_async_from_dict(): def test_read_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -1957,12 +2197,17 @@ def test_read_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_read_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -1984,12 +2229,16 @@ async def test_read_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_streaming_read(transport: str = "grpc", request_type=spanner.ReadRequest): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2023,7 +2272,8 @@ async def test_streaming_read_async( transport: str = "grpc_asyncio", request_type=spanner.ReadRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2057,7 +2307,9 @@ async def test_streaming_read_async_from_dict(): def test_streaming_read_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -2077,12 +2329,17 @@ def test_streaming_read_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_streaming_read_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -2105,14 +2362,18 @@ async def test_streaming_read_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_begin_transaction( transport: str = "grpc", request_type=spanner.BeginTransactionRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2124,7 +2385,9 @@ def test_begin_transaction( type(client.transport.begin_transaction), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = transaction.Transaction(id=b"id_blob",) + call.return_value = transaction.Transaction( + id=b"id_blob", + ) response = client.begin_transaction(request) @@ -2150,7 +2413,8 @@ async def test_begin_transaction_async( transport: str = "grpc_asyncio", request_type=spanner.BeginTransactionRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2163,7 +2427,9 @@ async def test_begin_transaction_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - transaction.Transaction(id=b"id_blob",) + transaction.Transaction( + id=b"id_blob", + ) ) response = await client.begin_transaction(request) @@ -2186,7 +2452,9 @@ async def test_begin_transaction_async_from_dict(): def test_begin_transaction_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -2208,12 +2476,17 @@ def test_begin_transaction_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_begin_transaction_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -2237,11 +2510,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", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_begin_transaction_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2268,7 +2546,9 @@ def test_begin_transaction_flattened(): def test_begin_transaction_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2282,7 +2562,9 @@ def test_begin_transaction_flattened_error(): @pytest.mark.asyncio async def test_begin_transaction_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2313,7 +2595,9 @@ async def test_begin_transaction_flattened_async(): @pytest.mark.asyncio async def test_begin_transaction_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2327,7 +2611,8 @@ async def test_begin_transaction_flattened_error_async(): def test_commit(transport: str = "grpc", request_type=spanner.CommitRequest): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2361,7 +2646,8 @@ async def test_commit_async( transport: str = "grpc_asyncio", request_type=spanner.CommitRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2393,7 +2679,9 @@ async def test_commit_async_from_dict(): def test_commit_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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,12 +2701,17 @@ def test_commit_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_commit_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -2440,11 +2733,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", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_commit_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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: @@ -2479,7 +2777,9 @@ def test_commit_flattened(): def test_commit_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2497,7 +2797,9 @@ def test_commit_flattened_error(): @pytest.mark.asyncio async def test_commit_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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: @@ -2536,7 +2838,9 @@ async def test_commit_flattened_async(): @pytest.mark.asyncio async def test_commit_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2554,7 +2858,8 @@ async def test_commit_flattened_error_async(): def test_rollback(transport: str = "grpc", request_type=spanner.RollbackRequest): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2587,7 +2892,8 @@ async def test_rollback_async( transport: str = "grpc_asyncio", request_type=spanner.RollbackRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2617,7 +2923,9 @@ async def test_rollback_async_from_dict(): def test_rollback_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -2637,12 +2945,17 @@ def test_rollback_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_rollback_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -2662,11 +2975,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", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_rollback_flattened(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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: @@ -2676,7 +2994,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( - session="session_value", transaction_id=b"transaction_id_blob", + session="session_value", + transaction_id=b"transaction_id_blob", ) # Establish that the underlying call was made with the expected @@ -2690,7 +3009,9 @@ def test_rollback_flattened(): def test_rollback_flattened_error(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2704,7 +3025,9 @@ def test_rollback_flattened_error(): @pytest.mark.asyncio async def test_rollback_flattened_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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: @@ -2715,7 +3038,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( - session="session_value", transaction_id=b"transaction_id_blob", + session="session_value", + transaction_id=b"transaction_id_blob", ) # Establish that the underlying call was made with the expected @@ -2730,7 +3054,9 @@ async def test_rollback_flattened_async(): @pytest.mark.asyncio async def test_rollback_flattened_error_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2746,7 +3072,8 @@ def test_partition_query( transport: str = "grpc", request_type=spanner.PartitionQueryRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2780,7 +3107,8 @@ async def test_partition_query_async( transport: str = "grpc_asyncio", request_type=spanner.PartitionQueryRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2812,7 +3140,9 @@ async def test_partition_query_async_from_dict(): def test_partition_query_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -2832,12 +3162,17 @@ def test_partition_query_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_partition_query_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -2859,14 +3194,18 @@ 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", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_partition_read( transport: str = "grpc", request_type=spanner.PartitionReadRequest ): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2900,7 +3239,8 @@ async def test_partition_read_async( transport: str = "grpc_asyncio", request_type=spanner.PartitionReadRequest ): client = SpannerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2932,7 +3272,9 @@ async def test_partition_read_async_from_dict(): def test_partition_read_field_headers(): - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=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. @@ -2952,12 +3294,17 @@ def test_partition_read_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_partition_read_field_headers_async(): - client = SpannerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=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. @@ -2979,7 +3326,10 @@ async def test_partition_read_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -2989,7 +3339,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SpannerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3008,7 +3359,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SpannerClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3050,8 +3402,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = SpannerClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.SpannerGrpcTransport,) + client = SpannerClient( + credentials=credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.SpannerGrpcTransport, + ) def test_spanner_base_transport_error(): @@ -3107,7 +3464,8 @@ def test_spanner_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (credentials.AnonymousCredentials(), None) transport = transports.SpannerTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3186,7 +3544,8 @@ def test_spanner_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.SpannerGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3197,7 +3556,8 @@ def test_spanner_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.SpannerGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3294,7 +3654,9 @@ def test_database_path(): database = "whelk" expected = "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) actual = SpannerClient.database_path(project, instance, database) assert expected == actual @@ -3320,7 +3682,10 @@ def test_session_path(): session = "nautilus" expected = "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}".format( - project=project, instance=instance, database=database, session=session, + project=project, + instance=instance, + database=database, + session=session, ) actual = SpannerClient.session_path(project, instance, database, session) assert expected == actual @@ -3364,7 +3729,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 = SpannerClient.common_folder_path(folder) assert expected == actual @@ -3383,7 +3750,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 = SpannerClient.common_organization_path(organization) assert expected == actual @@ -3402,7 +3771,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 = SpannerClient.common_project_path(project) assert expected == actual @@ -3423,7 +3794,8 @@ def test_common_location_path(): location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = SpannerClient.common_location_path(project, location) assert expected == actual @@ -3448,7 +3820,8 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.SpannerTransport, "_prep_wrapped_messages" ) as prep: client = SpannerClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3457,6 +3830,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = SpannerClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/spanner_dbapi/test_connect.py b/tests/unit/spanner_dbapi/test_connect.py index 771b9d4a7f..1d43b5e00c 100644 --- a/tests/unit/spanner_dbapi/test_connect.py +++ b/tests/unit/spanner_dbapi/test_connect.py @@ -30,38 +30,42 @@ class _CredentialsWithScopes( class Test_connect(unittest.TestCase): + PROJECT = "test-project" + CREDENTIALS = _make_credentials() + def test_connect(self): from google.cloud.spanner_dbapi import connect from google.cloud.spanner_dbapi import Connection - PROJECT = "test-project" USER_AGENT = "user-agent" - CREDENTIALS = _make_credentials() with mock.patch("google.cloud.spanner_v1.Client") as client_mock: connection = connect( "test-instance", "test-database", - PROJECT, - CREDENTIALS, + self.PROJECT, + self.CREDENTIALS, user_agent=USER_AGENT, ) self.assertIsInstance(connection, Connection) client_mock.assert_called_once_with( - project=PROJECT, credentials=CREDENTIALS, client_info=mock.ANY + project=self.PROJECT, credentials=self.CREDENTIALS, client_info=mock.ANY ) def test_instance_not_found(self): from google.cloud.spanner_dbapi import connect with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=False, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=False, ) as exists_mock: with self.assertRaises(ValueError): - connect("test-instance", "test-database") + connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) exists_mock.assert_called_once_with() @@ -69,14 +73,18 @@ def test_database_not_found(self): from google.cloud.spanner_dbapi import connect with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): with mock.patch( - "google.cloud.spanner_v1.database.Database.exists", return_value=False, + "google.cloud.spanner_v1.database.Database.exists", + return_value=False, ) as exists_mock: with self.assertRaises(ValueError): - connect("test-instance", "test-database") + connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) exists_mock.assert_called_once_with() @@ -89,7 +97,9 @@ def test_connect_instance_id(self): with mock.patch( "google.cloud.spanner_v1.client.Client.instance" ) as instance_mock: - connection = connect(INSTANCE, "test-database") + connection = connect( + INSTANCE, "test-database", self.PROJECT, self.CREDENTIALS + ) instance_mock.assert_called_once_with(INSTANCE) @@ -105,9 +115,12 @@ def test_connect_database_id(self): "google.cloud.spanner_v1.instance.Instance.database" ) as database_mock: with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): - connection = connect("test-instance", DATABASE) + connection = connect( + "test-instance", DATABASE, self.PROJECT, self.CREDENTIALS + ) database_mock.assert_called_once_with(DATABASE, pool=mock.ANY) @@ -118,9 +131,12 @@ def test_default_sessions_pool(self): with mock.patch("google.cloud.spanner_v1.instance.Instance.database"): with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) self.assertIsNotNone(connection.database._pool) @@ -135,7 +151,14 @@ def test_sessions_pool(self): "google.cloud.spanner_v1.instance.Instance.database" ) as database_mock: with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): - connect("test-instance", database_id, pool=pool) + connect( + "test-instance", + database_id, + self.PROJECT, + self.CREDENTIALS, + pool=pool, + ) database_mock.assert_called_once_with(database_id, pool=pool) diff --git a/tests/unit/spanner_dbapi/test_connection.py b/tests/unit/spanner_dbapi/test_connection.py index 213eb24d84..0ae86463c2 100644 --- a/tests/unit/spanner_dbapi/test_connection.py +++ b/tests/unit/spanner_dbapi/test_connection.py @@ -138,7 +138,9 @@ def test_close(self): with mock.patch( "google.cloud.spanner_v1.database.Database.exists", return_value=True ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) self.assertFalse(connection.is_closed) connection.close() @@ -264,7 +266,9 @@ def test_connect_instance_not_found(self): "google.cloud.spanner_v1.instance.Instance.exists", return_value=False ): with self.assertRaises(ValueError): - connect("test-instance", "test-database") + connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) def test_connect_database_not_found(self): from google.cloud.spanner_dbapi import connect @@ -276,7 +280,9 @@ def test_connect_database_not_found(self): "google.cloud.spanner_v1.instance.Instance.exists", return_value=True ): with self.assertRaises(ValueError): - connect("test-instance", "test-database") + connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) def test_default_sessions_pool(self): from google.cloud.spanner_dbapi import connect @@ -285,7 +291,9 @@ def test_default_sessions_pool(self): with mock.patch( "google.cloud.spanner_v1.instance.Instance.exists", return_value=True ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) self.assertIsNotNone(connection.database._pool) @@ -302,7 +310,13 @@ def test_sessions_pool(self): with mock.patch( "google.cloud.spanner_v1.instance.Instance.exists", return_value=True ): - connect("test-instance", database_id, pool=pool) + connect( + "test-instance", + database_id, + self.PROJECT, + self.CREDENTIALS, + pool=pool, + ) database_mock.assert_called_once_with(database_id, pool=pool) def test_run_statement_remember_statements(self): @@ -316,7 +330,12 @@ def test_run_statement_remember_statements(self): connection = self._make_connection() - statement = Statement(sql, params, param_types, ResultsChecksum(),) + statement = Statement( + sql, + params, + param_types, + ResultsChecksum(), + ) with mock.patch( "google.cloud.spanner_dbapi.connection.Connection.transaction_checkout" ): @@ -338,7 +357,12 @@ def test_run_statement_dont_remember_retried_statements(self): connection = self._make_connection() - statement = Statement(sql, params, param_types, ResultsChecksum(),) + statement = Statement( + sql, + params, + param_types, + ResultsChecksum(), + ) with mock.patch( "google.cloud.spanner_dbapi.connection.Connection.transaction_checkout" ): @@ -390,7 +414,12 @@ def test_retry_transaction(self): checksum.consume_result(row) retried_checkum = ResultsChecksum() - statement = Statement("SELECT 1", [], {}, checksum,) + statement = Statement( + "SELECT 1", + [], + {}, + checksum, + ) connection._statements.append(statement) with mock.patch( @@ -423,7 +452,12 @@ def test_retry_transaction_checksum_mismatch(self): checksum.consume_result(row) retried_checkum = ResultsChecksum() - statement = Statement("SELECT 1", [], {}, checksum,) + statement = Statement( + "SELECT 1", + [], + {}, + checksum, + ) connection._statements.append(statement) with mock.patch( @@ -442,23 +476,34 @@ def test_commit_retry_aborted_statements(self): row = ["field1", "field2"] with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): with mock.patch( - "google.cloud.spanner_v1.database.Database.exists", return_value=True, + "google.cloud.spanner_v1.database.Database.exists", + return_value=True, ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() cursor._checksum = ResultsChecksum() cursor._checksum.consume_result(row) - statement = Statement("SELECT 1", [], {}, cursor._checksum,) + statement = Statement( + "SELECT 1", + [], + {}, + cursor._checksum, + ) connection._statements.append(statement) connection._transaction = mock.Mock() with mock.patch.object( - connection._transaction, "commit", side_effect=(Aborted("Aborted"), None), + connection._transaction, + "commit", + side_effect=(Aborted("Aborted"), None), ): with mock.patch( "google.cloud.spanner_dbapi.connection.Connection.run_statement", @@ -496,18 +541,27 @@ def test_retry_aborted_retry(self): row = ["field1", "field2"] with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): with mock.patch( - "google.cloud.spanner_v1.database.Database.exists", return_value=True, + "google.cloud.spanner_v1.database.Database.exists", + return_value=True, ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() cursor._checksum = ResultsChecksum() cursor._checksum.consume_result(row) - statement = Statement("SELECT 1", [], {}, cursor._checksum,) + statement = Statement( + "SELECT 1", + [], + {}, + cursor._checksum, + ) connection._statements.append(statement) metadata_mock = mock.Mock() diff --git a/tests/unit/spanner_dbapi/test_cursor.py b/tests/unit/spanner_dbapi/test_cursor.py index 43fc077abe..ae6e6c55d0 100644 --- a/tests/unit/spanner_dbapi/test_cursor.py +++ b/tests/unit/spanner_dbapi/test_cursor.py @@ -18,11 +18,24 @@ import sys import unittest +import google.auth.credentials + + +def _make_credentials(): + class _CredentialsWithScopes( + google.auth.credentials.Credentials, google.auth.credentials.Scoped + ): + pass + + return mock.Mock(spec=_CredentialsWithScopes) + class TestCursor(unittest.TestCase): INSTANCE = "test-instance" DATABASE = "test-database" + CREDENTIALS = _make_credentials() + PROJECT = "test-project" def _get_target_class(self): from google.cloud.spanner_dbapi import Cursor @@ -79,7 +92,9 @@ def test_close(self): with mock.patch( "google.cloud.spanner_v1.database.Database.exists", return_value=True ): - connection = connect(self.INSTANCE, self.DATABASE) + connection = connect( + self.INSTANCE, self.DATABASE, self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() self.assertFalse(cursor.is_closed) @@ -100,7 +115,9 @@ def test_do_execute_update(self): def run_helper(ret_value): transaction.execute_update.return_value = ret_value res = cursor._do_execute_update( - transaction=transaction, sql="SELECT * WHERE true", params={}, + transaction=transaction, + sql="SELECT * WHERE true", + params={}, ) return res @@ -249,7 +266,9 @@ def test_executemany_on_closed_cursor(self): with mock.patch( "google.cloud.spanner_v1.database.Database.exists", return_value=True ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() cursor.close() @@ -269,7 +288,9 @@ def test_executemany(self): with mock.patch( "google.cloud.spanner_v1.database.Database.exists", return_value=True ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() with mock.patch( @@ -470,12 +491,16 @@ def test_fetchone_retry_aborted(self): from google.cloud.spanner_dbapi.connection import connect with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): with mock.patch( - "google.cloud.spanner_v1.database.Database.exists", return_value=True, + "google.cloud.spanner_v1.database.Database.exists", + return_value=True, ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() cursor._checksum = ResultsChecksum() @@ -501,18 +526,27 @@ def test_fetchone_retry_aborted_statements(self): row = ["field1", "field2"] with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): with mock.patch( - "google.cloud.spanner_v1.database.Database.exists", return_value=True, + "google.cloud.spanner_v1.database.Database.exists", + return_value=True, ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() cursor._checksum = ResultsChecksum() cursor._checksum.consume_result(row) - statement = Statement("SELECT 1", [], {}, cursor._checksum,) + statement = Statement( + "SELECT 1", + [], + {}, + cursor._checksum, + ) connection._statements.append(statement) with mock.patch( @@ -540,18 +574,27 @@ def test_fetchone_retry_aborted_statements_checksums_mismatch(self): row2 = ["updated_field1", "field2"] with mock.patch( - "google.cloud.spanner_v1.instance.Instance.exists", return_value=True, + "google.cloud.spanner_v1.instance.Instance.exists", + return_value=True, ): with mock.patch( - "google.cloud.spanner_v1.database.Database.exists", return_value=True, + "google.cloud.spanner_v1.database.Database.exists", + return_value=True, ): - connection = connect("test-instance", "test-database") + connection = connect( + "test-instance", "test-database", self.PROJECT, self.CREDENTIALS + ) cursor = connection.cursor() cursor._checksum = ResultsChecksum() cursor._checksum.consume_result(row) - statement = Statement("SELECT 1", [], {}, cursor._checksum,) + statement = Statement( + "SELECT 1", + [], + {}, + cursor._checksum, + ) connection._statements.append(statement) with mock.patch( diff --git a/tests/unit/test_backup.py b/tests/unit/test_backup.py index 748c460291..814e20e940 100644 --- a/tests/unit/test_backup.py +++ b/tests/unit/test_backup.py @@ -185,7 +185,10 @@ def test_create_grpc_error(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) with self.assertRaises(GoogleAPICallError): backup.create() @@ -211,7 +214,10 @@ def test_create_already_exists(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) with self.assertRaises(Conflict): backup.create() @@ -237,7 +243,10 @@ def test_create_instance_not_found(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) with self.assertRaises(NotFound): backup.create() @@ -278,7 +287,10 @@ def test_create_success(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) future = backup.create() self.assertIs(future, op_future) @@ -475,7 +487,10 @@ def test_update_expire_time_grpc_error(self): with self.assertRaises(Unknown): backup.update_expire_time(expire_time) - backup_update = Backup(name=self.BACKUP_NAME, expire_time=expire_time,) + backup_update = Backup( + name=self.BACKUP_NAME, + expire_time=expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup.assert_called_once_with( backup=backup_update, @@ -497,7 +512,10 @@ def test_update_expire_time_not_found(self): with self.assertRaises(NotFound): backup.update_expire_time(expire_time) - backup_update = Backup(name=self.BACKUP_NAME, expire_time=expire_time,) + backup_update = Backup( + name=self.BACKUP_NAME, + expire_time=expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup.assert_called_once_with( backup=backup_update, @@ -517,7 +535,10 @@ def test_update_expire_time_success(self): backup.update_expire_time(expire_time) - backup_update = Backup(name=self.BACKUP_NAME, expire_time=expire_time,) + backup_update = Backup( + name=self.BACKUP_NAME, + expire_time=expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup.assert_called_once_with( backup=backup_update, diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index a3001e61ae..65db43f623 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -87,7 +87,9 @@ def _constructor_test_helper( self.assertIs(client._credentials, expected_creds) if expected_scopes is not None: - creds.with_scopes.assert_called_once_with(expected_scopes) + creds.with_scopes.assert_called_once_with( + expected_scopes, default_scopes=None + ) self.assertEqual(client.project, self.PROJECT) self.assertIs(client._client_info, expected_client_info) @@ -234,7 +236,9 @@ def test_instance_admin_api(self, mock_em): credentials=mock.ANY, client_info=client_info, client_options=client_options ) - credentials.with_scopes.assert_called_once_with(expected_scopes) + credentials.with_scopes.assert_called_once_with( + expected_scopes, default_scopes=None + ) @mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") def test_instance_admin_api_emulator_env(self, mock_em): @@ -332,7 +336,9 @@ def test_database_admin_api(self, mock_em): credentials=mock.ANY, client_info=client_info, client_options=client_options ) - credentials.with_scopes.assert_called_once_with(expected_scopes) + credentials.with_scopes.assert_called_once_with( + expected_scopes, default_scopes=None + ) @mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") def test_database_admin_api_emulator_env(self, mock_em): diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index 175c269d50..4e2bd87d5f 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -618,7 +618,9 @@ def test_update_ddl_grpc_error(self): database.update_ddl(DDL_STATEMENTS) expected_request = UpdateDatabaseDdlRequest( - database=self.DATABASE_NAME, statements=DDL_STATEMENTS, operation_id="", + database=self.DATABASE_NAME, + statements=DDL_STATEMENTS, + operation_id="", ) api.update_database_ddl.assert_called_once_with( @@ -642,7 +644,9 @@ def test_update_ddl_not_found(self): database.update_ddl(DDL_STATEMENTS) expected_request = UpdateDatabaseDdlRequest( - database=self.DATABASE_NAME, statements=DDL_STATEMENTS, operation_id="", + database=self.DATABASE_NAME, + statements=DDL_STATEMENTS, + operation_id="", ) api.update_database_ddl.assert_called_once_with( @@ -667,7 +671,9 @@ def test_update_ddl(self): self.assertIs(future, op_future) expected_request = UpdateDatabaseDdlRequest( - database=self.DATABASE_NAME, statements=DDL_STATEMENTS, operation_id="", + database=self.DATABASE_NAME, + statements=DDL_STATEMENTS, + operation_id="", ) api.update_database_ddl.assert_called_once_with( diff --git a/tests/unit/test_keyset.py b/tests/unit/test_keyset.py index 86a814c752..ec59fd2f99 100644 --- a/tests/unit/test_keyset.py +++ b/tests/unit/test_keyset.py @@ -121,7 +121,10 @@ def test_to_pb_w_start_closed_and_end_open(self): key2 = u"key_2" key_range = self._make_one(start_closed=[key1], end_open=[key2]) key_range_pb = key_range._to_pb() - expected = KeyRangePB(start_closed=[key1], end_open=[key2],) + expected = KeyRangePB( + start_closed=[key1], + end_open=[key2], + ) self.assertEqual(key_range_pb, expected) def test_to_pb_w_start_open_and_end_closed(self): diff --git a/tests/unit/test_session.py b/tests/unit/test_session.py index 0a004e3cd0..d1ae862cd9 100644 --- a/tests/unit/test_session.py +++ b/tests/unit/test_session.py @@ -138,7 +138,9 @@ def test_create_ok(self): self.assertEqual(session.session_id, self.SESSION_ID) - request = CreateSessionRequest(database=database.name,) + request = CreateSessionRequest( + database=database.name, + ) gax_api.create_session.assert_called_once_with( request=request, metadata=[("google-cloud-resource-prefix", database.name)] @@ -165,11 +167,13 @@ def test_create_w_labels(self): self.assertEqual(session.session_id, self.SESSION_ID) request = CreateSessionRequest( - database=database.name, session=SessionPB(labels=labels), + database=database.name, + session=SessionPB(labels=labels), ) gax_api.create_session.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) self.assertSpanAttributes( @@ -332,10 +336,14 @@ def test_ping_hit(self): session.ping() - request = ExecuteSqlRequest(session=self.SESSION_NAME, sql="SELECT 1",) + request = ExecuteSqlRequest( + session=self.SESSION_NAME, + sql="SELECT 1", + ) gax_api.execute_sql.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_ping_miss(self): @@ -352,10 +360,14 @@ def test_ping_miss(self): with self.assertRaises(NotFound): session.ping() - request = ExecuteSqlRequest(session=self.SESSION_NAME, sql="SELECT 1",) + request = ExecuteSqlRequest( + session=self.SESSION_NAME, + sql="SELECT 1", + ) gax_api.execute_sql.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_ping_error(self): @@ -372,10 +384,14 @@ def test_ping_error(self): with self.assertRaises(Unknown): session.ping() - request = ExecuteSqlRequest(session=self.SESSION_NAME, sql="SELECT 1",) + request = ExecuteSqlRequest( + session=self.SESSION_NAME, + sql="SELECT 1", + ) gax_api.execute_sql.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_delete_wo_session_id(self):