@@ -80,7 +80,8 @@ def setUp(self):
8080 user .user_permissions .set ([
8181 Permission .objects .get (codename = 'add_basicmodel' ),
8282 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' )
8485 ])
8586
8687 user = User .
objects .
create_user (
'updateonly' ,
'[email protected] ' ,
'password' )
@@ -139,6 +140,15 @@ def test_get_queryset_has_create_permissions(self):
139140 response = get_queryset_list_view (request , pk = 1 )
140141 self .assertEqual (response .status_code , status .HTTP_201_CREATED )
141142
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+
142152 def test_has_put_permissions (self ):
143153 request = factory .put ('/1' , {'text' : 'foobar' }, format = 'json' ,
144154 HTTP_AUTHORIZATION = self .permitted_credentials )
@@ -156,6 +166,15 @@ def test_does_not_have_create_permissions(self):
156166 response = root_view (request , pk = 1 )
157167 self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
158168
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+
159178 def test_does_not_have_put_permissions (self ):
160179 request = factory .put ('/1' , {'text' : 'foobar' }, format = 'json' ,
161180 HTTP_AUTHORIZATION = self .disallowed_credentials )
0 commit comments