summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-06-01 15:42:13 +0000
committerHonza Král <honza.kral@gmail.com>2009-06-01 15:42:13 +0000
commitafcb3c887290fb4df73e72780f864b1ec82a2ac2 (patch)
treef2b38be36c17ab431d75272052b89c22489e6faa
parent3ca1199da85b226c61faa7b5502e82058aa86c58 (diff)
[soc2009/model-validation] moved validation tests to tests.py out of models.py
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@10878 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/modeltests/validation/models.py17
-rw-r--r--tests/modeltests/validation/tests.py22
2 files changed, 22 insertions, 17 deletions
diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
index bce49741a1..77b1b07cf6 100644
--- a/tests/modeltests/validation/models.py
+++ b/tests/modeltests/validation/models.py
@@ -14,20 +14,3 @@ class ModelToValidate(models.Model):
if self.number == 11:
raise ValidationError('Invalid number supplied!')
-class BaseModelValidationTests(TestCase):
- def test_missing_required_field_raises_error(self):
- mtv = ModelToValidate()
- self.assertRaises(ValidationError, mtv.clean)
- try:
- mtv.clean()
- except ValidationError, e:
- self.assertEquals(['name', 'number'], sorted(e.message_dict.keys()))
-
- def test_with_correct_value_model_validates(self):
- mtv = ModelToValidate(number=10, name='Some Name')
- self.assertEqual(None, mtv.clean())
-
- def test_custom_validate_method_is_called(self):
- mtv = ModelToValidate(number=11)
- self.assertRaises(ValidationError, mtv.clean)
-
diff --git a/tests/modeltests/validation/tests.py b/tests/modeltests/validation/tests.py
new file mode 100644
index 0000000000..f1d558aa8d
--- /dev/null
+++ b/tests/modeltests/validation/tests.py
@@ -0,0 +1,22 @@
+from django.core.exceptions import ValidationError
+from django.test import TestCase
+
+from models import ModelToValidate
+
+class BaseModelValidationTests(TestCase):
+ def test_missing_required_field_raises_error(self):
+ mtv = ModelToValidate()
+ self.assertRaises(ValidationError, mtv.clean)
+ try:
+ mtv.clean()
+ except ValidationError, e:
+ self.assertEquals(['name', 'number'], sorted(e.message_dict.keys()))
+
+ def test_with_correct_value_model_validates(self):
+ mtv = ModelToValidate(number=10, name='Some Name')
+ self.assertEqual(None, mtv.clean())
+
+ def test_custom_validate_method_is_called(self):
+ mtv = ModelToValidate(number=11)
+ self.assertRaises(ValidationError, mtv.clean)
+