  
  object_permissions_view = ObjectPermissionInstanceView.as_view()
  
  if guardian:
      from guardian.shortcuts import assign_perm
  
      class ObjectPermissionsIntegrationTests(TestCase):
 
</s> remove     model = BasicModel
 </s> add     model = BasicPermModel </s> remove             # assign permissions appropriately
            from guardian.shortcuts import assign_perm
 </s> add             # appropriate object level permissions
            readers = Group.objects.create(name='readers')
            writers = Group.objects.create(name='writers')
            deleters = Group.objects.create(name='deleters') </s> remove             # create users
            User.objects.create_user('no_permission', 'no_permission@example.com', 'password')
            reader = User.objects.create_user('reader', 'reader@example.com', 'password')
            writer = User.objects.create_user('writer', 'writer@example.com', 'password')
            full_access = User.objects.create_user('full_access', 'full_access@example.com', 'password')
            
            model = BasicPermModel.objects.create(text='foo')
 </s> add             perms = self.perms
            users = self.users </s> remove             read = "read_basicpermmodel"
            write = "change_basicpermmodel"
            delete = "delete_basicpermmodel"
            app_label = 'tests.'
            # model level permissions
            assign_perm(app_label + delete, full_access, obj=model)
            (assign_perm(app_label + write, user, obj=model) for user in (writer, full_access))
            (assign_perm(app_label + read, user, obj=model) for user in (reader, writer, full_access))
 </s> add             model = BasicPermModel.objects.create(text='foo')
            
            assign_perm(perms['read'], readers, model)
            assign_perm(perms['change'], writers, model)
            assign_perm(perms['delete'], deleters, model)

            readers.user_set.add(users['fullaccess'], users['readonly'])
            writers.user_set.add(users['fullaccess'], users['writeonly'])
            deleters.user_set.add(users['fullaccess'], users['deleteonly'])

            self.credentials = {}
            for user in users.values():
                self.credentials[user.username] = basic_auth_header(user.username, 'password')

        # Delete
        def test_can_delete_permissions(self):
            request = factory.delete('/1', HTTP_AUTHORIZATION=self.credentials['deleteonly'])
            object_permissions_view.cls.action = 'destroy'
            response = object_permissions_view(request, pk='1')
            self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
class ObjectPermissionListView(generics.ListAPIView):
    model = BasicPermModel
    authentication_classes = [authentication.BasicAuthentication]
    permission_classes = [permissions.DjangoObjectLevelModelPermissions]

object_permissions_list_view = ObjectPermissionListView.as_view()

  
  object_permissions_view = ObjectPermissionInstanceView.as_view()
  
class ObjectPermissionListView(generics.ListAPIView):
    model = BasicPermModel
    authentication_classes = [authentication.BasicAuthentication]
    permission_classes = [permissions.DjangoObjectLevelModelPermissions]

object_permissions_list_view = ObjectPermissionListView.as_view()

  if guardian:
      from guardian.shortcuts import assign_perm
  
      class ObjectPermissionsIntegrationTests(TestCase):
keep keep add keep keep keep keep
 first pass at object level permissions and tests 
rest_framework/tests/test_permissions.py