def setup(self): self.view = CruditorListView.as_view(model=User) self.filtered_view = CruditorListView.as_view( model=User, filter_class=UserFilter) self.user = UserFactory.create(is_staff=False) self.staff_user = UserFactory.create(is_staff=True)
def test_logged_in_has_permission(self, user_rf): self.staff_user.is_superuser = True view = CruditorListView.as_view( model=User, required_permission='accounts.change_user') assert view(user_rf.get('/', user=self.staff_user)).status_code == 200
def test_logged_in_no_permission(self, user_rf): view = CruditorListView.as_view( model=User, required_permission='accounts.change_user') with pytest.raises(PermissionDenied): view(user_rf.get('/', user=self.staff_user))