summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-08-27 07:19:44 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-08-27 07:19:44 +0000
commitc2ba59fc1da5287d6286e2c2aca4083d5bafe056 (patch)
tree26c05bc1b845efadd28126adee8f2a3726f09424 /tests
parenta1575766604205b3bddf0f05d13ad698c78a7582 (diff)
Removed oldforms, validators, and related code:
* Removed `Manipulator`, `AutomaticManipulator`, and related classes. * Removed oldforms specific bits from model fields: * Removed `validator_list` and `core` arguments from constructors. * Removed the methods: * `get_manipulator_field_names` * `get_manipulator_field_objs` * `get_manipulator_fields` * `get_manipulator_new_data` * `prepare_field_objs_and_params` * `get_follow` * Renamed `flatten_data` method to `value_to_string` for better alignment with its use by the serialization framework, which was the only remaining code using `flatten_data`. * Removed oldforms methods from `django.db.models.Options` class: `get_followed_related_objects`, `get_data_holders`, `get_follow`, and `has_field_type`. * Removed oldforms-admin specific options from `django.db.models.fields.related` classes: `num_in_admin`, `min_num_in_admin`, `max_num_in_admin`, `num_extra_on_change`, and `edit_inline`. * Serialization framework * `Serializer.get_string_value` now calls the model fields' renamed `value_to_string` methods. * Removed a special-casing of `models.DateTimeField` in `core.serializers.base.Serializer.get_string_value` that's handled by `django.db.models.fields.DateTimeField.value_to_string`. * Removed `django.core.validators`: * Moved `ValidationError` exception to `django.core.exceptions`. * For the couple places that were using validators, brought over the necessary code to maintain the same functionality. * Introduced a SlugField form field for validation and to compliment the SlugField model field (refs #8040). * Removed an oldforms-style model creation hack (refs #2160). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8616 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/field_subclassing/models.py3
-rw-r--r--tests/modeltests/invalid_models/models.py8
-rw-r--r--tests/modeltests/manipulators/__init__.py0
-rw-r--r--tests/modeltests/manipulators/models.py105
-rw-r--r--tests/modeltests/mutually_referential/models.py2
-rw-r--r--tests/regressiontests/model_fields/tests.py2
6 files changed, 6 insertions, 114 deletions
diff --git a/tests/modeltests/field_subclassing/models.py b/tests/modeltests/field_subclassing/models.py
index baf07a072f..c776146de5 100644
--- a/tests/modeltests/field_subclassing/models.py
+++ b/tests/modeltests/field_subclassing/models.py
@@ -53,9 +53,6 @@ class SmallField(models.Field):
return []
raise FieldError('Invalid lookup type: %r' % lookup_type)
- def flatten_data(self, follow, obj=None):
- return {self.attname: force_unicode(self._get_val_from_obj(obj))}
-
class MyModel(models.Model):
name = models.CharField(max_length=10)
data = SmallField('small field')
diff --git a/tests/modeltests/invalid_models/models.py b/tests/modeltests/invalid_models/models.py
index abd72b1293..28172089ab 100644
--- a/tests/modeltests/invalid_models/models.py
+++ b/tests/modeltests/invalid_models/models.py
@@ -23,13 +23,13 @@ class Target(models.Model):
clash1_set = models.CharField(max_length=10)
class Clash1(models.Model):
- src_safe = models.CharField(max_length=10, core=True)
+ src_safe = models.CharField(max_length=10)
foreign = models.ForeignKey(Target)
m2m = models.ManyToManyField(Target)
class Clash2(models.Model):
- src_safe = models.CharField(max_length=10, core=True)
+ src_safe = models.CharField(max_length=10)
foreign_1 = models.ForeignKey(Target, related_name='id')
foreign_2 = models.ForeignKey(Target, related_name='src_safe')
@@ -46,7 +46,7 @@ class Target2(models.Model):
clashm2m_set = models.ManyToManyField(Target)
class Clash3(models.Model):
- src_safe = models.CharField(max_length=10, core=True)
+ src_safe = models.CharField(max_length=10)
foreign_1 = models.ForeignKey(Target2, related_name='foreign_tgt')
foreign_2 = models.ForeignKey(Target2, related_name='m2m_tgt')
@@ -61,7 +61,7 @@ class ClashM2M(models.Model):
m2m = models.ManyToManyField(Target2)
class SelfClashForeign(models.Model):
- src_safe = models.CharField(max_length=10, core=True)
+ src_safe = models.CharField(max_length=10)
selfclashforeign = models.CharField(max_length=10)
selfclashforeign_set = models.ForeignKey("SelfClashForeign")
diff --git a/tests/modeltests/manipulators/__init__.py b/tests/modeltests/manipulators/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/modeltests/manipulators/__init__.py
+++ /dev/null
diff --git a/tests/modeltests/manipulators/models.py b/tests/modeltests/manipulators/models.py
deleted file mode 100644
index 0adee9ed39..0000000000
--- a/tests/modeltests/manipulators/models.py
+++ /dev/null
@@ -1,105 +0,0 @@
-# coding: utf-8
-"""
-27. Default manipulators
-
-Each model gets an ``AddManipulator`` and ``ChangeManipulator`` by default.
-"""
-
-from django.db import models
-
-class Musician(models.Model):
- first_name = models.CharField(max_length=30)
- last_name = models.CharField(max_length=30)
-
- def __unicode__(self):
- return u"%s %s" % (self.first_name, self.last_name)
-
-class Album(models.Model):
- name = models.CharField(max_length=100)
- musician = models.ForeignKey(Musician)
- release_date = models.DateField(blank=True, null=True)
-
- def __unicode__(self):
- return self.name
-
-__test__ = {'API_TESTS':u"""
->>> from django.utils.datastructures import MultiValueDict
-
-# Create a Musician object via the default AddManipulator.
->>> man = Musician.AddManipulator()
->>> data = MultiValueDict({'first_name': ['Ella'], 'last_name': ['Fitzgerald']})
-
->>> man.get_validation_errors(data)
-{}
->>> man.do_html2python(data)
->>> m1 = man.save(data)
-
-# Verify it worked.
->>> Musician.objects.all()
-[<Musician: Ella Fitzgerald>]
->>> [m1] == list(Musician.objects.all())
-True
-
-# Attempt to add a Musician without a first_name.
->>> man.get_validation_errors(MultiValueDict({'last_name': ['Blakey']}))['first_name']
-[u'This field is required.']
-
-# Attempt to add a Musician without a first_name and last_name.
->>> errors = man.get_validation_errors(MultiValueDict({}))
->>> errors['first_name']
-[u'This field is required.']
->>> errors['last_name']
-[u'This field is required.']
-
-# Attempt to create an Album without a name or musician.
->>> man = Album.AddManipulator()
->>> errors = man.get_validation_errors(MultiValueDict({}))
->>> errors['musician']
-[u'This field is required.']
->>> errors['name']
-[u'This field is required.']
-
-# Attempt to create an Album with an invalid musician.
->>> errors = man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['foo']}))
->>> errors['musician']
-[u"Select a valid choice; 'foo' is not in [u'', u'1']."]
-
-# Attempt to create an Album with an invalid release_date.
->>> errors = man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['1'], 'release_date': 'today'}))
->>> errors['release_date']
-[u'Enter a valid date in YYYY-MM-DD format.']
-
-# Create an Album without a release_date (because it's optional).
->>> data = MultiValueDict({'name': ['Ella and Basie'], 'musician': ['1']})
->>> man.get_validation_errors(data)
-{}
->>> man.do_html2python(data)
->>> a1 = man.save(data)
-
-# Verify it worked.
->>> Album.objects.all()
-[<Album: Ella and Basie>]
->>> Album.objects.get().musician
-<Musician: Ella Fitzgerald>
-
-# Create an Album with a release_date.
->>> data = MultiValueDict({'name': ['Ultimate Ella'], 'musician': ['1'], 'release_date': ['2005-02-13']})
->>> man.get_validation_errors(data)
-{}
->>> man.do_html2python(data)
->>> a2 = man.save(data)
-
-# Verify it worked.
->>> Album.objects.order_by('name')
-[<Album: Ella and Basie>, <Album: Ultimate Ella>]
->>> a2 = Album.objects.get(pk=2)
->>> a2
-<Album: Ultimate Ella>
->>> a2.release_date
-datetime.date(2005, 2, 13)
-
-# Test isValidFloat Unicode coercion
->>> from django.core.validators import isValidFloat, ValidationError
->>> try: isValidFloat(u"รค", None)
-... except ValidationError: pass
-"""}
diff --git a/tests/modeltests/mutually_referential/models.py b/tests/modeltests/mutually_referential/models.py
index 5176721f3d..2cbaa4b50b 100644
--- a/tests/modeltests/mutually_referential/models.py
+++ b/tests/modeltests/mutually_referential/models.py
@@ -7,7 +7,7 @@ Strings can be used instead of model literals to set up "lazy" relations.
from django.db.models import *
class Parent(Model):
- name = CharField(max_length=100, core=True)
+ name = CharField(max_length=100)
# Use a simple string for forward declarations.
bestchild = ForeignKey("Child", null=True, related_name="favoured_by")
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index 5aedcd15fc..0e67c60ac9 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -18,7 +18,7 @@ True
>>> f.to_python("abc")
Traceback (most recent call last):
...
-ValidationError: [u'This value must be a decimal number.']
+ValidationError: This value must be a decimal number.
>>> f = DecimalField(max_digits=5, decimal_places=1)
>>> x = f.to_python(2)