Skip to content

Commit

Permalink
test: update tests to support latest google-cloud-core (#23)
Browse files Browse the repository at this point in the history
* test: update tests to support latest google-cloud-core

`google-cloud-core` version 1.4.2 populates `prettyPrint=false` by
default. Update the connection tests to expect a value for
`prettyPrint`.
  • Loading branch information
tswast committed Oct 5, 2020
1 parent 1b75bde commit 47f8458
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions tests/unit/test__http.py
Expand Up @@ -28,9 +28,33 @@ def _make_one(self, *args, **kw):
return self._get_target_class()(*args, **kw)

def test_build_api_url_no_extra_query_params(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit

conn = self._make_one(object())
URI = "/".join([conn.API_BASE_URL, "dns", conn.API_VERSION, "foo"])
self.assertEqual(conn.build_api_url("/foo"), URI)
uri = conn.build_api_url("/foo")
scheme, netloc, path, qs, _ = urlsplit(uri)
self.assertEqual("%s://%s" % (scheme, netloc), conn.API_BASE_URL)
self.assertEqual(path, "/".join(["", "dns", conn.API_VERSION, "foo"]))
parms = dict(parse_qsl(qs))
pretty_print = parms.pop("prettyPrint", "false")
self.assertEqual(pretty_print, "false")
self.assertEqual(parms, {})

def test_build_api_url_w_custom_endpoint(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit

custom_endpoint = "https://foo-dns.googleapis.com"
conn = self._make_one(object(), api_endpoint=custom_endpoint)
uri = conn.build_api_url("/foo")
scheme, netloc, path, qs, _ = urlsplit(uri)
self.assertEqual("%s://%s" % (scheme, netloc), custom_endpoint)
self.assertEqual(path, "/".join(["", "dns", conn.API_VERSION, "foo"]))
parms = dict(parse_qsl(qs))
pretty_print = parms.pop("prettyPrint", "false")
self.assertEqual(pretty_print, "false")
self.assertEqual(parms, {})

def test_build_api_url_w_extra_query_params(self):
from six.moves.urllib.parse import parse_qsl
Expand All @@ -44,12 +68,6 @@ def test_build_api_url_w_extra_query_params(self):
parms = dict(parse_qsl(qs))
self.assertEqual(parms["bar"], "baz")

def test_build_api_url_w_custom_endpoint(self):
custom_endpoint = "https://foo-dns.googleapis.com"
conn = self._make_one(object(), api_endpoint=custom_endpoint)
URI = "/".join([custom_endpoint, "dns", conn.API_VERSION, "foo"])
self.assertEqual(conn.build_api_url("/foo"), URI)

def test_extra_headers(self):
import requests
from google.cloud import _http as base_http
Expand Down

0 comments on commit 47f8458

Please sign in to comment.