@@ -42,6 +42,36 @@ def test_default_url(self):
4242 conn = self ._make_one (client )
4343 self .assertIs (conn ._client , client )
4444
45+ def test_extra_headers (self ):
46+ from google .cloud import _http as base_http
47+ from google .cloud .logging import _http as MUT
48+
49+ http = mock .Mock (spec = ['request' ])
50+ response = mock .Mock (status = 200 , spec = ['status' ])
51+ data = b'brent-spiner'
52+ http .request .return_value = response , data
53+ client = mock .Mock (_http = http , spec = ['_http' ])
54+
55+ conn = self ._make_one (client )
56+ req_data = 'req-data-boring'
57+ result = conn .api_request (
58+ 'GET' , '/rainbow' , data = req_data , expect_json = False )
59+ self .assertEqual (result , data )
60+
61+ expected_headers = {
62+ 'Content-Length' : str (len (req_data )),
63+ 'Accept-Encoding' : 'gzip' ,
64+ base_http .CLIENT_INFO_HEADER : MUT ._CLIENT_INFO ,
65+ 'User-Agent' : conn .USER_AGENT ,
66+ }
67+ expected_uri = conn .build_api_url ('/rainbow' )
68+ http .request .assert_called_once_with (
69+ body = req_data ,
70+ headers = expected_headers ,
71+ method = 'GET' ,
72+ uri = expected_uri ,
73+ )
74+
4575
4676class Test_LoggingAPI (unittest .TestCase ):
4777
0 commit comments