Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
8844082d
Commit
8844082d
authored
Jan 19, 2017
by
José Padilla
Committed by
GitHub
Jan 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4829 from micgeronimo/negotiation-tests
Negotiation tests
parents
46210205
c2ce2fb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletions
+26
-1
tests/test_negotiation.py
+26
-1
No files found.
tests/test_negotiation.py
View file @
8844082d
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
pytest
from
django.http
import
Http404
from
django.test
import
TestCase
from
django.test
import
TestCase
from
rest_framework.negotiation
import
DefaultContentNegotiation
from
rest_framework.negotiation
import
(
BaseContentNegotiation
,
DefaultContentNegotiation
)
from
rest_framework.renderers
import
BaseRenderer
from
rest_framework.renderers
import
BaseRenderer
from
rest_framework.request
import
Request
from
rest_framework.request
import
Request
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.test
import
APIRequestFactory
...
@@ -78,3 +82,24 @@ class TestAcceptedMediaType(TestCase):
...
@@ -78,3 +82,24 @@ class TestAcceptedMediaType(TestCase):
params_str
+=
';
%
s=
%
s'
%
(
key
,
val
)
params_str
+=
';
%
s=
%
s'
%
(
key
,
val
)
expected
=
'test/*'
+
params_str
expected
=
'test/*'
+
params_str
assert
str
(
mediatype
)
==
expected
assert
str
(
mediatype
)
==
expected
def
test_raise_error_if_no_suitable_renderers_found
(
self
):
class
MockRenderer
(
object
):
format
=
'xml'
renderers
=
[
MockRenderer
()]
with
pytest
.
raises
(
Http404
):
self
.
negotiator
.
filter_renderers
(
renderers
,
format
=
'json'
)
class
BaseContentNegotiationTests
(
TestCase
):
def
setUp
(
self
):
self
.
negotiator
=
BaseContentNegotiation
()
def
test_raise_error_for_abstract_select_parser_method
(
self
):
with
pytest
.
raises
(
NotImplementedError
):
self
.
negotiator
.
select_parser
(
None
,
None
)
def
test_raise_error_for_abstract_select_renderer_method
(
self
):
with
pytest
.
raises
(
NotImplementedError
):
self
.
negotiator
.
select_renderer
(
None
,
None
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment