@@ -51,13 +51,17 @@ def test_build_api_url_w_extra_query_params(self):
51
51
self .assertEqual (parms ['bar' ], 'baz' )
52
52
53
53
def test_extra_headers (self ):
54
+ import requests
55
+
54
56
from google .cloud import _http as base_http
55
57
from google .cloud .resource_manager import _http as MUT
56
58
57
- http = mock .Mock (spec = ['request' ])
58
- response = mock .Mock (status = 200 , spec = ['status' ])
59
+ http = mock .create_autospec (requests .Session , instance = True )
60
+ response = requests .Response ()
61
+ response .status_code = 200
59
62
data = b'brent-spiner'
60
- http .request .return_value = response , data
63
+ response ._content = data
64
+ http .request .return_value = response
61
65
client = mock .Mock (_http = http , spec = ['_http' ])
62
66
63
67
conn = self ._make_one (client )
@@ -67,15 +71,14 @@ def test_extra_headers(self):
67
71
self .assertEqual (result , data )
68
72
69
73
expected_headers = {
70
- 'Content-Length' : str (len (req_data )),
71
74
'Accept-Encoding' : 'gzip' ,
72
75
base_http .CLIENT_INFO_HEADER : MUT ._CLIENT_INFO ,
73
76
'User-Agent' : conn .USER_AGENT ,
74
77
}
75
78
expected_uri = conn .build_api_url ('/rainbow' )
76
79
http .request .assert_called_once_with (
77
- body = req_data ,
80
+ data = req_data ,
78
81
headers = expected_headers ,
79
82
method = 'GET' ,
80
- uri = expected_uri ,
83
+ url = expected_uri ,
81
84
)
0 commit comments