From 44eeeb49ceedbdf7c6bd6cacdff291285b5302e4 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 7 May 2021 13:49:50 -0400 Subject: [PATCH] refactor: rename 'Client._get_path' -> '_get_resource' For parity with forthcoming '_put_resource', '_patch_resource', '_post_resource', and '_delete_resource' methods. Toward #38. --- google/cloud/storage/_helpers.py | 2 +- google/cloud/storage/acl.py | 2 +- google/cloud/storage/blob.py | 6 +- google/cloud/storage/bucket.py | 6 +- google/cloud/storage/client.py | 4 +- google/cloud/storage/hmac_key.py | 4 +- google/cloud/storage/notification.py | 4 +- tests/unit/test__helpers.py | 24 +++--- tests/unit/test_acl.py | 18 ++--- tests/unit/test_blob.py | 54 +++++++------- tests/unit/test_bucket.py | 106 +++++++++++++-------------- tests/unit/test_client.py | 56 +++++++------- tests/unit/test_hmac_key.py | 24 +++--- tests/unit/test_notification.py | 32 ++++---- 14 files changed, 171 insertions(+), 171 deletions(-) diff --git a/google/cloud/storage/_helpers.py b/google/cloud/storage/_helpers.py index 8c7766ec7..a126c9e02 100644 --- a/google/cloud/storage/_helpers.py +++ b/google/cloud/storage/_helpers.py @@ -215,7 +215,7 @@ def reload( if_metageneration_match=if_metageneration_match, if_metageneration_not_match=if_metageneration_not_match, ) - api_response = client._get_path( + api_response = client._get_resource( self.path, query_params=query_params, headers=self._encryption_headers(), diff --git a/google/cloud/storage/acl.py b/google/cloud/storage/acl.py index f56b14cb4..b80447b9d 100644 --- a/google/cloud/storage/acl.py +++ b/google/cloud/storage/acl.py @@ -466,7 +466,7 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): self.entities.clear() - found = client._get_path( + found = client._get_resource( path, query_params=query_params, timeout=timeout, retry=retry, ) self.loaded = True diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index c102f37d5..a105053de 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.py @@ -704,7 +704,7 @@ def exists( try: # We intentionally pass `_target_object=None` since fields=name # would limit the local properties. - client._get_path( + client._get_resource( self.path, query_params=query_params, timeout=timeout, @@ -2828,7 +2828,7 @@ def get_iam_policy( if requested_policy_version is not None: query_params["optionsRequestedPolicyVersion"] = requested_policy_version - info = client._get_path( + info = client._get_resource( "%s/iam" % (self.path,), query_params=query_params, timeout=timeout, @@ -2968,7 +2968,7 @@ def test_iam_permissions( query_params["userProject"] = self.user_project path = "%s/iam/testPermissions" % (self.path,) - resp = client._get_path( + resp = client._get_resource( path, query_params=query_params, timeout=timeout, diff --git a/google/cloud/storage/bucket.py b/google/cloud/storage/bucket.py index 2d8c88b0a..aacc2efe5 100644 --- a/google/cloud/storage/bucket.py +++ b/google/cloud/storage/bucket.py @@ -786,7 +786,7 @@ def exists( try: # We intentionally pass `_target_object=None` since fields=name # would limit the local properties. - client._get_path( + client._get_resource( self.path, query_params=query_params, timeout=timeout, @@ -2881,7 +2881,7 @@ def get_iam_policy( if requested_policy_version is not None: query_params["optionsRequestedPolicyVersion"] = requested_policy_version - info = client._get_path( + info = client._get_resource( "%s/iam" % (self.path,), query_params=query_params, timeout=timeout, @@ -3006,7 +3006,7 @@ def test_iam_permissions( query_params["userProject"] = self.user_project path = "%s/iam/testPermissions" % (self.path,) - resp = client._get_path( + resp = client._get_resource( path, query_params=query_params, timeout=timeout, diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 62446c8e7..848012725 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -286,7 +286,7 @@ def get_service_account_email( project = self.project path = "/projects/%s/serviceAccount" % (project,) - api_response = self._get_path(path, timeout=timeout, retry=retry) + api_response = self._get_resource(path, timeout=timeout, retry=retry) return api_response["email_address"] def bucket(self, bucket_name, user_project=None): @@ -320,7 +320,7 @@ def batch(self): """ return Batch(client=self) - def _get_path( + def _get_resource( self, path, query_params=None, diff --git a/google/cloud/storage/hmac_key.py b/google/cloud/storage/hmac_key.py index 74affb0e0..c6cc17a85 100644 --- a/google/cloud/storage/hmac_key.py +++ b/google/cloud/storage/hmac_key.py @@ -222,7 +222,7 @@ def exists(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): if self.user_project is not None: qs_params["userProject"] = self.user_project - self._client._get_path( + self._client._get_resource( self.path, query_params=qs_params, timeout=timeout, retry=retry, ) except NotFound: @@ -262,7 +262,7 @@ def reload(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): if self.user_project is not None: qs_params["userProject"] = self.user_project - self._properties = self._client._get_path( + self._properties = self._client._get_resource( self.path, query_params=qs_params, timeout=timeout, retry=retry, ) diff --git a/google/cloud/storage/notification.py b/google/cloud/storage/notification.py index 2523c2243..5389ab51e 100644 --- a/google/cloud/storage/notification.py +++ b/google/cloud/storage/notification.py @@ -323,7 +323,7 @@ def exists(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): query_params["userProject"] = self.bucket.user_project try: - client._get_path( + client._get_resource( self.path, query_params=query_params, timeout=timeout, retry=retry, ) except NotFound: @@ -377,7 +377,7 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): if self.bucket.user_project is not None: query_params["userProject"] = self.bucket.user_project - response = client._get_path( + response = client._get_resource( self.path, query_params=query_params, timeout=timeout, retry=retry, ) self._set_properties(response) diff --git a/tests/unit/test__helpers.py b/tests/unit/test__helpers.py index 90172c864..f1c6b0436 100644 --- a/tests/unit/test__helpers.py +++ b/tests/unit/test__helpers.py @@ -112,8 +112,8 @@ def test__query_params_w_user_project(self): def test_reload_w_defaults(self): path = "/path" response = {"foo": "Foo"} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = response derived = self._derivedClass(path)() # Make sure changes is not a set instance before calling reload # (which will clear / replace it with an empty set), checked below. @@ -127,7 +127,7 @@ def test_reload_w_defaults(self): expected_query_params = {"projection": "noAcl"} expected_headers = {} # no encryption headers by default - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( path, query_params=expected_query_params, headers=expected_headers, @@ -142,8 +142,8 @@ def test_reload_w_generation_match_w_timeout(self): path = "/path" timeout = 42 response = {"foo": "Foo"} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = response derived = self._derivedClass(path)() # Make sure changes is not a set instance before calling reload # (which will clear / replace it with an empty set), checked below. @@ -165,7 +165,7 @@ def test_reload_w_generation_match_w_timeout(self): "ifMetagenerationMatch": metageneration_number, } expected_headers = {} # no encryption headers by default - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( path, query_params=expected_query_params, headers=expected_headers, @@ -179,8 +179,8 @@ def test_reload_w_user_project_w_retry(self): path = "/path" retry = mock.Mock(spec=[]) response = {"foo": "Foo"} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = response derived = self._derivedClass(path, user_project)() # Make sure changes is not a set instance before calling reload # (which will clear / replace it with an empty set), checked below. @@ -197,7 +197,7 @@ def test_reload_w_user_project_w_retry(self): "userProject": user_project, } expected_headers = {} # no encryption headers by default - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( path, query_params=expected_query_params, headers=expected_headers, @@ -210,8 +210,8 @@ def test_reload_w_projection_w_explicit_client_w_enc_header(self): path = "/path" response = {"foo": "Foo"} encryption_headers = {"bar": "Bar"} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = response derived = self._derivedClass(path)() # Make sure changes is not a set instance before calling reload # (which will clear / replace it with an empty set), checked below. @@ -224,7 +224,7 @@ def test_reload_w_projection_w_explicit_client_w_enc_header(self): self.assertEqual(derived._changes, set()) expected_query_params = {"projection": "full"} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( path, query_params=expected_query_params, headers=encryption_headers, diff --git a/tests/unit/test_acl.py b/tests/unit/test_acl.py index e08238ae6..7cea5c8fc 100644 --- a/tests/unit/test_acl.py +++ b/tests/unit/test_acl.py @@ -546,15 +546,15 @@ class Derived(self._get_target_class()): acl.reload_path = reload_path acl.loaded = True acl.entity("allUsers", role) - client = acl.client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = acl.client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response acl.reload() self.assertEqual(list(acl), []) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( reload_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -571,8 +571,8 @@ def test_reload_w_empty_result_w_timeout_w_retry_w_explicit_client(self): acl.reload_path = reload_path acl.loaded = True acl.entity("allUsers", role) - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response acl.reload(client=client, timeout=timeout, retry=retry) @@ -580,7 +580,7 @@ def test_reload_w_empty_result_w_timeout_w_retry_w_explicit_client(self): self.assertEqual(list(acl), []) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( reload_path, query_params=expected_query_params, timeout=timeout, @@ -596,8 +596,8 @@ def test_reload_w_nonempty_result_w_user_project(self): acl.reload_path = reload_path acl.loaded = True acl.user_project = user_project - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response acl.reload(client=client) @@ -605,7 +605,7 @@ def test_reload_w_nonempty_result_w_user_project(self): self.assertEqual(list(acl), [{"entity": "allUsers", "role": role}]) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( reload_path, query_params=expected_query_params, timeout=self._get_default_timeout(), diff --git a/tests/unit/test_blob.py b/tests/unit/test_blob.py index ee3d5aff2..6d8fc7b33 100644 --- a/tests/unit/test_blob.py +++ b/tests/unit/test_blob.py @@ -692,15 +692,15 @@ def test_exists_miss_w_defaults(self): from google.cloud.exceptions import NotFound blob_name = "nonesuch" - client = mock.Mock(spec=["_get_path"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.side_effect = NotFound("testing") bucket = _Bucket(client) blob = self._make_one(blob_name, bucket=bucket) self.assertFalse(blob.exists()) expected_query_params = {"fields": "name"} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( blob.path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -713,15 +713,15 @@ def test_exists_hit_w_user_project_w_timeout(self): user_project = "user-project-123" timeout = 42 api_response = {"name": blob_name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client, user_project=user_project) blob = self._make_one(blob_name, bucket=bucket) self.assertTrue(blob.exists(timeout=timeout)) expected_query_params = {"fields": "name", "userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( blob.path, query_params=expected_query_params, timeout=timeout, @@ -734,15 +734,15 @@ def test_exists_hit_w_generation_w_retry(self): generation = 123456 api_response = {"name": blob_name} retry = mock.Mock(spec=[]) - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client) blob = self._make_one(blob_name, bucket=bucket, generation=generation) self.assertTrue(blob.exists(retry=retry)) expected_query_params = {"fields": "name", "generation": generation} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( blob.path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -755,8 +755,8 @@ def test_exists_w_generation_match(self): generation_number = 123456 metageneration_number = 6 api_response = {"name": blob_name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client) blob = self._make_one(blob_name, bucket=bucket) @@ -773,7 +773,7 @@ def test_exists_w_generation_match(self): "ifGenerationMatch": generation_number, "ifMetagenerationMatch": metageneration_number, } - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( blob.path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -3168,8 +3168,8 @@ def test_get_iam_policy_defaults(self): binding["role"]: set(binding["members"]) for binding in api_response["bindings"] } - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client=client) blob = self._make_one(blob_name, bucket=bucket) @@ -3182,7 +3182,7 @@ def test_get_iam_policy_defaults(self): expected_path = "%s/iam" % (path,) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -3206,8 +3206,8 @@ def test_get_iam_policy_w_user_project_w_timeout(self): "bindings": [], } expected_policy = {} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client=client, user_project=user_project) blob = self._make_one(blob_name, bucket=bucket) @@ -3220,7 +3220,7 @@ def test_get_iam_policy_w_user_project_w_timeout(self): expected_path = "%s/iam" % (path,) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, @@ -3243,8 +3243,8 @@ def test_get_iam_policy_w_requested_policy_version(self): "version": version, "bindings": [{"role": STORAGE_OWNER_ROLE, "members": [owner1, owner2]}], } - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client=client) blob = self._make_one(blob_name, bucket=bucket) @@ -3254,7 +3254,7 @@ def test_get_iam_policy_w_requested_policy_version(self): expected_path = "%s/iam" % (path,) expected_query_params = {"optionsRequestedPolicyVersion": version} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -3361,8 +3361,8 @@ def test_test_iam_permissions_defaults(self): ] expected = permissions[1:] api_response = {"permissions": expected} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client=client) blob = self._make_one(blob_name, bucket=bucket) @@ -3372,7 +3372,7 @@ def test_test_iam_permissions_defaults(self): expected_path = "/b/name/o/%s/iam/testPermissions" % (blob_name,) expected_query_params = {"permissions": permissions} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -3396,8 +3396,8 @@ def test_test_iam_permissions_w_user_project_w_timeout_w_retry(self): ] expected = permissions[1:] api_response = {"permissions": expected} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = _Bucket(client=client, user_project=user_project) blob = self._make_one(blob_name, bucket=bucket) @@ -3410,7 +3410,7 @@ def test_test_iam_permissions_w_user_project_w_timeout_w_retry(self): "permissions": permissions, "userProject": user_project, } - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, diff --git a/tests/unit/test_bucket.py b/tests/unit/test_bucket.py index fe4783a01..5ff2209c7 100644 --- a/tests/unit/test_bucket.py +++ b/tests/unit/test_bucket.py @@ -654,14 +654,14 @@ def test_exists_miss_w_defaults(self): from google.cloud.exceptions import NotFound bucket_name = "bucket-name" - client = mock.Mock(spec=["_get_path"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.side_effect = NotFound("testing") bucket = self._make_one(client, name=bucket_name) self.assertFalse(bucket.exists()) expected_query_params = {"fields": "name"} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( bucket.path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -674,8 +674,8 @@ def test_exists_w_metageneration_match_w_timeout(self): metageneration_number = 6 timeout = 42 api_response = {"name": bucket_name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client, name=bucket_name) self.assertTrue( @@ -686,7 +686,7 @@ def test_exists_w_metageneration_match_w_timeout(self): "fields": "name", "ifMetagenerationMatch": metageneration_number, } - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( bucket.path, query_params=expected_query_params, timeout=timeout, @@ -699,8 +699,8 @@ def test_exists_hit_w_user_project_w_retry_w_explicit_client(self): user_project = "user-project-123" retry = mock.Mock(spec=[]) api_response = {"name": bucket_name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(name=bucket_name, user_project=user_project) self.assertTrue(bucket.exists(client=client, retry=retry)) @@ -709,7 +709,7 @@ def test_exists_hit_w_user_project_w_retry_w_explicit_client(self): "fields": "name", "userProject": user_project, } - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( bucket.path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -748,8 +748,8 @@ def test_get_blob_miss_w_defaults(self): name = "name" blob_name = "nonesuch" - client = mock.Mock(spec=["_get_path"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.side_effect = NotFound("testing") bucket = self._make_one(client, name=name) result = bucket.get_blob(blob_name) @@ -759,7 +759,7 @@ def test_get_blob_miss_w_defaults(self): expected_path = "/b/%s/o/%s" % (name, blob_name) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -768,7 +768,7 @@ def test_get_blob_miss_w_defaults(self): _target_object=mock.ANY, ) - target = client._get_path.call_args[1]["_target_object"] + target = client._get_resource.call_args[1]["_target_object"] self.assertIsInstance(target, Blob) self.assertIs(target.bucket, bucket) self.assertEqual(target.name, blob_name) @@ -780,8 +780,8 @@ def test_get_blob_hit_w_user_project(self): blob_name = "blob-name" user_project = "user-project-123" api_response = {"name": blob_name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client, name=name, user_project=user_project) blob = bucket.get_blob(blob_name, client=client) @@ -796,7 +796,7 @@ def test_get_blob_hit_w_user_project(self): "projection": "noAcl", } expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -813,8 +813,8 @@ def test_get_blob_hit_w_generation_w_timeout(self): generation = 1512565576797178 timeout = 42 api_response = {"name": blob_name, "generation": generation} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client, name=name) blob = bucket.get_blob(blob_name, generation=generation, timeout=timeout) @@ -830,7 +830,7 @@ def test_get_blob_hit_w_generation_w_timeout(self): "projection": "noAcl", } expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -847,8 +847,8 @@ def test_get_blob_w_generation_match_w_retry(self): generation = 1512565576797178 retry = mock.Mock(spec=[]) api_response = {"name": blob_name, "generation": generation} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client, name=name) blob = bucket.get_blob(blob_name, if_generation_match=generation, retry=retry) @@ -864,7 +864,7 @@ def test_get_blob_w_generation_match_w_retry(self): "projection": "noAcl", } expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -882,8 +882,8 @@ def test_get_blob_hit_with_kwargs_w_explicit_client(self): chunk_size = 1024 * 1024 key = b"01234567890123456789012345678901" # 32 bytes api_response = {"name": blob_name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(name=name) blob = bucket.get_blob( @@ -901,7 +901,7 @@ def test_get_blob_hit_with_kwargs_w_explicit_client(self): "projection": "noAcl", } expected_headers = _get_encryption_headers(key) - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -1042,8 +1042,8 @@ def test_get_notification_miss_w_defaults(self): name = "name" notification_id = "1" - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.side_effect = NotFound("testing") client.project = project bucket = self._make_one(client=client, name=name) @@ -1052,7 +1052,7 @@ def test_get_notification_miss_w_defaults(self): expected_path = "/b/{}/notificationConfigs/{}".format(name, notification_id) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -1079,8 +1079,8 @@ def test_get_notification_hit_w_explicit_w_user_project(self): } timeout = 42 retry = mock.Mock(spec=[]) - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.return_value = api_response client.project = project bucket = self._make_one(client=client, name=name, user_project=user_project) @@ -1099,7 +1099,7 @@ def test_get_notification_hit_w_explicit_w_user_project(self): expected_path = "/b/{}/notificationConfigs/{}".format(name, notification_id) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, @@ -1463,8 +1463,8 @@ def test_reload_w_metageneration_match(self): name = "name" metageneration_number = 9 api_response = {"name": name} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client, name=name) bucket.reload(if_metageneration_match=metageneration_number) @@ -1475,7 +1475,7 @@ def test_reload_w_metageneration_match(self): "ifMetagenerationMatch": metageneration_number, } expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -2535,8 +2535,8 @@ def test_get_iam_policy_defaults(self): binding["role"]: set(binding["members"]) for binding in api_response["bindings"] } - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client=client, name=bucket_name) policy = bucket.get_iam_policy() @@ -2548,7 +2548,7 @@ def test_get_iam_policy_defaults(self): expected_path = "/b/%s/iam" % (bucket_name,) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -2572,8 +2572,8 @@ def test_get_iam_policy_w_user_project_w_timeout(self): "bindings": [], } expected_policy = {} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one( client=client, name=bucket_name, user_project=user_project ) @@ -2587,7 +2587,7 @@ def test_get_iam_policy_w_user_project_w_timeout(self): expected_path = "/b/%s/iam" % (bucket_name,) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, @@ -2611,8 +2611,8 @@ def test_get_iam_policy_w_requested_policy_version_w_retry(self): "bindings": [{"role": STORAGE_OWNER_ROLE, "members": [owner1, owner2]}], } retry = mock.Mock(spec=[]) - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client=client, name=bucket_name) policy = bucket.get_iam_policy(requested_policy_version=3, retry=retry) @@ -2621,7 +2621,7 @@ def test_get_iam_policy_w_requested_policy_version_w_retry(self): expected_path = "/b/%s/iam" % (bucket_name,) expected_query_params = {"optionsRequestedPolicyVersion": version} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -2749,8 +2749,8 @@ def test_test_iam_permissions_defaults(self): ] expected = permissions[1:] api_response = {"permissions": expected} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client=client, name=name) found = bucket.test_iam_permissions(permissions) @@ -2760,7 +2760,7 @@ def test_test_iam_permissions_defaults(self): expected_path = "/b/%s/iam/testPermissions" % (name,) expected_query_params = {} expected_query_params = {"permissions": permissions} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -2784,8 +2784,8 @@ def test_test_iam_permissions_w_user_project_w_timeout_w_retry(self): ] expected = permissions[1:] api_response = {"permissions": expected} - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = api_response bucket = self._make_one(client=client, name=name, user_project=user_project) found = bucket.test_iam_permissions(permissions, timeout=timeout, retry=retry) @@ -2797,7 +2797,7 @@ def test_test_iam_permissions_w_user_project_w_timeout_w_retry(self): "permissions": permissions, "userProject": user_project, } - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, @@ -2838,7 +2838,7 @@ def _make_public_w_future_helper(self, default_object_acl_loaded=True): client = _Client(connection) # Temporary workaround until we use real mock client - client._get_path = mock.Mock(return_value={"items": []}) + client._get_resource = mock.Mock(return_value={"items": []}) bucket = self._make_one(client=client, name=NAME) bucket.acl.loaded = True @@ -2862,7 +2862,7 @@ def _make_public_w_future_helper(self, default_object_acl_loaded=True): if not default_object_acl_loaded: expected_path = "/b/%s/defaultObjectAcl" % (NAME,) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -2992,7 +2992,7 @@ def _make_private_w_future_helper(self, default_object_acl_loaded=True): bucket.default_object_acl.loaded = default_object_acl_loaded # Temporary workaround until we use real mock client - client._get_path = mock.Mock(return_value={"items": []}) + client._get_resource = mock.Mock(return_value={"items": []}) bucket.make_private(future=True) self.assertEqual(list(bucket.acl), no_permissions) @@ -3013,7 +3013,7 @@ def _make_private_w_future_helper(self, default_object_acl_loaded=True): if not default_object_acl_loaded: expected_path = "/b/%s/defaultObjectAcl" % (NAME,) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 578ad8dc2..c6a98951e 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -409,7 +409,7 @@ def test_batch(self): self.assertIsInstance(batch, Batch) self.assertIs(batch._client, client) - def test__get_path_miss_w_defaults(self): + def test__get_resource_miss_w_defaults(self): from google.cloud.exceptions import NotFound PROJECT = "PROJECT" @@ -420,7 +420,7 @@ def test__get_path_miss_w_defaults(self): connection = client._base_connection = _make_connection() with self.assertRaises(NotFound): - client._get_path(PATH) + client._get_resource(PATH) connection.api_request.assert_called_once_with( method="GET", @@ -432,7 +432,7 @@ def test__get_path_miss_w_defaults(self): _target_object=None, ) - def test__get_path_hit_w_explicit(self): + def test__get_resource_hit_w_explicit(self): PROJECT = "PROJECT" PATH = "/path/to/something" QUERY_PARAMS = {"foo": "Foo"} @@ -446,7 +446,7 @@ def test__get_path_hit_w_explicit(self): connection = client._base_connection = _make_connection(expected) target = mock.Mock(spec={}) - found = client._get_path( + found = client._get_resource( PATH, query_params=QUERY_PARAMS, headers=HEADERS, @@ -474,8 +474,8 @@ def test_get_bucket_miss_w_string_w_defaults(self): project = "PROJECT" credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock() - client._get_path.side_effect = NotFound("testing") + client._get_resource = mock.Mock() + client._get_resource.side_effect = NotFound("testing") bucket_name = "nonesuch" with self.assertRaises(NotFound): @@ -484,7 +484,7 @@ def test_get_bucket_miss_w_string_w_defaults(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -493,7 +493,7 @@ def test_get_bucket_miss_w_string_w_defaults(self): _target_object=mock.ANY, ) - target = client._get_path.call_args[1]["_target_object"] + target = client._get_resource.call_args[1]["_target_object"] self.assertIsInstance(target, Bucket) self.assertEqual(target.name, bucket_name) @@ -506,7 +506,7 @@ def test_get_bucket_hit_w_string_w_timeout(self): api_response = {"name": bucket_name} credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket = client.get_bucket(bucket_name, timeout=timeout) @@ -516,7 +516,7 @@ def test_get_bucket_hit_w_string_w_timeout(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -534,7 +534,7 @@ def test_get_bucket_hit_w_string_w_metageneration_match(self): api_response = {"name": bucket_name} credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket = client.get_bucket( bucket_name, if_metageneration_match=metageneration_number @@ -549,7 +549,7 @@ def test_get_bucket_hit_w_string_w_metageneration_match(self): "ifMetagenerationMatch": metageneration_number, } expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -567,7 +567,7 @@ def test_get_bucket_miss_w_object_w_retry(self): retry = mock.Mock(spec=[]) credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(side_effect=NotFound("testing")) + client._get_resource = mock.Mock(side_effect=NotFound("testing")) bucket_obj = Bucket(client, bucket_name) with self.assertRaises(NotFound): @@ -576,7 +576,7 @@ def test_get_bucket_miss_w_object_w_retry(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -585,7 +585,7 @@ def test_get_bucket_miss_w_object_w_retry(self): _target_object=mock.ANY, ) - target = client._get_path.call_args[1]["_target_object"] + target = client._get_resource.call_args[1]["_target_object"] self.assertIsInstance(target, Bucket) self.assertEqual(target.name, bucket_name) @@ -597,7 +597,7 @@ def test_get_bucket_hit_w_object_defaults(self): api_response = {"name": bucket_name} credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket_obj = Bucket(client, bucket_name) bucket = client.get_bucket(bucket_obj) @@ -608,7 +608,7 @@ def test_get_bucket_hit_w_object_defaults(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -625,7 +625,7 @@ def test_get_bucket_hit_w_object_w_retry_none(self): api_response = {"name": bucket_name} credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket_obj = Bucket(client, bucket_name) bucket = client.get_bucket(bucket_obj, retry=None) @@ -636,7 +636,7 @@ def test_get_bucket_hit_w_object_w_retry_none(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -653,7 +653,7 @@ def test_lookup_bucket_miss_w_defaults(self): bucket_name = "nonesuch" credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(side_effect=NotFound("testing")) + client._get_resource = mock.Mock(side_effect=NotFound("testing")) bucket = client.lookup_bucket(bucket_name) @@ -662,7 +662,7 @@ def test_lookup_bucket_miss_w_defaults(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -671,7 +671,7 @@ def test_lookup_bucket_miss_w_defaults(self): _target_object=mock.ANY, ) - target = client._get_path.call_args[1]["_target_object"] + target = client._get_resource.call_args[1]["_target_object"] self.assertIsInstance(target, Bucket) self.assertEqual(target.name, bucket_name) @@ -684,7 +684,7 @@ def test_lookup_bucket_hit_w_timeout(self): api_response = {"name": bucket_name} credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket = client.lookup_bucket(bucket_name, timeout=timeout) @@ -694,7 +694,7 @@ def test_lookup_bucket_hit_w_timeout(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -712,7 +712,7 @@ def test_lookup_bucket_hit_w_metageneration_match(self): credentials = _make_credentials() metageneration_number = 6 client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket = client.lookup_bucket( bucket_name, if_metageneration_match=metageneration_number @@ -727,7 +727,7 @@ def test_lookup_bucket_hit_w_metageneration_match(self): "ifMetagenerationMatch": metageneration_number, } expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, @@ -744,7 +744,7 @@ def test_lookup_bucket_hit_w_retry(self): api_response = {"name": bucket_name} credentials = _make_credentials() client = self._make_one(project=project, credentials=credentials) - client._get_path = mock.Mock(return_value=api_response) + client._get_resource = mock.Mock(return_value=api_response) bucket_obj = Bucket(client, bucket_name) bucket = client.lookup_bucket(bucket_obj, retry=None) @@ -755,7 +755,7 @@ def test_lookup_bucket_hit_w_retry(self): expected_path = "/b/%s" % (bucket_name,) expected_query_params = {"projection": "noAcl"} expected_headers = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, headers=expected_headers, diff --git a/tests/unit/test_hmac_key.py b/tests/unit/test_hmac_key.py index 2cd8f2389..06b3a65c5 100644 --- a/tests/unit/test_hmac_key.py +++ b/tests/unit/test_hmac_key.py @@ -223,8 +223,8 @@ def test_exists_miss_w_defaults(self): access_id = "ACCESS-ID" project = "PROJECT" - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.side_effect = NotFound("testing") client.project = project metadata = self._make_one(client) metadata._properties["accessId"] = access_id @@ -233,7 +233,7 @@ def test_exists_miss_w_defaults(self): expected_path = "/projects/{}/hmacKeys/{}".format(project, access_id) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -252,8 +252,8 @@ def test_exists_hit_w_explicit_w_user_project(self): } timeout = 42 retry = mock.Mock(spec=[]) - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = resource + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = resource metadata = self._make_one(client, user_project=user_project) metadata._properties["accessId"] = access_id metadata._properties["projectId"] = project @@ -262,7 +262,7 @@ def test_exists_hit_w_explicit_w_user_project(self): expected_path = "/projects/{}/hmacKeys/{}".format(project, access_id) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, @@ -274,8 +274,8 @@ def test_reload_miss_w_defaults(self): access_id = "ACCESS-ID" project = "PROJECT" - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.side_effect = NotFound("testing") client.project = project metadata = self._make_one(client) metadata._properties["accessId"] = access_id @@ -285,7 +285,7 @@ def test_reload_miss_w_defaults(self): expected_path = "/projects/{}/hmacKeys/{}".format(project, access_id) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -304,8 +304,8 @@ def test_reload_hit_w_project_set(self): } timeout = 42 retry = mock.Mock(spec=[]) - client = mock.Mock(spec=["_get_path"]) - client._get_path.return_value = resource + client = mock.Mock(spec=["_get_resource"]) + client._get_resource.return_value = resource metadata = self._make_one(client, user_project=user_project) metadata._properties["accessId"] = access_id metadata._properties["projectId"] = project @@ -316,7 +316,7 @@ def test_reload_hit_w_project_set(self): expected_path = "/projects/{}/hmacKeys/{}".format(project, access_id) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( expected_path, query_params=expected_query_params, timeout=timeout, diff --git a/tests/unit/test_notification.py b/tests/unit/test_notification.py index 00829d31e..e8cee0478 100644 --- a/tests/unit/test_notification.py +++ b/tests/unit/test_notification.py @@ -327,7 +327,7 @@ def test_create_w_explicit_client(self): ) def test_exists_wo_notification_id(self): - client = mock.Mock(spec=["_get_path", "project"]) + client = mock.Mock(spec=["_get_resource", "project"]) client.project = self.BUCKET_PROJECT bucket = self._make_bucket(client) notification = self._make_one(bucket, self.TOPIC_NAME) @@ -335,13 +335,13 @@ def test_exists_wo_notification_id(self): with self.assertRaises(ValueError): notification.exists() - client._get_path.assert_not_called() + client._get_resource.assert_not_called() def test_exists_miss_w_defaults(self): from google.cloud.exceptions import NotFound - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.side_effect = NotFound("testing") client.project = self.BUCKET_PROJECT bucket = self._make_bucket(client) notification = self._make_one(bucket, self.TOPIC_NAME) @@ -350,7 +350,7 @@ def test_exists_miss_w_defaults(self): self.assertFalse(notification.exists()) expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( self.NOTIFICATION_PATH, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -365,8 +365,8 @@ def test_exists_hit_w_explicit_w_user_project(self): "etag": self.ETAG, "selfLink": self.SELF_LINK, } - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.return_vale = api_response + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.return_vale = api_response client.project = self.BUCKET_PROJECT bucket = self._make_bucket(client, user_project=user_project) notification = self._make_one(bucket, self.TOPIC_NAME) @@ -379,7 +379,7 @@ def test_exists_hit_w_explicit_w_user_project(self): ) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( self.NOTIFICATION_PATH, query_params=expected_query_params, timeout=timeout, @@ -387,7 +387,7 @@ def test_exists_hit_w_explicit_w_user_project(self): ) def test_reload_wo_notification_id(self): - client = mock.Mock(spec=["_get_path", "project"]) + client = mock.Mock(spec=["_get_resource", "project"]) client.project = self.BUCKET_PROJECT bucket = self._make_bucket(client) notification = self._make_one(bucket, self.TOPIC_NAME) @@ -395,13 +395,13 @@ def test_reload_wo_notification_id(self): with self.assertRaises(ValueError): notification.reload() - client._get_path.assert_not_called() + client._get_resource.assert_not_called() def test_reload_miss_w_defaults(self): from google.cloud.exceptions import NotFound - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.side_effect = NotFound("testing") + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.side_effect = NotFound("testing") client.project = self.BUCKET_PROJECT bucket = self._make_bucket(client) notification = self._make_one(bucket, self.TOPIC_NAME) @@ -411,7 +411,7 @@ def test_reload_miss_w_defaults(self): notification.reload() expected_query_params = {} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( self.NOTIFICATION_PATH, query_params=expected_query_params, timeout=self._get_default_timeout(), @@ -429,8 +429,8 @@ def test_reload_hit_w_explicit_w_user_project(self): "selfLink": self.SELF_LINK, "payload_format": NONE_PAYLOAD_FORMAT, } - client = mock.Mock(spec=["_get_path", "project"]) - client._get_path.return_value = api_response + client = mock.Mock(spec=["_get_resource", "project"]) + client._get_resource.return_value = api_response client.project = self.BUCKET_PROJECT bucket = self._make_bucket(client, user_project=user_project) notification = self._make_one(bucket, self.TOPIC_NAME) @@ -448,7 +448,7 @@ def test_reload_hit_w_explicit_w_user_project(self): self.assertEqual(notification.payload_format, NONE_PAYLOAD_FORMAT) expected_query_params = {"userProject": user_project} - client._get_path.assert_called_once_with( + client._get_resource.assert_called_once_with( self.NOTIFICATION_PATH, query_params=expected_query_params, timeout=timeout,