def test_empty_pagination(self):

        paginator = Paginator(get_user_model().objects.all(), per_page=self.perpage)
        page = paginator.page(1)
        context = pagination.pagination(page)
        self.assertEqual(context['num_pages'], 1)
        self.assertEqual(context['page'], page)
        self.assertEqual(context['begin'], [1])
        self.assertEqual(context['middle'], [])
        self.assertEqual(context['end'], [])
    def test_pagination_collide(self):

        numpages = 10
        begin_pages = 3
        end_pages = 3
        before_current_pages = 3
        after_current_pages = 3

        for x in range(0, numpages * self.perpage):
            get_user_model().objects.create(username="******" % x)

        paginator = Paginator(get_user_model().objects.all(), per_page=self.perpage)

        for x in range(1, begin_pages+1):
            page = paginator.page(x)
            context = pagination.pagination(page, begin_pages, end_pages, before_current_pages, after_current_pages)

            self.assertEqual(context['num_pages'], numpages)
            self.assertEqual(context['page'], page)
            self.assertEqual(context['begin'], range(1, min(before_current_pages + after_current_pages, numpages)+1))
            self.assertEqual(context['middle'], [])
            self.assertEqual(context['end'], range(numpages - end_pages + 1, numpages+1))

        for x in range(numpages/2, numpages/2 + before_current_pages):
            page = paginator.page(x)
            context = pagination.pagination(page, begin_pages, end_pages, before_current_pages, after_current_pages)

            self.assertEqual(context['num_pages'], numpages)
            self.assertEqual(context['page'], page)
            self.assertEqual(context['begin'], range(1, begin_pages+1))
            self.assertEqual(context['middle'], [])
            self.assertEqual(context['end'], range(max(numpages - before_current_pages - after_current_pages, 1), numpages+1))

        for x in range(numpages - end_pages - 1, numpages+1):
            page = paginator.page(x)
            context = pagination.pagination(page, begin_pages, end_pages, before_current_pages, after_current_pages)

            self.assertEqual(context['num_pages'], numpages)
            self.assertEqual(context['page'], page)
            self.assertEqual(context['begin'], range(1, begin_pages+1))
            self.assertEqual(context['middle'], [])
            self.assertEqual(context['end'], range(max(numpages - before_current_pages - after_current_pages, 1), numpages+1))