@@ -80,7 +80,8 @@ def setUp(self):
80
80
user .user_permissions .set ([
81
81
Permission .objects .get (codename = 'add_basicmodel' ),
82
82
Permission .objects .get (codename = 'change_basicmodel' ),
83
- Permission .objects .get (codename = 'delete_basicmodel' )
83
+ Permission .objects .get (codename = 'delete_basicmodel' ),
84
+ Permission .objects .get (codename = 'view_basicmodel' )
84
85
])
85
86
86
87
user = User .
objects .
create_user (
'updateonly' ,
'[email protected] ' ,
'password' )
@@ -139,6 +140,15 @@ def test_get_queryset_has_create_permissions(self):
139
140
response = get_queryset_list_view (request , pk = 1 )
140
141
self .assertEqual (response .status_code , status .HTTP_201_CREATED )
141
142
143
+ def test_has_get_permissions (self ):
144
+ request = factory .get ('/' , HTTP_AUTHORIZATION = self .permitted_credentials )
145
+ response = root_view (request )
146
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
147
+
148
+ request = factory .get ('/1' , HTTP_AUTHORIZATION = self .updateonly_credentials )
149
+ response = root_view (request , pk = 1 )
150
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
151
+
142
152
def test_has_put_permissions (self ):
143
153
request = factory .put ('/1' , {'text' : 'foobar' }, format = 'json' ,
144
154
HTTP_AUTHORIZATION = self .permitted_credentials )
@@ -156,6 +166,15 @@ def test_does_not_have_create_permissions(self):
156
166
response = root_view (request , pk = 1 )
157
167
self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
158
168
169
+ def test_does_not_have_get_permissions (self ):
170
+ request = factory .get ('/' , HTTP_AUTHORIZATION = self .disallowed_credentials )
171
+ response = root_view (request )
172
+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
173
+
174
+ request = factory .get ('/1' , HTTP_AUTHORIZATION = self .disallowed_credentials )
175
+ response = root_view (request , pk = 1 )
176
+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
177
+
159
178
def test_does_not_have_put_permissions (self ):
160
179
request = factory .put ('/1' , {'text' : 'foobar' }, format = 'json' ,
161
180
HTTP_AUTHORIZATION = self .disallowed_credentials )
0 commit comments