@@ -49,11 +49,11 @@ def __init__(self):
49
49
self .status_code = okay_status
50
50
self .raise_for_status = self .p
51
51
52
- def mock_do_api_call (verb , uri , headers , data , timeout ):
52
+ def mock_do_api_call (verb , uri , ** kwargs ):
53
53
# Spying on mocked function is maybe too much so verify
54
54
# the arguments here.
55
55
assert uri == "http://localhost:8080/source/api/v1/BAR"
56
- assert data == '"fooBARbar"'
56
+ assert kwargs [ ' data' ] == '"fooBARbar"'
57
57
58
58
return MockResponse ()
59
59
@@ -88,7 +88,8 @@ def test_content_type(monkeypatch):
88
88
command = {"command" : ["http://localhost:8080/source/api/v1/foo" ,
89
89
verb , "data" , header_arg ]}
90
90
91
- def mock_response (uri , verb , headers , data , timeout ):
91
+ def mock_response (verb , uri , ** kwargs ):
92
+ headers = kwargs ['headers' ]
92
93
if header_arg :
93
94
assert text_plain_header .items () <= headers .items ()
94
95
else :
@@ -109,22 +110,25 @@ def test_headers_timeout(monkeypatch):
109
110
"""
110
111
headers = {'Tatsuo' : 'Yasuko' }
111
112
expected_timeout = 42
113
+ expected_api_timeout = 24
112
114
command = {"command" : ["http://localhost:8080/source/api/v1/bar" ,
113
115
'GET' , "data" , headers ]}
114
116
extra_headers = {'Mei' : 'Totoro' }
115
117
116
- def mock_do_api_call (uri , verb , headers , data , timeout ):
118
+ def mock_do_api_call (verb , uri , ** kwargs ):
117
119
all_headers = headers
118
120
all_headers .update (extra_headers )
119
121
assert headers == all_headers
120
- assert timeout == expected_timeout
122
+ assert kwargs ['timeout' ] == expected_timeout
123
+ assert kwargs ['api_timeout' ] == expected_api_timeout
121
124
122
125
with monkeypatch .context () as m :
123
126
m .setattr ("opengrok_tools.utils.restful.do_api_call" ,
124
127
mock_do_api_call )
125
128
call_rest_api (command ,
126
129
http_headers = extra_headers ,
127
- timeout = expected_timeout )
130
+ timeout = expected_timeout ,
131
+ api_timeout = expected_api_timeout )
128
132
129
133
130
134
def test_headers_timeout_requests ():
0 commit comments