Add test for filter_renderers

This commit is contained in:
Artem Muterko 2017-01-19 12:43:18 +02:00
parent 46210205a4
commit 076ca6e765

View File

@ -1,5 +1,7 @@
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):
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')