# Path: tests/base.py
# class APITestCase(APITestCase):
#     client_class = APIClient
# 
# Path: tests/naturalkey_app/models.py
# class ModelWithNaturalKey(models.Model):
#     key = models.ForeignKey(NaturalKeyChild, models.CASCADE)
#     note = models.TextField()
# 
#     def __str__(self):
#         return "%s: %s" % (self.key, self.note)


from .base import APITestCase
from rest_framework import status
from django.contrib.auth.models import User
from tests.naturalkey_app.models import ModelWithNaturalKey
import json
                     'bind': {'required': True},
                }, {
                     'name': 'date',
                     'label': 'Date',
                     'type': 'date',
                     'bind': {'required': True},
                }]
            }
        ], response.data['pages']['modelwithnaturalkey']['form'])

    def test_naturalkey_post(self):
        form = {
            'key[parent][slug]': 'test-key',
            'key[date]': '2016-12-31',
            'note': 'Test Note',
        }

        response = self.client.post('/modelwithnaturalkeys.json', form)
        self.assertEqual(
            response.status_code, status.HTTP_201_CREATED, response.data
        )
        instance = ModelWithNaturalKey.objects.get(pk=response.data['id'])

        self.assertEqual(json.loads(response.content.decode('utf-8')), {
            'id': instance.id,
            'key_id': instance.key_id,

            'note': 'Test Note',
            'key': {
                'parent': {'slug': 'test-key'},

# Path: tests/base.py
# class APITestCase(APITestCase):
#     client_class = APIClient
# 
# Path: tests/naturalkey_app/models.py
# class ModelWithNaturalKey(models.Model):
#     key = models.ForeignKey(NaturalKeyChild, models.CASCADE)
#     note = models.TextField()
# 
#     def __str__(self):
#         return "%s: %s" % (self.key, self.note)


# Path: tests/test_naturalkey.py
from .base import APITestCase
from rest_framework import status
from django.contrib.auth.models import User
from tests.naturalkey_app.models import ModelWithNaturalKey
import json

                     'bind': {'required': True},
                }, {
                     'name': 'date',
                     'label': 'Date',
                     'type': 'date',
                     'bind': {'required': True},
                }]
            }
        ], response.data['pages']['modelwithnaturalkey']['form'])

    def test_naturalkey_post(self):
        form = {
            'key[parent][slug]': 'test-key',
            'key[date]': '2016-12-31',
            'note': 'Test Note',
        }

        response = self.client.post('/modelwithnaturalkeys.json', form)
        self.assertEqual(
            response.status_code, status.HTTP_201_CREATED, response.data
        )
        instance = ModelWithNaturalKey.objects.get(pk=response.data['id'])

        self.assertEqual(json.loads(response.content.decode('utf-8')), {
            'id': instance.id,
            'key_id': instance.key_id,

            'note': 'Test Note',
            'key': {
                'parent': {'slug': 'test-key'},

                'date': '2016-12-31',