@@ -75,7 +75,8 @@ def setUp(self):
7575 user .user_permissions .set ([
7676 Permission .objects .get (codename = 'add_basicmodel' ),
7777 Permission .objects .get (codename = 'change_basicmodel' ),
78- Permission .objects .get (codename = 'delete_basicmodel' )
78+ Permission .objects .get (codename = 'delete_basicmodel' ),
79+ Permission .objects .get (codename = 'view_basicmodel' )
7980 ])
8081
8182 user = User .
objects .
create_user (
'updateonly' ,
'[email protected] ' ,
'password' )
@@ -113,6 +114,15 @@ def test_get_queryset_has_create_permissions(self):
113114 response = get_queryset_list_view (request , pk = 1 )
114115 self .assertEqual (response .status_code , status .HTTP_201_CREATED )
115116
117+ def test_has_get_permissions (self ):
118+ request = factory .get ('/' , HTTP_AUTHORIZATION = self .permitted_credentials )
119+ response = root_view (request )
120+ self .assertEqual (response .status_code , status .HTTP_200_OK )
121+
122+ request = factory .get ('/1' , HTTP_AUTHORIZATION = self .updateonly_credentials )
123+ response = root_view (request , pk = 1 )
124+ self .assertEqual (response .status_code , status .HTTP_200_OK )
125+
116126 def test_has_put_permissions (self ):
117127 request = factory .put ('/1' , {'text' : 'foobar' }, format = 'json' ,
118128 HTTP_AUTHORIZATION = self .permitted_credentials )
@@ -130,6 +140,15 @@ def test_does_not_have_create_permissions(self):
130140 response = root_view (request , pk = 1 )
131141 self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
132142
143+ def test_does_not_have_get_permissions (self ):
144+ request = factory .get ('/' , HTTP_AUTHORIZATION = self .disallowed_credentials )
145+ response = root_view (request )
146+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
147+
148+ request = factory .get ('/1' , HTTP_AUTHORIZATION = self .disallowed_credentials )
149+ response = root_view (request , pk = 1 )
150+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
151+
133152 def test_does_not_have_put_permissions (self ):
134153 request = factory .put ('/1' , {'text' : 'foobar' }, format = 'json' ,
135154 HTTP_AUTHORIZATION = self .disallowed_credentials )
0 commit comments