aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTymur Maryokhin2014-11-29 20:04:50 +0100
committerTymur Maryokhin2014-11-29 20:04:50 +0100
commitdd9d40d8c01f54f1542ba728d89b8b2da584dc1f (patch)
treef184fea9c5c1b1cdc0949e214261da3e08402161 /tests
parent2f03483f966c5402734b5db2f7006c788bbe04f7 (diff)
downloaddjango-rest-framework-dd9d40d8c01f54f1542ba728d89b8b2da584dc1f.tar.bz2
Moved non-conflicting models
Diffstat (limited to 'tests')
-rw-r--r--tests/models.py12
-rw-r--r--tests/test_generics.py34
2 files changed, 25 insertions, 21 deletions
diff --git a/tests/models.py b/tests/models.py
index a0e0b3cc..456b0a0b 100644
--- a/tests/models.py
+++ b/tests/models.py
@@ -17,11 +17,6 @@ class BasicModel(RESTFrameworkModel):
text = models.CharField(max_length=100, verbose_name=_("Text comes here"), help_text=_("Text description."))
-class SlugBasedModel(RESTFrameworkModel):
- text = models.CharField(max_length=100)
- slug = models.SlugField(max_length=32)
-
-
class BaseFilterableItem(RESTFrameworkModel):
text = models.CharField(max_length=100)
@@ -34,13 +29,6 @@ class FilterableItem(BaseFilterableItem):
date = models.DateField()
-# Model for regression test for #285
-class Comment(RESTFrameworkModel):
- email = models.EmailField()
- content = models.CharField(max_length=200)
- created = models.DateTimeField(auto_now_add=True)
-
-
# Models for relations tests
# ManyToMany
class ManyToManyTarget(RESTFrameworkModel):
diff --git a/tests/test_generics.py b/tests/test_generics.py
index 2690fb47..b78584f0 100644
--- a/tests/test_generics.py
+++ b/tests/test_generics.py
@@ -6,12 +6,26 @@ from django.test import TestCase
from django.utils import six
from rest_framework import generics, renderers, serializers, status
from rest_framework.test import APIRequestFactory
-from tests.models import BasicModel, Comment, SlugBasedModel
+from tests.models import BasicModel, RESTFrameworkModel
from tests.models import ForeignKeySource, ForeignKeyTarget
factory = APIRequestFactory()
+# Models
+class SlugBasedModel(RESTFrameworkModel):
+ text = models.CharField(max_length=100)
+ slug = models.SlugField(max_length=32)
+
+
+# Model for regression test for #285
+class Comment(RESTFrameworkModel):
+ email = models.EmailField()
+ content = models.CharField(max_length=200)
+ created = models.DateTimeField(auto_now_add=True)
+
+
+# Serializers
class BasicSerializer(serializers.ModelSerializer):
class Meta:
model = BasicModel
@@ -22,6 +36,15 @@ class ForeignKeySerializer(serializers.ModelSerializer):
model = ForeignKeySource
+class SlugSerializer(serializers.ModelSerializer):
+ slug = serializers.ReadOnlyField()
+
+ class Meta:
+ model = SlugBasedModel
+ fields = ('text', 'slug')
+
+
+# Views
class RootView(generics.ListCreateAPIView):
queryset = BasicModel.objects.all()
serializer_class = BasicSerializer
@@ -37,14 +60,6 @@ class FKInstanceView(generics.RetrieveUpdateDestroyAPIView):
serializer_class = ForeignKeySerializer
-class SlugSerializer(serializers.ModelSerializer):
- slug = serializers.ReadOnlyField()
-
- class Meta:
- model = SlugBasedModel
- fields = ('text', 'slug')
-
-
class SlugBasedInstanceView(InstanceView):
"""
A model with a slug-field.
@@ -54,6 +69,7 @@ class SlugBasedInstanceView(InstanceView):
lookup_field = 'slug'
+# Tests
class TestRootView(TestCase):
def setUp(self):
"""