  from django.conf.urls.defaults import patterns, url
  from django.forms import ModelForm
  from django.contrib.auth.models import Group, User
  from djangorestframework.resources import ModelResource
  from djangorestframework.views import ListOrCreateModelView, InstanceModelView
  from djangorestframework.tests.models import CustomUser
  from djangorestframework.tests.testcases import TestModelsTestCase
  
  
  class GroupResource(ModelResource):
      model = Group
  
 
</s> remove class GroupResource(ModelResource):
    model = Group
 </s> add # class GroupResource(ModelResource):
#     model = Group </s> remove """Tests for the mixin module"""
from django.test import TestCase
from django.utils import simplejson as json
from djangorestframework import status
from djangorestframework.compat import RequestFactory
from django.contrib.auth.models import Group, User
from djangorestframework.mixins import CreateModelMixin, PaginatorMixin, ReadModelMixin
from djangorestframework.resources import ModelResource
from djangorestframework.response import Response, ImmediateResponse
from djangorestframework.tests.models import CustomUser
from djangorestframework.tests.testcases import TestModelsTestCase
from djangorestframework.views import View


class TestModelRead(TestModelsTestCase):
    """Tests on ReadModelMixin"""

    def setUp(self):
        super(TestModelRead, self).setUp()
        self.req = RequestFactory()

    def test_read(self):
        Group.objects.create(name='other group')
        group = Group.objects.create(name='my group')

        class GroupResource(ModelResource):
            model = Group

        request = self.req.get('/groups')
        mixin = ReadModelMixin()
        mixin.resource = GroupResource

        response = mixin.get(request, id=group.id)
        self.assertEquals(group.name, response.raw_content.name)

    def test_read_404(self):
        class GroupResource(ModelResource):
            model = Group

        request = self.req.get('/groups')
        mixin = ReadModelMixin()
        mixin.resource = GroupResource

        self.assertRaises(ImmediateResponse, mixin.get, request, id=12345)


class TestModelCreation(TestModelsTestCase):
    """Tests on CreateModelMixin"""

    def setUp(self):
        super(TestModelsTestCase, self).setUp()
        self.req = RequestFactory()

    def test_creation(self):
        self.assertEquals(0, Group.objects.count())

        class GroupResource(ModelResource):
            model = Group

        form_data = {'name': 'foo'}
        request = self.req.post('/groups', data=form_data)
        mixin = CreateModelMixin()
        mixin.resource = GroupResource
        mixin.CONTENT = form_data

        response = mixin.post(request)
        self.assertEquals(1, Group.objects.count())
        self.assertEquals('foo', response.raw_content.name)

    def test_creation_with_m2m_relation(self):
        class UserResource(ModelResource):
            model = User

            def url(self, instance):
                return "/users/%i" % instance.id

        group = Group(name='foo')
        group.save()

        form_data = {
            'username': 'bar',
            'password': 'baz',
            'groups': [group.id]
        }
        request = self.req.post('/groups', data=form_data)
        cleaned_data = dict(form_data)
        cleaned_data['groups'] = [group]
        mixin = CreateModelMixin()
        mixin.resource = UserResource
        mixin.CONTENT = cleaned_data

        response = mixin.post(request)
        self.assertEquals(1, User.objects.count())
        self.assertEquals(1, response.raw_content.groups.count())
        self.assertEquals('foo', response.raw_content.groups.all()[0].name)

    def test_creation_with_m2m_relation_through(self):
        """
        Tests creation where the m2m relation uses a through table
        """
        class UserResource(ModelResource):
            model = CustomUser

            def url(self, instance):
                return "/customusers/%i" % instance.id

        form_data = {'username': 'bar0', 'groups': []}
        request = self.req.post('/groups', data=form_data)
        cleaned_data = dict(form_data)
        cleaned_data['groups'] = []
        mixin = CreateModelMixin()
        mixin.resource = UserResource
        mixin.CONTENT = cleaned_data
 </s> add # """Tests for the mixin module"""
# from django.test import TestCase
# from djangorestframework import status
# from djangorestframework.compat import RequestFactory
# from django.contrib.auth.models import Group, User
# from djangorestframework.mixins import CreateModelMixin, PaginatorMixin, ReadModelMixin
# from djangorestframework.resources import ModelResource
# from djangorestframework.response import Response, ImmediateResponse
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from djangorestframework.views import View


# class TestModelRead(TestModelsTestCase):
#     """Tests on ReadModelMixin"""

