diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..f6b0fa6 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - v0 +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 0000000..9a6016c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - v0 +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 0000000..3e9c323 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - v0 +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=100 diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 9807e2a..3a952ac 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-bigquery-connection 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 02eb4a6..d84d186 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,18 @@ env_vars: { value: "github/python-bigquery-connection/.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 22659fe..97f5823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [0.3.1](https://github.com/googleapis/python-bigquery-connection/compare/v0.3.0...v0.3.1) (2022-04-06) + + +### Bug Fixes + +* **deps:** require google-api-core >= 1.31.5, >= 2.3.2 on v0 release ([#184](https://github.com/googleapis/python-bigquery-connection/issues/184)) ([628dd29](https://github.com/googleapis/python-bigquery-connection/commit/628dd299d273c5de14b63384c2f5b50c838895c9)) + ## [0.3.0](https://www.github.com/googleapis/python-bigquery-connection/compare/v0.2.0...v0.3.0) (2020-10-28) diff --git a/docs/conf.py b/docs/conf.py index 2688cc1..ee48ffc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,9 +67,9 @@ master_doc = "index" # General information about the project. -project = u"google-cloud-bigquery-connection" -copyright = u"2019, Google" -author = u"Google APIs" +project = "google-cloud-bigquery-connection" +copyright = "2019, Google" +author = "Google APIs" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -268,7 +268,7 @@ ( master_doc, "google-cloud-bigquery-connection.tex", - u"google-cloud-bigquery-connection Documentation", + "google-cloud-bigquery-connection Documentation", author, "manual", ) @@ -303,7 +303,7 @@ ( master_doc, "google-cloud-bigquery-connection", - u"google-cloud-bigquery-connection Documentation", + "google-cloud-bigquery-connection Documentation", [author], 1, ) @@ -322,7 +322,7 @@ ( master_doc, "google-cloud-bigquery-connection", - u"google-cloud-bigquery-connection Documentation", + "google-cloud-bigquery-connection Documentation", author, "google-cloud-bigquery-connection", "google-cloud-bigquery-connection Library", @@ -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/bigquery/connection_v1/services/connection_service/async_client.py b/google/cloud/bigquery/connection_v1/services/connection_service/async_client.py index 5035b81..ba08046 100644 --- a/google/cloud/bigquery/connection_v1/services/connection_service/async_client.py +++ b/google/cloud/bigquery/connection_v1/services/connection_service/async_client.py @@ -229,7 +229,12 @@ async def create_connection( ) # 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 @@ -296,7 +301,8 @@ async def get_connection( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=60.0, @@ -310,7 +316,12 @@ async def get_connection( ) # 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 @@ -379,7 +390,8 @@ async def list_connections( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=60.0, @@ -393,12 +405,20 @@ async def list_connections( ) # 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.ListConnectionsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -492,7 +512,12 @@ async def update_connection( ) # 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 @@ -552,7 +577,8 @@ async def delete_connection( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=60.0, @@ -567,7 +593,10 @@ async def delete_connection( # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_iam_policy( @@ -687,7 +716,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. @@ -704,7 +735,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 @@ -828,7 +864,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. @@ -845,7 +883,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 @@ -917,7 +960,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, @@ -935,7 +979,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/bigquery/connection_v1/services/connection_service/client.py b/google/cloud/bigquery/connection_v1/services/connection_service/client.py index 4844ccc..af47f29 100644 --- a/google/cloud/bigquery/connection_v1/services/connection_service/client.py +++ b/google/cloud/bigquery/connection_v1/services/connection_service/client.py @@ -59,7 +59,8 @@ class ConnectionServiceClientMeta(type): _transport_registry["grpc_asyncio"] = ConnectionServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[ConnectionServiceTransport]: """Return an appropriate transport class. @@ -146,10 +147,18 @@ def transport(self) -> ConnectionServiceTransport: return self._transport @staticmethod - def connection_path(project: str, location: str, connection: str,) -> str: + def connection_path( + project: str, + location: str, + connection: str, + ) -> str: """Return a fully-qualified connection string.""" - return "projects/{project}/locations/{location}/connections/{connection}".format( - project=project, location=location, connection=connection, + return ( + "projects/{project}/locations/{location}/connections/{connection}".format( + project=project, + location=location, + connection=connection, + ) ) @staticmethod @@ -162,7 +171,9 @@ def parse_connection_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, @@ -175,9 +186,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]: @@ -186,9 +201,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]: @@ -197,9 +216,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]: @@ -208,10 +231,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 @@ -423,7 +450,12 @@ def create_connection( ) # 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 @@ -497,7 +529,12 @@ def get_connection( ) # 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 @@ -573,12 +610,20 @@ def list_connections( ) # 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.ListConnectionsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -673,7 +718,12 @@ def update_connection( ) # 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 @@ -741,7 +791,10 @@ def delete_connection( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_iam_policy( @@ -861,7 +914,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. @@ -874,7 +929,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 @@ -998,7 +1058,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. @@ -1011,7 +1073,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 @@ -1083,7 +1150,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, @@ -1097,7 +1165,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/bigquery/connection_v1/services/connection_service/transports/base.py b/google/cloud/bigquery/connection_v1/services/connection_service/transports/base.py index a1cf970..7ca36be 100644 --- a/google/cloud/bigquery/connection_v1/services/connection_service/transports/base.py +++ b/google/cloud/bigquery/connection_v1/services/connection_service/transports/base.py @@ -76,10 +76,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. @@ -114,7 +114,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_connection: gapic_v1.method.wrap_method( - self.create_connection, default_timeout=60.0, client_info=client_info, + self.create_connection, + default_timeout=60.0, + client_info=client_info, ), self.get_connection: gapic_v1.method.wrap_method( self.get_connection, @@ -123,7 +125,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=60.0, @@ -136,14 +139,17 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=60.0, client_info=client_info, ), self.update_connection: gapic_v1.method.wrap_method( - self.update_connection, default_timeout=60.0, client_info=client_info, + self.update_connection, + default_timeout=60.0, + client_info=client_info, ), self.delete_connection: gapic_v1.method.wrap_method( self.delete_connection, @@ -152,17 +158,22 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, + exceptions.ServiceUnavailable, ), ), default_timeout=60.0, client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( - self.get_iam_policy, default_timeout=60.0, client_info=client_info, + self.get_iam_policy, + default_timeout=60.0, + client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=60.0, client_info=client_info, + self.set_iam_policy, + default_timeout=60.0, + client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, diff --git a/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc.py b/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc.py index aedcbdb..e59cd27 100644 --- a/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc.py +++ b/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc.py @@ -229,8 +229,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/bigquery/connection_v1/services/connection_service/transports/grpc_asyncio.py b/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc_asyncio.py index a091147..b7d2182 100644 --- a/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc_asyncio.py +++ b/google/cloud/bigquery/connection_v1/services/connection_service/transports/grpc_asyncio.py @@ -138,10 +138,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/bigquery/connection_v1/types/connection.py b/google/cloud/bigquery/connection_v1/types/connection.py index a964123..cc1ca6e 100644 --- a/google/cloud/bigquery/connection_v1/types/connection.py +++ b/google/cloud/bigquery/connection_v1/types/connection.py @@ -58,7 +58,11 @@ class CreateConnectionRequest(proto.Message): connection_id = proto.Field(proto.STRING, number=2) - connection = proto.Field(proto.MESSAGE, number=3, message="Connection",) + connection = proto.Field( + proto.MESSAGE, + number=3, + message="Connection", + ) class GetConnectionRequest(proto.Message): @@ -112,7 +116,11 @@ def raw_page(self): next_page_token = proto.Field(proto.STRING, number=1) - connections = proto.RepeatedField(proto.MESSAGE, number=2, message="Connection",) + connections = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="Connection", + ) class UpdateConnectionRequest(proto.Message): @@ -133,9 +141,17 @@ class UpdateConnectionRequest(proto.Message): name = proto.Field(proto.STRING, number=1) - connection = proto.Field(proto.MESSAGE, number=2, message="Connection",) + connection = proto.Field( + proto.MESSAGE, + number=2, + message="Connection", + ) - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, + number=3, + message=field_mask.FieldMask, + ) class DeleteConnectionRequest(proto.Message): @@ -185,11 +201,17 @@ class Connection(proto.Message): description = proto.Field(proto.STRING, number=3) cloud_sql = proto.Field( - proto.MESSAGE, number=4, oneof="properties", message="CloudSqlProperties", + proto.MESSAGE, + number=4, + oneof="properties", + message="CloudSqlProperties", ) aws = proto.Field( - proto.MESSAGE, number=8, oneof="properties", message="AwsProperties", + proto.MESSAGE, + number=8, + oneof="properties", + message="AwsProperties", ) creation_time = proto.Field(proto.INT64, number=5) @@ -224,9 +246,17 @@ class DatabaseType(proto.Enum): database = proto.Field(proto.STRING, number=2) - type_ = proto.Field(proto.ENUM, number=3, enum=DatabaseType,) + type_ = proto.Field( + proto.ENUM, + number=3, + enum=DatabaseType, + ) - credential = proto.Field(proto.MESSAGE, number=4, message="CloudSqlCredential",) + credential = proto.Field( + proto.MESSAGE, + number=4, + message="CloudSqlCredential", + ) class CloudSqlCredential(proto.Message): diff --git a/noxfile.py b/noxfile.py index 0f561b2..c09efd8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,7 +23,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -40,12 +40,14 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) 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. @@ -57,7 +59,8 @@ def blacken(session): """ session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) @@ -122,7 +125,9 @@ 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", ) session.install("-e", ".") @@ -151,7 +156,7 @@ def docs(session): """Build the docs for this library.""" session.install("-e", ".") - session.install("sphinx", "alabaster", "recommonmark") + session.install("sphinx<3", "alabaster", "recommonmark", "Jinja2<3.1") shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( @@ -173,9 +178,9 @@ def docfx(session): """Build the docfx yaml files for this library.""" session.install("-e", ".") - # 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<3", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml", "Jinja2<3.1" + ) shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( diff --git a/setup.py b/setup.py index 6cee319..b34c21c 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import os import setuptools # type: ignore -version = "0.3.0" +version = "0.3.1" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -40,7 +40,7 @@ platforms="Posix; MacOS X; Windows", include_package_data=True, install_requires=( - "google-api-core >= 1.21.0, < 2.0.0dev", + "google-api-core >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", "proto-plus >= 1.4.0", "grpc-google-iam-v1", "libcst >= 0.2.5", diff --git a/tests/unit/gapic/connection_v1/test_connection_service.py b/tests/unit/gapic/connection_v1/test_connection_service.py index 7469f9f..8162fd9 100644 --- a/tests/unit/gapic/connection_v1/test_connection_service.py +++ b/tests/unit/gapic/connection_v1/test_connection_service.py @@ -394,7 +394,9 @@ def test_connection_service_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) @@ -462,7 +464,8 @@ def test_create_connection( transport: str = "grpc", request_type=gcbc_connection.CreateConnectionRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -521,7 +524,8 @@ async def test_create_connection_async( request_type=gcbc_connection.CreateConnectionRequest, ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -574,7 +578,9 @@ async def test_create_connection_async_from_dict(): def test_create_connection_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -596,7 +602,10 @@ def test_create_connection_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 @@ -627,11 +636,16 @@ async def test_create_connection_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_connection_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -661,7 +675,9 @@ def test_create_connection_flattened(): def test_create_connection_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -731,7 +747,8 @@ def test_get_connection( transport: str = "grpc", request_type=connection.GetConnectionRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -785,7 +802,8 @@ async def test_get_connection_async( transport: str = "grpc_asyncio", request_type=connection.GetConnectionRequest ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -836,7 +854,9 @@ async def test_get_connection_async_from_dict(): def test_get_connection_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -856,7 +876,10 @@ def test_get_connection_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 @@ -885,11 +908,16 @@ async def test_get_connection_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_connection_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_connection), "__call__") as call: @@ -898,7 +926,9 @@ def test_get_connection_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_connection(name="name_value",) + client.get_connection( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -909,13 +939,16 @@ def test_get_connection_flattened(): def test_get_connection_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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_connection( - connection.GetConnectionRequest(), name="name_value", + connection.GetConnectionRequest(), + name="name_value", ) @@ -935,7 +968,9 @@ async def test_get_connection_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_connection(name="name_value",) + response = await client.get_connection( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -955,7 +990,8 @@ async def test_get_connection_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_connection( - connection.GetConnectionRequest(), name="name_value", + connection.GetConnectionRequest(), + name="name_value", ) @@ -963,7 +999,8 @@ def test_list_connections( transport: str = "grpc", request_type=connection.ListConnectionsRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1001,7 +1038,8 @@ async def test_list_connections_async( transport: str = "grpc_asyncio", request_type=connection.ListConnectionsRequest ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1012,7 +1050,9 @@ async def test_list_connections_async( with mock.patch.object(type(client.transport.list_connections), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - connection.ListConnectionsResponse(next_page_token="next_page_token_value",) + connection.ListConnectionsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_connections(request) @@ -1035,7 +1075,9 @@ async def test_list_connections_async_from_dict(): def test_list_connections_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -1055,7 +1097,10 @@ def test_list_connections_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 @@ -1084,11 +1129,16 @@ async def test_list_connections_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_connections_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_connections), "__call__") as call: @@ -1097,7 +1147,9 @@ def test_list_connections_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_connections(parent="parent_value",) + client.list_connections( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1108,13 +1160,16 @@ def test_list_connections_flattened(): def test_list_connections_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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_connections( - connection.ListConnectionsRequest(), parent="parent_value", + connection.ListConnectionsRequest(), + parent="parent_value", ) @@ -1134,7 +1189,9 @@ async def test_list_connections_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_connections(parent="parent_value",) + response = await client.list_connections( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1154,12 +1211,15 @@ async def test_list_connections_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_connections( - connection.ListConnectionsRequest(), parent="parent_value", + connection.ListConnectionsRequest(), + parent="parent_value", ) def test_list_connections_pager(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials,) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_connections), "__call__") as call: @@ -1173,12 +1233,21 @@ def test_list_connections_pager(): ], next_page_token="abc", ), - connection.ListConnectionsResponse(connections=[], next_page_token="def",), connection.ListConnectionsResponse( - connections=[connection.Connection(),], next_page_token="ghi", + connections=[], + next_page_token="def", + ), + connection.ListConnectionsResponse( + connections=[ + connection.Connection(), + ], + next_page_token="ghi", ), connection.ListConnectionsResponse( - connections=[connection.Connection(), connection.Connection(),], + connections=[ + connection.Connection(), + connection.Connection(), + ], ), RuntimeError, ) @@ -1197,7 +1266,9 @@ def test_list_connections_pager(): def test_list_connections_pages(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials,) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_connections), "__call__") as call: @@ -1211,12 +1282,21 @@ def test_list_connections_pages(): ], next_page_token="abc", ), - connection.ListConnectionsResponse(connections=[], next_page_token="def",), connection.ListConnectionsResponse( - connections=[connection.Connection(),], next_page_token="ghi", + connections=[], + next_page_token="def", + ), + connection.ListConnectionsResponse( + connections=[ + connection.Connection(), + ], + next_page_token="ghi", ), connection.ListConnectionsResponse( - connections=[connection.Connection(), connection.Connection(),], + connections=[ + connection.Connection(), + connection.Connection(), + ], ), RuntimeError, ) @@ -1227,7 +1307,9 @@ def test_list_connections_pages(): @pytest.mark.asyncio async def test_list_connections_async_pager(): - client = ConnectionServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ConnectionServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1243,16 +1325,27 @@ async def test_list_connections_async_pager(): ], next_page_token="abc", ), - connection.ListConnectionsResponse(connections=[], next_page_token="def",), connection.ListConnectionsResponse( - connections=[connection.Connection(),], next_page_token="ghi", + connections=[], + next_page_token="def", ), connection.ListConnectionsResponse( - connections=[connection.Connection(), connection.Connection(),], + connections=[ + connection.Connection(), + ], + next_page_token="ghi", + ), + connection.ListConnectionsResponse( + connections=[ + connection.Connection(), + connection.Connection(), + ], ), RuntimeError, ) - async_pager = await client.list_connections(request={},) + async_pager = await client.list_connections( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1264,7 +1357,9 @@ async def test_list_connections_async_pager(): @pytest.mark.asyncio async def test_list_connections_async_pages(): - client = ConnectionServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ConnectionServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1280,12 +1375,21 @@ async def test_list_connections_async_pages(): ], next_page_token="abc", ), - connection.ListConnectionsResponse(connections=[], next_page_token="def",), connection.ListConnectionsResponse( - connections=[connection.Connection(),], next_page_token="ghi", + connections=[], + next_page_token="def", ), connection.ListConnectionsResponse( - connections=[connection.Connection(), connection.Connection(),], + connections=[ + connection.Connection(), + ], + next_page_token="ghi", + ), + connection.ListConnectionsResponse( + connections=[ + connection.Connection(), + connection.Connection(), + ], ), RuntimeError, ) @@ -1300,7 +1404,8 @@ def test_update_connection( transport: str = "grpc", request_type=gcbc_connection.UpdateConnectionRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1359,7 +1464,8 @@ async def test_update_connection_async( request_type=gcbc_connection.UpdateConnectionRequest, ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1412,7 +1518,9 @@ async def test_update_connection_async_from_dict(): def test_update_connection_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -1434,7 +1542,10 @@ def test_update_connection_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 @@ -1465,11 +1576,16 @@ async def test_update_connection_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_update_connection_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1499,7 +1615,9 @@ def test_update_connection_flattened(): def test_update_connection_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1569,7 +1687,8 @@ def test_delete_connection( transport: str = "grpc", request_type=connection.DeleteConnectionRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1604,7 +1723,8 @@ async def test_delete_connection_async( transport: str = "grpc_asyncio", request_type=connection.DeleteConnectionRequest ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1636,7 +1756,9 @@ async def test_delete_connection_async_from_dict(): def test_delete_connection_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -1658,7 +1780,10 @@ def test_delete_connection_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 @@ -1687,11 +1812,16 @@ async def test_delete_connection_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_connection_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1702,7 +1832,9 @@ def test_delete_connection_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_connection(name="name_value",) + client.delete_connection( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1713,13 +1845,16 @@ def test_delete_connection_flattened(): def test_delete_connection_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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_connection( - connection.DeleteConnectionRequest(), name="name_value", + connection.DeleteConnectionRequest(), + name="name_value", ) @@ -1739,7 +1874,9 @@ async def test_delete_connection_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_connection(name="name_value",) + response = await client.delete_connection( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1759,7 +1896,8 @@ async def test_delete_connection_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_connection( - connection.DeleteConnectionRequest(), name="name_value", + connection.DeleteConnectionRequest(), + name="name_value", ) @@ -1767,7 +1905,8 @@ def test_get_iam_policy( transport: str = "grpc", request_type=iam_policy.GetIamPolicyRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1777,7 +1916,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) @@ -1805,7 +1947,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1816,7 +1959,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) @@ -1841,7 +1987,9 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -1861,7 +2009,10 @@ 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 @@ -1888,11 +2039,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 = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -1908,7 +2064,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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: @@ -1917,7 +2075,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. @@ -1928,13 +2088,16 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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", ) @@ -1952,7 +2115,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. @@ -1972,7 +2137,8 @@ async def test_get_iam_policy_flattened_error_async(): # 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", ) @@ -1980,7 +2146,8 @@ def test_set_iam_policy( transport: str = "grpc", request_type=iam_policy.SetIamPolicyRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1990,7 +2157,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) @@ -2018,7 +2188,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2029,7 +2200,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) @@ -2054,7 +2228,9 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -2074,7 +2250,10 @@ 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 @@ -2101,11 +2280,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 = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -2121,7 +2305,9 @@ def test_set_iam_policy_from_dict_foreign(): def test_set_iam_policy_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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: @@ -2130,7 +2316,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. @@ -2141,13 +2329,16 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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", ) @@ -2165,7 +2356,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. @@ -2185,7 +2378,8 @@ async def test_set_iam_policy_flattened_error_async(): # 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", ) @@ -2193,7 +2387,8 @@ def test_test_iam_permissions( transport: str = "grpc", request_type=iam_policy.TestIamPermissionsRequest ): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2233,7 +2428,8 @@ async def test_test_iam_permissions_async( transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest ): client = ConnectionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2246,7 +2442,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) @@ -2269,7 +2467,9 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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. @@ -2291,7 +2491,10 @@ 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 @@ -2322,11 +2525,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 = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + 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__" @@ -2344,7 +2552,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2356,7 +2566,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 @@ -2370,7 +2581,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2401,7 +2614,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 @@ -2437,7 +2651,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2456,7 +2671,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ConnectionServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2501,8 +2717,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = ConnectionServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.ConnectionServiceGrpcTransport,) + client = ConnectionServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.ConnectionServiceGrpcTransport, + ) def test_connection_service_base_transport_error(): @@ -2551,7 +2772,8 @@ def test_connection_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (credentials.AnonymousCredentials(), None) transport = transports.ConnectionServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2630,7 +2852,8 @@ def test_connection_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.ConnectionServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2642,7 +2865,8 @@ def test_connection_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.ConnectionServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2748,8 +2972,12 @@ def test_connection_path(): location = "clam" connection = "whelk" - expected = "projects/{project}/locations/{location}/connections/{connection}".format( - project=project, location=location, connection=connection, + expected = ( + "projects/{project}/locations/{location}/connections/{connection}".format( + project=project, + location=location, + connection=connection, + ) ) actual = ConnectionServiceClient.connection_path(project, location, connection) assert expected == actual @@ -2792,7 +3020,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = ConnectionServiceClient.common_folder_path(folder) assert expected == actual @@ -2811,7 +3041,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = ConnectionServiceClient.common_organization_path(organization) assert expected == actual @@ -2830,7 +3062,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = ConnectionServiceClient.common_project_path(project) assert expected == actual @@ -2851,7 +3085,8 @@ def test_common_location_path(): location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = ConnectionServiceClient.common_location_path(project, location) assert expected == actual @@ -2876,7 +3111,8 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ConnectionServiceTransport, "_prep_wrapped_messages" ) as prep: client = ConnectionServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2885,6 +3121,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ConnectionServiceClient.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)