@@ -28,9 +28,33 @@ def _make_one(self, *args, **kw):
28
28
return self ._get_target_class ()(* args , ** kw )
29
29
30
30
def test_build_api_url_no_extra_query_params (self ):
31
+ from six .moves .urllib .parse import parse_qsl
32
+ from six .moves .urllib .parse import urlsplit
33
+
31
34
conn = self ._make_one (object ())
32
- URI = "/" .join ([conn .API_BASE_URL , "dns" , conn .API_VERSION , "foo" ])
33
- self .assertEqual (conn .build_api_url ("/foo" ), URI )
35
+ uri = conn .build_api_url ("/foo" )
36
+ scheme , netloc , path , qs , _ = urlsplit (uri )
37
+ self .assertEqual ("%s://%s" % (scheme , netloc ), conn .API_BASE_URL )
38
+ self .assertEqual (path , "/" .join (["" , "dns" , conn .API_VERSION , "foo" ]))
39
+ parms = dict (parse_qsl (qs ))
40
+ pretty_print = parms .pop ("prettyPrint" , "false" )
41
+ self .assertEqual (pretty_print , "false" )
42
+ self .assertEqual (parms , {})
43
+
44
+ def test_build_api_url_w_custom_endpoint (self ):
45
+ from six .moves .urllib .parse import parse_qsl
46
+ from six .moves .urllib .parse import urlsplit
47
+
48
+ custom_endpoint = "https://foo-dns.googleapis.com"
49
+ conn = self ._make_one (object (), api_endpoint = custom_endpoint )
50
+ uri = conn .build_api_url ("/foo" )
51
+ scheme , netloc , path , qs , _ = urlsplit (uri )
52
+ self .assertEqual ("%s://%s" % (scheme , netloc ), custom_endpoint )
53
+ self .assertEqual (path , "/" .join (["" , "dns" , conn .API_VERSION , "foo" ]))
54
+ parms = dict (parse_qsl (qs ))
55
+ pretty_print = parms .pop ("prettyPrint" , "false" )
56
+ self .assertEqual (pretty_print , "false" )
57
+ self .assertEqual (parms , {})
34
58
35
59
def test_build_api_url_w_extra_query_params (self ):
36
60
from six .moves .urllib .parse import parse_qsl
@@ -44,12 +68,6 @@ def test_build_api_url_w_extra_query_params(self):
44
68
parms = dict (parse_qsl (qs ))
45
69
self .assertEqual (parms ["bar" ], "baz" )
46
70
47
- def test_build_api_url_w_custom_endpoint (self ):
48
- custom_endpoint = "https://foo-dns.googleapis.com"
49
- conn = self ._make_one (object (), api_endpoint = custom_endpoint )
50
- URI = "/" .join ([custom_endpoint , "dns" , conn .API_VERSION , "foo" ])
51
- self .assertEqual (conn .build_api_url ("/foo" ), URI )
52
-
53
71
def test_extra_headers (self ):
54
72
import requests
55
73
from google .cloud import _http as base_http
0 commit comments