# Path: tests/base.py
# class APITestCase(APITestCase):
#     client_class = APIClient
# 
# Path: tests/rest_app/models.py
# class RootModel(LabelModel):
#     slug = models.SlugField()
#     description = models.TextField()
# 
#     wq_label_template = "{{slug}}"
# 
# class OneToOneModel(LabelModel):
#     root = models.OneToOneField(RootModel, models.CASCADE)
# 
#     wq_label_template = "onetoonemodel for {{root}}"
# 
# class ForeignKeyModel(LabelModel):
#     root = models.ForeignKey(RootModel, models.CASCADE)
# 
#     wq_label_template = "foreignkeymodel for {{root}}"
# 
# class ExtraModel(LabelModel):
#     root = models.ForeignKey(
#         RootModel,
#         models.CASCADE,
#         related_name="extramodels",
#     )
#     alt_root = models.ForeignKey(
#         RootModel,
#         models.CASCADE,
#         related_name="extramodel_set",
#         null=True,
#         blank=True,
#     )
# 
#     wq_label_template = "extramodel for {{root}}"
# 
# class UserManagedModel(models.Model):
#     user = models.ForeignKey("auth.User", models.CASCADE)
# 
# class Parent(LabelModel):
#     name = models.CharField(max_length=10)
# 
# class ItemType(LabelModel):
#     name = models.CharField(max_length=10)
#     active = models.NullBooleanField(default=True)
# 
# class SlugModel(LabelModel):
#     code = models.SlugField()
#     name = models.CharField(max_length=255)


from .base import APITestCase
from rest_framework import status
from tests.rest_app.models import (
    RootModel, OneToOneModel, ForeignKeyModel, ExtraModel, UserManagedModel,
    Parent, ItemType, SlugModel,
)
from django.contrib.auth.models import User
        self.assertEqual(response.data['per_page'], 10)

    def test_rest_cache_all(self):
        for num in range(2, 101):
            ItemType.objects.create(
                pk=num,
                name='Type #%s' % num
            )

        tests = [
             (100, '/itemtypes.json'),
             (50, '/itemtypes/'),
             (50, '/itemtypes.json?page=1'),
        ]
        for expect_items, url in tests:
            response = self.client.get(url)
            self.assertTrue(
                status.is_success(response.status_code), response.data
            )
            self.assertEqual(
                len(response.data['list']), expect_items,
                "%s should return %s items" % (url, expect_items)
            )
            self.assertEqual(response.data['pages'], 2)
            self.assertEqual(response.data['per_page'], 50)
            self.assertEqual(response.data['count'], 100)

    def test_rest_cache_filter(self):
        other_user = User.objects.create(username='otheruser')
        UserManagedModel.objects.create(id=2, user=other_user)

# Path: tests/base.py
# class APITestCase(APITestCase):
#     client_class = APIClient
# 
# Path: tests/rest_app/models.py
# class RootModel(LabelModel):
#     slug = models.SlugField()
#     description = models.TextField()
# 
#     wq_label_template = "{{slug}}"
# 
# class OneToOneModel(LabelModel):
#     root = models.OneToOneField(RootModel, models.CASCADE)
# 
#     wq_label_template = "onetoonemodel for {{root}}"
# 
# class ForeignKeyModel(LabelModel):
#     root = models.ForeignKey(RootModel, models.CASCADE)
# 
#     wq_label_template = "foreignkeymodel for {{root}}"
# 
# class ExtraModel(LabelModel):
#     root = models.ForeignKey(
#         RootModel,
#         models.CASCADE,
#         related_name="extramodels",
#     )
#     alt_root = models.ForeignKey(
#         RootModel,
#         models.CASCADE,
#         related_name="extramodel_set",
#         null=True,
#         blank=True,
#     )
# 
#     wq_label_template = "extramodel for {{root}}"
# 
# class UserManagedModel(models.Model):
#     user = models.ForeignKey("auth.User", models.CASCADE)
# 
# class Parent(LabelModel):
#     name = models.CharField(max_length=10)
# 
# class ItemType(LabelModel):
#     name = models.CharField(max_length=10)
#     active = models.NullBooleanField(default=True)
# 
# class SlugModel(LabelModel):
#     code = models.SlugField()
#     name = models.CharField(max_length=255)


# Path: tests/test_rest.py
from .base import APITestCase
from rest_framework import status
from tests.rest_app.models import (
    RootModel, OneToOneModel, ForeignKeyModel, ExtraModel, UserManagedModel,
    Parent, ItemType, SlugModel,
)
from django.contrib.auth.models import User

        self.assertEqual(response.data['per_page'], 10)

    def test_rest_cache_all(self):
        for num in range(2, 101):
            ItemType.objects.create(
                pk=num,
                name='Type #%s' % num
            )

        tests = [
             (100, '/itemtypes.json'),
             (50, '/itemtypes/'),
             (50, '/itemtypes.json?page=1'),
        ]
        for expect_items, url in tests:
            response = self.client.get(url)
            self.assertTrue(
                status.is_success(response.status_code), response.data
            )
            self.assertEqual(
                len(response.data['list']), expect_items,
                "%s should return %s items" % (url, expect_items)
            )
            self.assertEqual(response.data['pages'], 2)
            self.assertEqual(response.data['per_page'], 50)
            self.assertEqual(response.data['count'], 100)

    def test_rest_cache_filter(self):
        other_user = User.objects.create(username='otheruser')
        UserManagedModel.objects.create(id=2, user=other_user)

        UserManagedModel.objects.create(id=3, user=other_user)