From 55f029a64a0e903e4898becec32ecd515bf3823c Mon Sep 17 00:00:00 2001 From: Charles Salmon Date: Mon, 10 Dec 2018 18:14:45 +1300 Subject: [PATCH] Ensure that `ManagedZone:exists()` does not misreport `True` result. The behaviour of the `MangedZones: get` API is such that when only the `id` field of a non-existent `ManagedZone` is requested, a 200 status code response with body `{}` is returned. This is arguably undesirable behaviour, however this patch serves to ensure that the Python SDK works with what is there. --- dns/google/cloud/dns/zone.py | 4 +--- dns/tests/unit/test_zone.py | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/dns/google/cloud/dns/zone.py b/dns/google/cloud/dns/zone.py index 1f664fcf9011..bd98db4f5eb6 100644 --- a/dns/google/cloud/dns/zone.py +++ b/dns/google/cloud/dns/zone.py @@ -280,9 +280,7 @@ def exists(self, client=None): client = self._require_client(client) try: - client._connection.api_request( - method="GET", path=self.path, query_params={"fields": "id"} - ) + client._connection.api_request(method="GET", path=self.path) except NotFound: return False else: diff --git a/dns/tests/unit/test_zone.py b/dns/tests/unit/test_zone.py index e9a147729fce..21d55bcc1b65 100644 --- a/dns/tests/unit/test_zone.py +++ b/dns/tests/unit/test_zone.py @@ -330,7 +330,6 @@ def test_exists_miss_w_bound_client(self): req = conn._requested[0] self.assertEqual(req["method"], "GET") self.assertEqual(req["path"], "/%s" % PATH) - self.assertEqual(req["query_params"], {"fields": "id"}) def test_exists_hit_w_alternate_client(self): PATH = "projects/%s/managedZones/%s" % (self.PROJECT, self.ZONE_NAME) @@ -347,7 +346,6 @@ def test_exists_hit_w_alternate_client(self): req = conn2._requested[0] self.assertEqual(req["method"], "GET") self.assertEqual(req["path"], "/%s" % PATH) - self.assertEqual(req["query_params"], {"fields": "id"}) def test_reload_w_bound_client(self): PATH = "projects/%s/managedZones/%s" % (self.PROJECT, self.ZONE_NAME)