File tree 2 files changed +58
-0
lines changed
2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ from __future__ import unicode_literals
2
+ from django .conf .urls import patterns
3
+
4
+ # from tests.test_generics import RootView
5
+
6
+ from rest_framework .pagination import PageNumberPagination
7
+ from rest_framework .serializers import ModelSerializer
8
+ from rest_framework .viewsets import GenericViewSet
9
+ from rest_framework .mixins import ListModelMixin
10
+ from rest_framework import renderers
11
+ from tests .models import BasicModel
12
+
13
+
14
+ class BasicSerializer (ModelSerializer ):
15
+ class Meta :
16
+ model = BasicModel
17
+
18
+
19
+ class Paginator (PageNumberPagination ):
20
+ page_size = 10
21
+
22
+
23
+ class BasicViewSet (GenericViewSet , ListModelMixin ):
24
+ queryset = BasicModel .objects .all ()
25
+ serializer_class = BasicSerializer
26
+ renderer_classes = (renderers .BrowsableAPIRenderer , renderers .JSONRenderer )
27
+ paginator = None
28
+
29
+
30
+ urlpatterns = patterns (
31
+ '' ,
32
+ (r'^basic/' , BasicViewSet .as_view ({'get' : 'list' })),
33
+ )
Original file line number Diff line number Diff line change 3
3
from django .test import TestCase
4
4
5
5
from rest_framework .test import APIClient
6
+ from tests .models import BasicModel
6
7
7
8
8
9
class DropdownWithAuthTests (TestCase ):
@@ -63,3 +64,27 @@ def test_dropdown_not_shown_when_logged_in(self):
63
64
def test_dropdown_not_shown_when_logged_out (self ):
64
65
response = self .client .get ('/' )
65
66
self .assertNotContains (response , '<li class="dropdown">' )
67
+
68
+
69
+ class PaginatorRenderingTests (TestCase ):
70
+ """Tests correct dropdown behaviour with Auth views NOT enabled."""
71
+
72
+ urls = 'tests.browsable_api.example_modelviewset_urls'
73
+
74
+ def setUp (self ):
75
+ items = ['foo' , 'bar' , 'baz' ]
76
+ for item in items :
77
+ BasicModel (text = item ).save ()
78
+ self .objects = BasicModel .objects
79
+ self .data = [
80
+ {'id' : obj .id , 'text' : obj .text }
81
+ for obj in self .objects .all ()
82
+ ]
83
+ self .client = APIClient (enforce_csrf_checks = True )
84
+
85
+ def tearDown (self ):
86
+ self .client .logout ()
87
+
88
+ def test_none_paginator_allows_page_to_render (self ):
89
+ response = self .client .get ('/basic/' )
90
+ self .assertEqual (response .status_code , 200 )
You can’t perform that action at this time.
0 commit comments