summaryrefslogtreecommitdiff
path: root/tests/modeltests/field_subclassing/models.py
diff options
context:
space:
mode:
authorArthur Koziel <arthur@arthurkoziel.com>2010-09-13 00:04:27 +0000
committerArthur Koziel <arthur@arthurkoziel.com>2010-09-13 00:04:27 +0000
commitdd49269c7db008b2567f50cb03c4d3d9b321daa1 (patch)
tree326dd25bb045ac016cda7966b43cbdfe1f67d699 /tests/modeltests/field_subclassing/models.py
parentc9b188c4ec939abbe48dae5a371276742e64b6b8 (diff)
downloaddjango-soc2010/app-loading.tar.gz
[soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loading
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/field_subclassing/models.py')
-rw-r--r--tests/modeltests/field_subclassing/models.py54
1 files changed, 0 insertions, 54 deletions
diff --git a/tests/modeltests/field_subclassing/models.py b/tests/modeltests/field_subclassing/models.py
index a9fe88fe77..4a55b72961 100644
--- a/tests/modeltests/field_subclassing/models.py
+++ b/tests/modeltests/field_subclassing/models.py
@@ -2,7 +2,6 @@
Tests for field subclassing.
"""
-from django.core import serializers
from django.db import models
from django.utils.encoding import force_unicode
@@ -18,56 +17,3 @@ class MyModel(models.Model):
class DataModel(models.Model):
data = JSONField()
-
-__test__ = {'API_TESTS': ur"""
-# Creating a model with custom fields is done as per normal.
->>> s = Small(1, 2)
->>> print s
-12
->>> m = MyModel(name='m', data=s)
->>> m.save()
-
-# Custom fields still have normal field's attributes.
->>> m._meta.get_field('data').verbose_name
-'small field'
-
-# The m.data attribute has been initialised correctly. It's a Small object.
->>> m.data.first, m.data.second
-(1, 2)
-
-# The data loads back from the database correctly and 'data' has the right type.
->>> m1 = MyModel.objects.get(pk=m.pk)
->>> isinstance(m1.data, Small)
-True
->>> print m1.data
-12
-
-# We can do normal filtering on the custom field (and will get an error when we
-# use a lookup type that does not make sense).
->>> s1 = Small(1, 3)
->>> s2 = Small('a', 'b')
->>> MyModel.objects.filter(data__in=[s, s1, s2])
-[<MyModel: m>]
->>> MyModel.objects.filter(data__lt=s)
-Traceback (most recent call last):
-...
-TypeError: Invalid lookup type: 'lt'
-
-# Serialization works, too.
->>> stream = serializers.serialize("json", MyModel.objects.all())
->>> stream
-'[{"pk": 1, "model": "field_subclassing.mymodel", "fields": {"data": "12", "name": "m"}}]'
->>> obj = list(serializers.deserialize("json", stream))[0]
->>> obj.object == m
-True
-
-# Test retrieving custom field data
->>> m.delete()
->>> m1 = MyModel(name="1", data=Small(1, 2))
->>> m1.save()
->>> m2 = MyModel(name="2", data=Small(2, 3))
->>> m2.save()
->>> for m in MyModel.objects.all(): print unicode(m.data)
-12
-23
-"""}