# 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 Child(LabelModel):
#     name = models.CharField(max_length=10)
#     parent = models.ForeignKey(Parent, models.CASCADE, related_name="children")
# 
# class ItemType(LabelModel):
#     name = models.CharField(max_length=10)
#     active = models.NullBooleanField(default=True)
# 
# class Item(LabelModel):
#     name = models.CharField(max_length=10)
#     type = models.ForeignKey(ItemType, models.CASCADE)
# 
#     class Meta:
#         ordering = ('type', 'name')
# 
# class SlugModel(LabelModel):
#     code = models.SlugField()
#     name = models.CharField(max_length=255)
# 
# class SlugRefParent(LabelModel):
#     ref = models.ForeignKey(SlugModel, models.CASCADE)
#     name = models.CharField(max_length=255)
# 
#     wq_label_template = "{{name}}{{#ref_id}} ({{ref}}){{/ref_id}}"
# 
# class ChoiceModel(LabelModel):
#     CHOICE_CHOICES = [
#         ('one', 'Choice One'),
#         ('two', 'Choice Two'),
#         ('three', 'Choice Three'),
#     ]
#     name = models.CharField(
#         max_length=10,
#         help_text='Enter Name',
#     )
#     choice = models.CharField(
#         max_length=10,
#         help_text='Pick One',
#         choices=CHOICE_CHOICES,
#     )
# 
#     wq_label_template = "{{name}}: {{choice}}"


from .base import APITestCase
from rest_framework import status
from tests.rest_app.models import (
    RootModel, OneToOneModel, ForeignKeyModel, ExtraModel, UserManagedModel,
    Parent, Child, ItemType, Item, SlugModel, SlugRefParent, ChoiceModel,
)
from django.contrib.auth.models import User
from django.conf import settings
        response = self.client.get('/rest_context')
        html = response.content.decode('utf-8')
        token = html.split('value="')[1].split('"')[0]
        self.assertTrue(len(token) >= 32)
        if settings.WITH_NONROOT:
            base_url = '/wqsite'
        else:
            base_url = ''
        self.assertHTMLEqual("""
            <p>{base_url}/rest_context</p>
            <p>rest_context</p>
            <p>{base_url}/</p>
            <p>{base_url}/</p>
            <p>0.0.0</p>
            <p>
              <input name="csrfmiddlewaretoken" type="hidden" value="{csrf}">
            </p>
            <p>rest_context</p>
            <p>Can Edit Items</p>
        """.format(csrf=token, base_url=base_url), html, auto_replace=False)

    def test_template_page_config(self):
        item = Item.objects.get(name="Test 1")
        self.check_html('/items/%s' % item.pk, """
            <h3>Test 1</h3>
            <a href="/itemtypes/1">Test</a>
            <a href="/items/{pk}/edit">Edit</a>
        """.format(pk=item.pk))

    def test_template_edit_fk(self):

# 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 Child(LabelModel):
#     name = models.CharField(max_length=10)
#     parent = models.ForeignKey(Parent, models.CASCADE, related_name="children")
# 
# class ItemType(LabelModel):
#     name = models.CharField(max_length=10)
#     active = models.NullBooleanField(default=True)
# 
# class Item(LabelModel):
#     name = models.CharField(max_length=10)
#     type = models.ForeignKey(ItemType, models.CASCADE)
# 
#     class Meta:
#         ordering = ('type', 'name')
# 
# class SlugModel(LabelModel):
#     code = models.SlugField()
#     name = models.CharField(max_length=255)
# 
# class SlugRefParent(LabelModel):
#     ref = models.ForeignKey(SlugModel, models.CASCADE)
#     name = models.CharField(max_length=255)
# 
#     wq_label_template = "{{name}}{{#ref_id}} ({{ref}}){{/ref_id}}"
# 
# class ChoiceModel(LabelModel):
#     CHOICE_CHOICES = [
#         ('one', 'Choice One'),
#         ('two', 'Choice Two'),
#         ('three', 'Choice Three'),
#     ]
#     name = models.CharField(
#         max_length=10,
#         help_text='Enter Name',
#     )
#     choice = models.CharField(
#         max_length=10,
#         help_text='Pick One',
#         choices=CHOICE_CHOICES,
#     )
# 
#     wq_label_template = "{{name}}: {{choice}}"


# Path: tests/test_template.py
from .base import APITestCase
from rest_framework import status
from tests.rest_app.models import (
    RootModel, OneToOneModel, ForeignKeyModel, ExtraModel, UserManagedModel,
    Parent, Child, ItemType, Item, SlugModel, SlugRefParent, ChoiceModel,
)
from django.contrib.auth.models import User
from django.conf import settings

        response = self.client.get('/rest_context')
        html = response.content.decode('utf-8')
        token = html.split('value="')[1].split('"')[0]
        self.assertTrue(len(token) >= 32)
        if settings.WITH_NONROOT:
            base_url = '/wqsite'
        else:
            base_url = ''
        self.assertHTMLEqual("""
            <p>{base_url}/rest_context</p>
            <p>rest_context</p>
            <p>{base_url}/</p>
            <p>{base_url}/</p>
            <p>0.0.0</p>
            <p>
              <input name="csrfmiddlewaretoken" type="hidden" value="{csrf}">
            </p>
            <p>rest_context</p>
            <p>Can Edit Items</p>
        """.format(csrf=token, base_url=base_url), html, auto_replace=False)

    def test_template_page_config(self):
        item = Item.objects.get(name="Test 1")
        self.check_html('/items/%s' % item.pk, """
            <h3>Test 1</h3>
            <a href="/itemtypes/1">Test</a>
            <a href="/items/{pk}/edit">Edit</a>
        """.format(pk=item.pk))

    def test_template_edit_fk(self):

        item = Item.objects.get(name="Test 1")