#     def setUp(self):
#         super(TestModelRead, self).setUp()
#         self.req = RequestFactory()

#     def test_read(self):
#         Group.objects.create(name='other group')
#         group = Group.objects.create(name='my group')

#         class GroupResource(ModelResource):
#             model = Group

#         request = self.req.get('/groups')
#         mixin = ReadModelMixin()
#         mixin.resource = GroupResource

#         response = mixin.get(request, id=group.id)
#         self.assertEquals(group.name, response.raw_content.name)

#     def test_read_404(self):
#         class GroupResource(ModelResource):
#             model = Group

#         request = self.req.get('/groups')
#         mixin = ReadModelMixin()
#         mixin.resource = GroupResource

#         self.assertRaises(ImmediateResponse, mixin.get, request, id=12345)


# class TestModelCreation(TestModelsTestCase):
#     """Tests on CreateModelMixin"""

#     def setUp(self):
#         super(TestModelsTestCase, self).setUp()
#         self.req = RequestFactory()

#     def test_creation(self):
#         self.assertEquals(0, Group.objects.count())

#         class GroupResource(ModelResource):
#             model = Group

#         form_data = {'name': 'foo'}
#         request = self.req.post('/groups', data=form_data)
#         mixin = CreateModelMixin()
#         mixin.resource = GroupResource
#         mixin.CONTENT = form_data

#         response = mixin.post(request)
#         self.assertEquals(1, Group.objects.count())
#         self.assertEquals('foo', response.raw_content.name)

#     def test_creation_with_m2m_relation(self):
#         class UserResource(ModelResource):
#             model = User

#             def url(self, instance):
#                 return "/users/%i" % instance.id

#         group = Group(name='foo')
#         group.save()

#         form_data = {
#             'username': 'bar',
#             'password': 'baz',
#             'groups': [group.id]
#         }
#         request = self.req.post('/groups', data=form_data)
#         cleaned_data = dict(form_data)
#         cleaned_data['groups'] = [group]
#         mixin = CreateModelMixin()
#         mixin.resource = UserResource
#         mixin.CONTENT = cleaned_data

#         response = mixin.post(request)
#         self.assertEquals(1, User.objects.count())
#         self.assertEquals(1, response.raw_content.groups.count())
#         self.assertEquals('foo', response.raw_content.groups.all()[0].name)

#     def test_creation_with_m2m_relation_through(self):
#         """
#         Tests creation where the m2m relation uses a through table
#         """
#         class UserResource(ModelResource):
#             model = CustomUser

#             def url(self, instance):
#                 return "/customusers/%i" % instance.id

#         form_data = {'username': 'bar0', 'groups': []}
#         request = self.req.post('/groups', data=form_data)
#         cleaned_data = dict(form_data)
#         cleaned_data['groups'] = []
#         mixin = CreateModelMixin()
#         mixin.resource = UserResource
#         mixin.CONTENT = cleaned_data </s> remove from django import forms
from django.db import models
from django.test import TestCase
from djangorestframework.resources import FormResource, ModelResource
from djangorestframework.response import ImmediateResponse
from djangorestframework.views import View
 </s> add # from django import forms
# from django.db import models
# from django.test import TestCase
# from djangorestframework.response import ImmediateResponse
# from djangorestframework.views import View </s> remove from djangorestframework.permissions import PerUserThrottling, PerViewThrottling, PerResourceThrottling
from djangorestframework.resources import FormResource
 </s> add from djangorestframework.permissions import PerUserThrottling, PerViewThrottling </s> remove from djangorestframework.compat import RequestFactory
from djangorestframework.views import View
from djangorestframework.resources import FormResource
from djangorestframework.response import Response
 </s> add # from djangorestframework.compat import RequestFactory
# from djangorestframework.views import View
# from djangorestframework.response import Response
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
# from django.conf.urls.defaults import patterns, url
# from django.forms import ModelForm
# from django.contrib.auth.models import Group, User
# from djangorestframework.resources import ModelResource
# from djangorestframework.views import ListOrCreateModelView, InstanceModelView
# from djangorestframework.tests.models import CustomUser
# from djangorestframework.tests.testcases import TestModelsTestCase
  
  
  class GroupResource(ModelResource):
      model = Group
  
replace replace replace replace replace replace replace keep keep keep keep keep
 Drop out resources & mixins 
djangorestframework/tests/modelviews.py