Commit 076ca6e7 by Artem Muterko

Add test for filter_renderers

parent 46210205
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 DefaultContentNegotiation
...@@ -78,3 +80,10 @@ class TestAcceptedMediaType(TestCase): ...@@ -78,3 +80,10 @@ 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')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment