# Path: tests_app/tests/functional/routers/nested_router_mixin/models.py
# class NestedRouterMixinUserModel(models.Model):
#     email = models.EmailField(blank=True, null=True)
#     name = models.CharField(max_length=10)
#     groups = models.ManyToManyField(
#         'NestedRouterMixinGroupModel', related_name='user_groups')
# 
# class NestedRouterMixinGroupModel(models.Model):
#     name = models.CharField(max_length=10)
#     permissions = models.ManyToManyField('NestedRouterMixinPermissionModel')
# 
# class NestedRouterMixinPermissionModel(models.Model):
#     name = models.CharField(max_length=10)
# 
# class NestedRouterMixinTaskModel(models.Model):
#     title = models.CharField(max_length=30)
# 
# class NestedRouterMixinBookModel(models.Model):
#     title = models.CharField(max_length=30)
# 
# class NestedRouterMixinCommentModel(models.Model):
#     content_type = models.ForeignKey(
#         "contenttypes.ContentType",
#         blank=True,
#         null=True,
#         on_delete=models.CASCADE,
#     )
#     object_id = models.PositiveIntegerField(blank=True, null=True)
#     content_object = GenericForeignKey()
#     text = models.CharField(max_length=30)


from django.test import override_settings
from rest_framework.test import APITestCase
from .models import (
    NestedRouterMixinUserModel as UserModel,
    NestedRouterMixinGroupModel as GroupModel,
    NestedRouterMixinPermissionModel as PermissionModel,
    NestedRouterMixinTaskModel as TaskModel,
    NestedRouterMixinBookModel as BookModel,
    NestedRouterMixinCommentModel as CommentModel
)


@override_settings(ROOT_URLCONF='tests_app.tests.functional.routers.nested_router_mixin.urls_generic_relations')
class NestedRouterMixinTestBehaviour__generic_relations(APITestCase):

    def setUp(self):
        self.tasks = {
            'one': TaskModel.objects.create(id=1, title='Task one'),
            'two': TaskModel.objects.create(id=2, title='Task two'),
        }
        self.books = {
            'one': BookModel.objects.create(id=1, title='Book one'),
            'two': BookModel.objects.create(id=2, title='Book two'),
        }
        self.comments = {
            'for_task_one': CommentModel.objects.create(
                id=1,
                content_object=self.tasks['one'],
                text=u'Comment for task one'
            ),
            'for_task_two': CommentModel.objects.create(
                id=2,
                content_object=self.tasks['two'],
                text=u'Comment for task two'
            ),
            'for_book_one': CommentModel.objects.create(
                id=3,
                content_object=self.books['one'],
                text=u'Comment for book one'
            ),

# Path: tests_app/tests/functional/routers/nested_router_mixin/models.py
# class NestedRouterMixinUserModel(models.Model):
#     email = models.EmailField(blank=True, null=True)
#     name = models.CharField(max_length=10)
#     groups = models.ManyToManyField(
#         'NestedRouterMixinGroupModel', related_name='user_groups')
# 
# class NestedRouterMixinGroupModel(models.Model):
#     name = models.CharField(max_length=10)
#     permissions = models.ManyToManyField('NestedRouterMixinPermissionModel')
# 
# class NestedRouterMixinPermissionModel(models.Model):
#     name = models.CharField(max_length=10)
# 
# class NestedRouterMixinTaskModel(models.Model):
#     title = models.CharField(max_length=30)
# 
# class NestedRouterMixinBookModel(models.Model):
#     title = models.CharField(max_length=30)
# 
# class NestedRouterMixinCommentModel(models.Model):
#     content_type = models.ForeignKey(
#         "contenttypes.ContentType",
#         blank=True,
#         null=True,
#         on_delete=models.CASCADE,
#     )
#     object_id = models.PositiveIntegerField(blank=True, null=True)
#     content_object = GenericForeignKey()
#     text = models.CharField(max_length=30)


# Path: tests_app/tests/functional/routers/nested_router_mixin/tests.py
from django.test import override_settings
from rest_framework.test import APITestCase
from .models import (
    NestedRouterMixinUserModel as UserModel,
    NestedRouterMixinGroupModel as GroupModel,
    NestedRouterMixinPermissionModel as PermissionModel,
    NestedRouterMixinTaskModel as TaskModel,
    NestedRouterMixinBookModel as BookModel,
    NestedRouterMixinCommentModel as CommentModel
)



@override_settings(ROOT_URLCONF='tests_app.tests.functional.routers.nested_router_mixin.urls_generic_relations')
class NestedRouterMixinTestBehaviour__generic_relations(APITestCase):

    def setUp(self):
        self.tasks = {
            'one': TaskModel.objects.create(id=1, title='Task one'),
            'two': TaskModel.objects.create(id=2, title='Task two'),
        }
        self.books = {
            'one': BookModel.objects.create(id=1, title='Book one'),
            'two': BookModel.objects.create(id=2, title='Book two'),
        }
        self.comments = {
            'for_task_one': CommentModel.objects.create(
                id=1,
                content_object=self.tasks['one'],
                text=u'Comment for task one'
            ),
            'for_task_two': CommentModel.objects.create(
                id=2,
                content_object=self.tasks['two'],
                text=u'Comment for task two'
            ),
            'for_book_one': CommentModel.objects.create(
                id=3,
                content_object=self.books['one'],
                text=u'Comment for book one'
            ),

            'for_book_two': CommentModel.objects.create(