Exemplo n.º 1
0
    def test_retrieve(self):
        template_renderer = TemplateHTMLRenderer
        template_renderer.format = 'html'

        request = APIRequestFactory()
        request.accepted_renderer = template_renderer
        request.query_params = dict()

        view = PostViewSet()
        view.kwargs = {'pk': 1}
        view.action = 'retrieve'
        view.request = request
        view.format_kwarg = ''

        response = view.retrieve(request)
        self.assertEqual(response.template_name, 'posts/detail.html')
Exemplo n.º 2
0
    def test_list(self):
        template_renderer = TemplateHTMLRenderer
        template_renderer.format = 'html'

        request = APIRequestFactory()
        request.accepted_renderer = template_renderer
        request.query_params = dict()
        request.GET = {}

        view = PostViewSet()
        view.action = 'list'
        view.request = request
        view.format_kwarg = ''

        response = view.list(request)
        self.assertEqual(response.template_name, 'posts/list.html')