Skip to content

Commit 9da28e5

Browse files
authored
test: update tests to support latest google-cloud-core (#276)
`google-cloud-core` version 1.4.2 populates `prettyPrint=false` by default. Update the connection tests to expect a value for `prettyPrint`.
1 parent 2779586 commit 9da28e5

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

tests/unit/test__http.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,33 @@ def _make_one(self, *args, **kw):
3535
return self._get_target_class()(*args, **kw)
3636

3737
def test_build_api_url_no_extra_query_params(self):
38+
from six.moves.urllib.parse import parse_qsl
39+
from six.moves.urllib.parse import urlsplit
40+
3841
conn = self._make_one(object())
39-
URI = "/".join([conn.DEFAULT_API_ENDPOINT, "bigquery", conn.API_VERSION, "foo"])
40-
self.assertEqual(conn.build_api_url("/foo"), URI)
42+
uri = conn.build_api_url("/foo")
43+
scheme, netloc, path, qs, _ = urlsplit(uri)
44+
self.assertEqual("%s://%s" % (scheme, netloc), conn.API_BASE_URL)
45+
self.assertEqual(path, "/".join(["", "bigquery", conn.API_VERSION, "foo"]))
46+
parms = dict(parse_qsl(qs))
47+
pretty_print = parms.pop("prettyPrint", "false")
48+
self.assertEqual(pretty_print, "false")
49+
self.assertEqual(parms, {})
4150

4251
def test_build_api_url_w_custom_endpoint(self):
43-
custom_endpoint = "https://www.foo-googleapis.com"
52+
from six.moves.urllib.parse import parse_qsl
53+
from six.moves.urllib.parse import urlsplit
54+
55+
custom_endpoint = "https://foo-bigquery.googleapis.com"
4456
conn = self._make_one(object(), api_endpoint=custom_endpoint)
45-
URI = "/".join([custom_endpoint, "bigquery", conn.API_VERSION, "foo"])
46-
self.assertEqual(conn.build_api_url("/foo"), URI)
57+
uri = conn.build_api_url("/foo")
58+
scheme, netloc, path, qs, _ = urlsplit(uri)
59+
self.assertEqual("%s://%s" % (scheme, netloc), custom_endpoint)
60+
self.assertEqual(path, "/".join(["", "bigquery", conn.API_VERSION, "foo"]))
61+
parms = dict(parse_qsl(qs))
62+
pretty_print = parms.pop("prettyPrint", "false")
63+
self.assertEqual(pretty_print, "false")
64+
self.assertEqual(parms, {})
4765

4866
def test_build_api_url_w_extra_query_params(self):
4967
from six.moves.urllib.parse import parse_qsl

0 commit comments

Comments
 (0)