def test_qs(self):
        for n in xrange(10, 20):
            name = 'u%d' % n
            user = User.objects.create(username=name, is_active=True)
        for n in xrange(20, 30):
            name = 'u%d' % n
            user = User.objects.create(username=name, is_active=False)

        onpage = 2
        p = CompoundPaginator((User.objects.filter(is_active=True),
                               User.objects.filter(is_active=False)), onpage)
        for page_n in p.page_range:
            page = p.page(page_n)
            self.assertIterableEquals(
                range(onpage * (page_n - 1) + 10, onpage * page_n + 10),
                [int(user.username[1:]) for user in page.object_list])

        p = CompoundPaginator(
            ([User.objects.get(username='******')
              ], User.objects.filter(is_active=False).exclude(username='******')),
            onpage)
        for page_n in p.page_range:
            page = p.page(page_n)
            self.assertIterableEquals(
                range(onpage * (page_n - 1) + 20, onpage * page_n + 20),
                [int(user.username[1:]) for user in page.object_list])

        p = CompoundPaginator((User.objects.filter(username='******'),
                               User.objects.filter(username='******')), onpage)
        page = p.page(1)
        self.assertIterableEquals([
            User.objects.get(username='******'),
            User.objects.get(username='******')
        ], page.object_list)
    def test_boundary(self):
        onpage = 5
        p = CompoundPaginator((range(1), range(1, 50)), onpage)
        for page_n in p.page_range:
            page = p.page(page_n)
            self.assertIterableEquals(
                range(onpage * (page_n - 1), onpage * page_n),
                page.object_list)

        p = CompoundPaginator((range(39), range(39, 40)), onpage)
        for page_n in p.page_range:
            page = p.page(page_n)
            self.assertIterableEquals(
                page.object_list, range(onpage * (page_n - 1),
                                        onpage * page_n))
 def test_basic(self):
     p = CompoundPaginator((range(0, 20), range(20, 50)), 5)
     for page_n in p.page_range:
         page = p.page(page_n)
         self.assertIterableEquals(range(5 * (page_n - 1), 5 * page_n),
                                   page.object_list)