@@ -167,6 +167,31 @@ def test_request_header_args_ok():
167
167
}
168
168
assert endpoint .required_args == {'user_id' , 'token' , 'edition' }
169
169
170
+ @responses .activate
171
+ def test_default_request_header_ok ():
172
+ """
173
+ Default request-header are present.
174
+ """
175
+ with (
176
+ patch (
177
+ 'popget.client.settings.CLIENT_DEFAULT_HEADERS' ,
178
+ {'Accept-Encoding' : 'gzip' , 'X-Depop-Pointless' : 'default' }
179
+ )
180
+ ):
181
+ def callback (request ):
182
+ assert 'Accept-Encoding' in request .headers
183
+ assert 'gzip' in request .headers ['Accept-Encoding' ]
184
+ assert 'X-Depop-Pointless' in request .headers
185
+ assert 'explicitly pointless' in request .headers ['X-Depop-Pointless' ]
186
+
187
+ return (200 , {}, '{"thing": "it\' s a thing"}' )
188
+
189
+ responses .add_callback (responses .GET , 'http://example.com/v1/thing/777' ,
190
+ callback = callback ,
191
+ content_type = 'application/json' )
192
+
193
+ data = DummyService .thing_detail (id = 777 )
194
+ assert len (responses .calls ) == 1
170
195
171
196
def test_request_header_args_clash ():
172
197
"""
@@ -230,6 +255,9 @@ class Config:
230
255
thing_detail = APIEndpoint (
231
256
'GET' ,
232
257
'/v1/thing/{id}' ,
258
+ request_headers = {
259
+ 'X-Depop-Pointless' : 'explicitly pointless' ,
260
+ }
233
261
)
234
262
thing_update = APIEndpoint (
235
263
'PATCH' ,
0 commit comments