  
  def _camelcase_to_spaces(content):
      """
      Translate 'CamelCaseNames' to 'Camel Case Names'.
      Used when generating names from view/resource classes.
      """
      camelcase_boundry = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
      return re.sub(camelcase_boundry, ' \\1', content).strip()
  
  
 
</s> remove     Used when generating names from view/resource classes.
 </s> add     Used when generating names from view classes. </s> remove _resource_classes = (
    None,
    resources.Resource,
    resources.FormResource,
    resources.ModelResource
)


class View(ResourceMixin, DjangoView):
 </s> add class View(DjangoView): </s> remove         form_data = {'username': 'bar1', '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(2, CustomUser.objects.count())
        self.assertEquals(1, response.raw_content.groups.count())
        self.assertEquals('foo1', response.raw_content.groups.all()[0].name)

        group2 = Group(name='foo2')
        group2.save()

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

        response = mixin.post(request)
        self.assertEquals(3, CustomUser.objects.count())
        self.assertEquals(2, response.raw_content.groups.count())
        self.assertEquals('foo1', response.raw_content.groups.all()[0].name)
        self.assertEquals('foo2', response.raw_content.groups.all()[1].name)


class MockPaginatorView(PaginatorMixin, View):
    total = 60

    def get(self, request):
        return Response(range(0, self.total))

    def post(self, request):
        return Response({'status': 'OK'}, status=status.HTTP_201_CREATED)


class TestPagination(TestCase):
    def setUp(self):
        self.req = RequestFactory()

    def test_default_limit(self):
        """ Tests if pagination works without overwriting the limit """
        request = self.req.get('/paginator')
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(MockPaginatorView.total, content['total'])
        self.assertEqual(MockPaginatorView.limit, content['per_page'])

        self.assertEqual(range(0, MockPaginatorView.limit), content['results'])

    def test_overwriting_limit(self):
        """ Tests if the limit can be overwritten """
        limit = 10

        request = self.req.get('/paginator')
        response = MockPaginatorView.as_view(limit=limit)(request)
        content = response.raw_content

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(content['per_page'], limit)

        self.assertEqual(range(0, limit), content['results'])

    def test_limit_param(self):
        """ Tests if the client can set the limit """
        from math import ceil

        limit = 5
        num_pages = int(ceil(MockPaginatorView.total / float(limit)))

        request = self.req.get('/paginator/?limit=%d' % limit)
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(MockPaginatorView.total, content['total'])
        self.assertEqual(limit, content['per_page'])
        self.assertEqual(num_pages, content['pages'])

    def test_exceeding_limit(self):
        """ Makes sure the client cannot exceed the default limit """
        from math import ceil

        limit = MockPaginatorView.limit + 10
        num_pages = int(ceil(MockPaginatorView.total / float(limit)))

        request = self.req.get('/paginator/?limit=%d' % limit)
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(MockPaginatorView.total, content['total'])
        self.assertNotEqual(limit, content['per_page'])
        self.assertNotEqual(num_pages, content['pages'])
        self.assertEqual(MockPaginatorView.limit, content['per_page'])

    def test_only_works_for_get(self):
        """ Pagination should only work for GET requests """
        request = self.req.post('/paginator', data={'content': 'spam'})
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(None, content.get('per_page'))
        self.assertEqual('OK', content['status'])

    def test_non_int_page(self):
        """ Tests that it can handle invalid values """
        request = self.req.get('/paginator/?page=spam')
        response = MockPaginatorView.as_view()(request)

        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_page_range(self):
        """ Tests that the page range is handle correctly """
        request = self.req.get('/paginator/?page=0')
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

        request = self.req.get('/paginator/')
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(range(0, MockPaginatorView.limit), content['results'])

        num_pages = content['pages']

        request = self.req.get('/paginator/?page=%d' % num_pages)
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(range(MockPaginatorView.limit*(num_pages-1), MockPaginatorView.total), content['results'])

        request = self.req.get('/paginator/?page=%d' % (num_pages + 1,))
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_existing_query_parameters_are_preserved(self):
        """ Tests that existing query parameters are preserved when
        generating next/previous page links """
        request = self.req.get('/paginator/?foo=bar&another=something')
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue('foo=bar' in content['next'])
        self.assertTrue('another=something' in content['next'])
        self.assertTrue('page=2' in content['next'])

    def test_duplicate_parameters_are_not_created(self):
        """ Regression: ensure duplicate "page" parameters are not added to
        paginated URLs. So page 1 should contain ?page=2, not ?page=1&page=2 """
        request = self.req.get('/paginator/?page=1')
        response = MockPaginatorView.as_view()(request)
        content = response.raw_content
        self.assertTrue('page=2' in content['next'])
        self.assertFalse('page=1' in content['next'])
 </s> add #         form_data = {'username': 'bar1', '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(2, CustomUser.objects.count())
#         self.assertEquals(1, response.raw_content.groups.count())
#         self.assertEquals('foo1', response.raw_content.groups.all()[0].name)

#         group2 = Group(name='foo2')
#         group2.save()

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

#         response = mixin.post(request)
#         self.assertEquals(3, CustomUser.objects.count())
#         self.assertEquals(2, response.raw_content.groups.count())
#         self.assertEquals('foo1', response.raw_content.groups.all()[0].name)
#         self.assertEquals('foo2', response.raw_content.groups.all()[1].name)


# class MockPaginatorView(PaginatorMixin, View):
#     total = 60

#     def get(self, request):
#         return Response(range(0, self.total))

#     def post(self, request):
#         return Response({'status': 'OK'}, status=status.HTTP_201_CREATED)


# class TestPagination(TestCase):
#     def setUp(self):
#         self.req = RequestFactory()

#     def test_default_limit(self):
#         """ Tests if pagination works without overwriting the limit """
#         request = self.req.get('/paginator')
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content

#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertEqual(MockPaginatorView.total, content['total'])
#         self.assertEqual(MockPaginatorView.limit, content['per_page'])

#         self.assertEqual(range(0, MockPaginatorView.limit), content['results'])

#     def test_overwriting_limit(self):
#         """ Tests if the limit can be overwritten """
#         limit = 10

#         request = self.req.get('/paginator')
#         response = MockPaginatorView.as_view(limit=limit)(request)
#         content = response.raw_content

#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertEqual(content['per_page'], limit)

#         self.assertEqual(range(0, limit), content['results'])

#     def test_limit_param(self):
#         """ Tests if the client can set the limit """
#         from math import ceil

#         limit = 5
#         num_pages = int(ceil(MockPaginatorView.total / float(limit)))

#         request = self.req.get('/paginator/?limit=%d' % limit)
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content

#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertEqual(MockPaginatorView.total, content['total'])
#         self.assertEqual(limit, content['per_page'])
#         self.assertEqual(num_pages, content['pages'])

#     def test_exceeding_limit(self):
#         """ Makes sure the client cannot exceed the default limit """
#         from math import ceil

#         limit = MockPaginatorView.limit + 10
#         num_pages = int(ceil(MockPaginatorView.total / float(limit)))

#         request = self.req.get('/paginator/?limit=%d' % limit)
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content

#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertEqual(MockPaginatorView.total, content['total'])
#         self.assertNotEqual(limit, content['per_page'])
#         self.assertNotEqual(num_pages, content['pages'])
#         self.assertEqual(MockPaginatorView.limit, content['per_page'])

#     def test_only_works_for_get(self):
#         """ Pagination should only work for GET requests """
#         request = self.req.post('/paginator', data={'content': 'spam'})
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content

#         self.assertEqual(response.status_code, status.HTTP_201_CREATED)
#         self.assertEqual(None, content.get('per_page'))
#         self.assertEqual('OK', content['status'])

#     def test_non_int_page(self):
#         """ Tests that it can handle invalid values """
#         request = self.req.get('/paginator/?page=spam')
#         response = MockPaginatorView.as_view()(request)

#         self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

#     def test_page_range(self):
#         """ Tests that the page range is handle correctly """
#         request = self.req.get('/paginator/?page=0')
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content
#         self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

#         request = self.req.get('/paginator/')
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content
#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertEqual(range(0, MockPaginatorView.limit), content['results'])

#         num_pages = content['pages']

#         request = self.req.get('/paginator/?page=%d' % num_pages)
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content
#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertEqual(range(MockPaginatorView.limit*(num_pages-1), MockPaginatorView.total), content['results'])

#         request = self.req.get('/paginator/?page=%d' % (num_pages + 1,))
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content
#         self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

#     def test_existing_query_parameters_are_preserved(self):
#         """ Tests that existing query parameters are preserved when
#         generating next/previous page links """
#         request = self.req.get('/paginator/?foo=bar&another=something')
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content
#         self.assertEqual(response.status_code, status.HTTP_200_OK)
#         self.assertTrue('foo=bar' in content['next'])
#         self.assertTrue('another=something' in content['next'])
#         self.assertTrue('page=2' in content['next'])

#     def test_duplicate_parameters_are_not_created(self):
#         """ Regression: ensure duplicate "page" parameters are not added to
#         paginated URLs. So page 1 should contain ?page=2, not ?page=1&page=2 """
#         request = self.req.get('/paginator/?page=1')
#         response = MockPaginatorView.as_view()(request)
#         content = response.raw_content
#         self.assertTrue('page=2' in content['next'])
#         self.assertFalse('page=1' in content['next']) </s> remove import datetime
import decimal

class TestObjectToData(TestCase):
    """
    Tests for the Serializer class.
    """

    def setUp(self):
        self.serializer = Serializer()
        self.serialize = self.serializer.serialize

    def test_decimal(self):
        """Decimals need to be converted to a string representation."""
        self.assertEquals(self.serialize(decimal.Decimal('1.5')), decimal.Decimal('1.5'))

    def test_function(self):
        """Functions with no arguments should be called."""
        def foo():
            return 1
        self.assertEquals(self.serialize(foo), 1)

    def test_method(self):
        """Methods with only a ``self`` argument should be called."""
        class Foo(object):
            def foo(self):
                return 1
        self.assertEquals(self.serialize(Foo().foo), 1)

    def test_datetime(self):
        """datetime objects are left as-is."""
        now = datetime.datetime.now()
        self.assertEquals(self.serialize(now), now)

    def test_dict_method_name_collision(self):
        """dict with key that collides with dict method name"""
        self.assertEquals(self.serialize({'items': 'foo'}), {'items': u'foo'})
        self.assertEquals(self.serialize({'keys': 'foo'}), {'keys': u'foo'})
        self.assertEquals(self.serialize({'values': 'foo'}), {'values': u'foo'})
 </s> add # import datetime
# import decimal </s> remove     resource = None
    """
    The resource to use when validating requests and filtering responses,
    or `None` to use default behaviour.
    """

 </s> add 
    Used when generating names from view classes.
  
  def _camelcase_to_spaces(content):
      """
      Translate 'CamelCaseNames' to 'Camel Case Names'.
    Used when generating names from view classes.
      """
      camelcase_boundry = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
      return re.sub(camelcase_boundry, ' \\1', content).strip()
  
  
keep keep keep keep replace keep keep keep keep keep
 Drop out resources & mixins 
djangorestframework/views.py