diff options
author | Ian Kelly <ian.g.kelly@gmail.com> | 2011-03-08 22:50:56 +0000 |
---|---|---|
committer | Ian Kelly <ian.g.kelly@gmail.com> | 2011-03-08 22:50:56 +0000 |
commit | 05b197dbb17fad30dd8a0cdc68bfb453697473ed (patch) | |
tree | f5445dcb8a30c4fb57dc094000a25480383c00ba | |
parent | e81e64cd6361c43c775ccd52d9c4684fa935fcb7 (diff) | |
download | django-05b197dbb17fad30dd8a0cdc68bfb453697473ed.tar.gz |
[1.2.X] Added a skip for a test that fails in Oracle. Unlike other backends, Oracle does not allow duplicate rows where there is a unique_together constraint for which some but not all of the columns are NULL.
Backport of r15777 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15778 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r-- | tests/modeltests/model_formsets/tests.py | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/tests/modeltests/model_formsets/tests.py b/tests/modeltests/model_formsets/tests.py index 91c9043e75..059d70e1ef 100644 --- a/tests/modeltests/model_formsets/tests.py +++ b/tests/modeltests/model_formsets/tests.py @@ -4,7 +4,8 @@ from datetime import date from decimal import Decimal from django import forms -from django.db import models +from django.conf import settings +from django.db import models, DEFAULT_DB_ALIAS from django.forms.models import (_get_foreign_key, inlineformset_factory, modelformset_factory, modelformset_factory) from django.test import TestCase @@ -577,30 +578,33 @@ class ModelFormsetTest(TestCase): self.assertEqual(book1.title, 'Flowers of Evil') self.assertEqual(book1.notes, 'English translation of Les Fleurs du Mal') - # Test inline formsets where the inline-edited object has a - # unique_together constraint with a nullable member - - AuthorBooksFormSet4 = inlineformset_factory(Author, BookWithOptionalAltEditor, can_delete=False, extra=2) - - data = { - 'bookwithoptionalalteditor_set-TOTAL_FORMS': '2', # the number of forms rendered - 'bookwithoptionalalteditor_set-INITIAL_FORMS': '0', # the number of forms with initial data - 'bookwithoptionalalteditor_set-MAX_NUM_FORMS': '', # the max number of forms - 'bookwithoptionalalteditor_set-0-author': '1', - 'bookwithoptionalalteditor_set-0-title': 'Les Fleurs du Mal', - 'bookwithoptionalalteditor_set-1-author': '1', - 'bookwithoptionalalteditor_set-1-title': 'Les Fleurs du Mal', - } - formset = AuthorBooksFormSet4(data, instance=author) - self.assertTrue(formset.is_valid()) - - saved = formset.save() - self.assertEqual(len(saved), 2) - book1, book2 = saved - self.assertEqual(book1.author_id, 1) - self.assertEqual(book1.title, 'Les Fleurs du Mal') - self.assertEqual(book2.author_id, 1) - self.assertEqual(book2.title, 'Les Fleurs du Mal') + if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] != 'django.db.backends.oracle': + def test_inline_formsets_with_nullable_unique_together(self): + # Test inline formsets where the inline-edited object has a + # unique_together constraint with a nullable member + + AuthorBooksFormSet4 = inlineformset_factory(Author, BookWithOptionalAltEditor, can_delete=False, extra=2) + author = Author.objects.create(pk=1, name='Charles Baudelaire') + + data = { + 'bookwithoptionalalteditor_set-TOTAL_FORMS': '2', # the number of forms rendered + 'bookwithoptionalalteditor_set-INITIAL_FORMS': '0', # the number of forms with initial data + 'bookwithoptionalalteditor_set-MAX_NUM_FORMS': '', # the max number of forms + 'bookwithoptionalalteditor_set-0-author': '1', + 'bookwithoptionalalteditor_set-0-title': 'Les Fleurs du Mal', + 'bookwithoptionalalteditor_set-1-author': '1', + 'bookwithoptionalalteditor_set-1-title': 'Les Fleurs du Mal', + } + formset = AuthorBooksFormSet4(data, instance=author) + self.assertTrue(formset.is_valid()) + + saved = formset.save() + self.assertEqual(len(saved), 2) + book1, book2 = saved + self.assertEqual(book1.author_id, 1) + self.assertEqual(book1.title, 'Les Fleurs du Mal') + self.assertEqual(book2.author_id, 1) + self.assertEqual(book2.title, 'Les Fleurs du Mal') def test_inline_formsets_with_custom_save_method(self): AuthorBooksFormSet = inlineformset_factory(Author, Book, can_delete=False, extra=2) |