# 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


class RestTestCase(APITestCase):
    def setUp(self):
        instance = RootModel.objects.create(
            slug='instance',
            description="Test",
        )
        for cls in OneToOneModel, ForeignKeyModel, ExtraModel:
            cls.objects.create(
                root=instance,
            )
        self.user = User.objects.create(username="testuser")
        UserManagedModel.objects.create(id=1, user=self.user)
        parent = Parent.objects.create(name="Test", pk=1)
        parent.children.create(name="Test 1")
        parent.children.create(name="Test 2")

# 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



class RestTestCase(APITestCase):
    def setUp(self):
        instance = RootModel.objects.create(
            slug='instance',
            description="Test",
        )
        for cls in OneToOneModel, ForeignKeyModel, ExtraModel:
            cls.objects.create(
                root=instance,
            )
        self.user = User.objects.create(username="testuser")
        UserManagedModel.objects.create(id=1, user=self.user)
        parent = Parent.objects.create(name="Test", pk=1)
        parent.children.create(name="Test 1")
        parent.children.create(name="Test 2")

        parent2 = Parent.objects.create(name="Test 2", pk=2)