@@ -174,30 +174,30 @@ def test_head_method_serializes_no_content(self):
174
174
175
175
def test_default_renderer_serializes_content_on_accept_any (self ):
176
176
"""If the Accept header is set to */* the default renderer should serialize the response."""
177
- resp = self .client .get ('/' , HTTP_ACCEPT = '*/*' )
177
+ resp = self .client .get ('/' , headers = { "accept" : '*/*' } )
178
178
self .assertEqual (resp ['Content-Type' ], RendererA .media_type + '; charset=utf-8' )
179
179
self .assertEqual (resp .content , RENDERER_A_SERIALIZER (DUMMYCONTENT ))
180
180
self .assertEqual (resp .status_code , DUMMYSTATUS )
181
181
182
182
def test_specified_renderer_serializes_content_default_case (self ):
183
183
"""If the Accept header is set the specified renderer should serialize the response.
184
184
(In this case we check that works for the default renderer)"""
185
- resp = self .client .get ('/' , HTTP_ACCEPT = RendererA .media_type )
185
+ resp = self .client .get ('/' , headers = { "accept" : RendererA .media_type } )
186
186
self .assertEqual (resp ['Content-Type' ], RendererA .media_type + '; charset=utf-8' )
187
187
self .assertEqual (resp .content , RENDERER_A_SERIALIZER (DUMMYCONTENT ))
188
188
self .assertEqual (resp .status_code , DUMMYSTATUS )
189
189
190
190
def test_specified_renderer_serializes_content_non_default_case (self ):
191
191
"""If the Accept header is set the specified renderer should serialize the response.
192
192
(In this case we check that works for a non-default renderer)"""
193
- resp = self .client .get ('/' , HTTP_ACCEPT = RendererB .media_type )
193
+ resp = self .client .get ('/' , headers = { "accept" : RendererB .media_type } )
194
194
self .assertEqual (resp ['Content-Type' ], RendererB .media_type + '; charset=utf-8' )
195
195
self .assertEqual (resp .content , RENDERER_B_SERIALIZER (DUMMYCONTENT ))
196
196
self .assertEqual (resp .status_code , DUMMYSTATUS )
197
197
198
198
def test_unsatisfiable_accept_header_on_request_returns_406_status (self ):
199
199
"""If the Accept header is unsatisfiable we should return a 406 Not Acceptable response."""
200
- resp = self .client .get ('/' , HTTP_ACCEPT = 'foo/bar' )
200
+ resp = self .client .get ('/' , headers = { "accept" : 'foo/bar' } )
201
201
self .assertEqual (resp .status_code , status .HTTP_406_NOT_ACCEPTABLE )
202
202
203
203
def test_specified_renderer_serializes_content_on_format_query (self ):
@@ -228,14 +228,14 @@ def test_specified_renderer_is_used_on_format_query_with_matching_accept(self):
228
228
RendererB .format
229
229
)
230
230
resp = self .client .get ('/' + param ,
231
- HTTP_ACCEPT = RendererB .media_type )
231
+ headers = { "accept" : RendererB .media_type } )
232
232
self .assertEqual (resp ['Content-Type' ], RendererB .media_type + '; charset=utf-8' )
233
233
self .assertEqual (resp .content , RENDERER_B_SERIALIZER (DUMMYCONTENT ))
234
234
self .assertEqual (resp .status_code , DUMMYSTATUS )
235
235
236
236
def test_parse_error_renderers_browsable_api (self ):
237
237
"""Invalid data should still render the browsable API correctly."""
238
- resp = self .client .post ('/parseerror' , data = 'foobar' , content_type = 'application/json' , HTTP_ACCEPT = 'text/html' )
238
+ resp = self .client .post ('/parseerror' , data = 'foobar' , content_type = 'application/json' , headers = { "accept" : 'text/html' } )
239
239
self .assertEqual (resp ['Content-Type' ], 'text/html; charset=utf-8' )
240
240
self .assertEqual (resp .status_code , status .HTTP_400_BAD_REQUEST )
241
241
@@ -714,13 +714,13 @@ class DummyView:
714
714
assert result is None
715
715
716
716
def test_extra_actions_dropdown (self ):
717
- resp = self .client .get ('/api/examples/' , HTTP_ACCEPT = 'text/html' )
717
+ resp = self .client .get ('/api/examples/' , headers = { "accept" : 'text/html' } )
718
718
assert 'id="extra-actions-menu"' in resp .content .decode ()
719
719
assert '/api/examples/list_action/' in resp .content .decode ()
720
720
assert '>Extra list action<' in resp .content .decode ()
721
721
722
722
def test_extra_actions_dropdown_not_authed (self ):
723
- resp = self .client .get ('/api/unauth-examples/' , HTTP_ACCEPT = 'text/html' )
723
+ resp = self .client .get ('/api/unauth-examples/' , headers = { "accept" : 'text/html' } )
724
724
assert 'id="extra-actions-menu"' not in resp .content .decode ()
725
725
assert '/api/examples/list_action/' not in resp .content .decode ()
726
726
assert '>Extra list action<' not in resp .content .decode ()
0 commit comments