Skip to content

Commit

Permalink
test: update tests to support latest google-cloud-core (#276)
Browse files Browse the repository at this point in the history
`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 authored and parthea committed Mar 12, 2022
1 parent ae13239 commit cd01dd7
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/unit/test__http.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,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.DEFAULT_API_ENDPOINT, "bigquery", 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(["", "bigquery", 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):
custom_endpoint = "https://www.foo-googleapis.com"
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit

custom_endpoint = "https://foo-bigquery.googleapis.com"
conn = self._make_one(object(), api_endpoint=custom_endpoint)
URI = "/".join([custom_endpoint, "bigquery", 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), custom_endpoint)
self.assertEqual(path, "/".join(["", "bigquery", 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 Down

0 comments on commit cd01dd7

Please sign in to comment.