diff --git a/google/cloud/spanner_v1/client.py b/google/cloud/spanner_v1/client.py index 0759fcff23..52bc796431 100644 --- a/google/cloud/spanner_v1/client.py +++ b/google/cloud/spanner_v1/client.py @@ -192,7 +192,10 @@ def __init__( # will have no impact since the _http() @property only lazily # creates a working HTTP object. super(Client, self).__init__( - project=project, credentials=credentials, _http=None + project=project, + credentials=credentials, + client_options=client_options, + _http=None, ) self._client_info = client_info diff --git a/setup.py b/setup.py index eeddbb6932..498179106f 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ release_status = "Development Status :: 5 - Production/Stable" dependencies = [ "google-api-core[grpc, grpcgcp] >= 1.14.0, < 2.0.0dev", - "google-cloud-core >= 1.0.3, < 2.0dev", + "google-cloud-core >= 1.4.1, < 2.0dev", "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", ] extras = {} diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 09cf61f9ab..7874ae68e9 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -223,12 +223,13 @@ def test_constructor_custom_query_options_env_config(self, mock_ver): @mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") def test_instance_admin_api(self, mock_em): from google.cloud.spanner_v1.client import SPANNER_ADMIN_SCOPE + from google.api_core.client_options import ClientOptions mock_em.return_value = None credentials = _make_credentials() client_info = mock.Mock() - client_options = mock.Mock() + client_options = ClientOptions(quota_project_id="QUOTA-PROJECT") client = self._make_one( project=self.PROJECT, credentials=credentials, @@ -248,19 +249,19 @@ def test_instance_admin_api(self, mock_em): self.assertIs(again, api) instance_admin_client.assert_called_once_with( - credentials=credentials.with_scopes.return_value, - client_info=client_info, - client_options=client_options, + credentials=mock.ANY, client_info=client_info, client_options=client_options ) credentials.with_scopes.assert_called_once_with(expected_scopes) @mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") def test_instance_admin_api_emulator_env(self, mock_em): + from google.api_core.client_options import ClientOptions + mock_em.return_value = "emulator.host" credentials = _make_credentials() client_info = mock.Mock() - client_options = mock.Mock() + client_options = ClientOptions(api_endpoint="endpoint") client = self._make_one( project=self.PROJECT, credentials=credentials, @@ -321,11 +322,12 @@ def test_instance_admin_api_emulator_code(self): @mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") def test_database_admin_api(self, mock_em): from google.cloud.spanner_v1.client import SPANNER_ADMIN_SCOPE + from google.api_core.client_options import ClientOptions mock_em.return_value = None credentials = _make_credentials() client_info = mock.Mock() - client_options = mock.Mock() + client_options = ClientOptions(quota_project_id="QUOTA-PROJECT") client = self._make_one( project=self.PROJECT, credentials=credentials, @@ -345,19 +347,19 @@ def test_database_admin_api(self, mock_em): self.assertIs(again, api) database_admin_client.assert_called_once_with( - credentials=credentials.with_scopes.return_value, - client_info=client_info, - client_options=client_options, + credentials=mock.ANY, client_info=client_info, client_options=client_options ) credentials.with_scopes.assert_called_once_with(expected_scopes) @mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") def test_database_admin_api_emulator_env(self, mock_em): + from google.api_core.client_options import ClientOptions + mock_em.return_value = "host:port" credentials = _make_credentials() client_info = mock.Mock() - client_options = mock.Mock() + client_options = ClientOptions(api_endpoint="endpoint") client = self._make_one( project=self.PROJECT, credentials=credentials,