mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f68fa8b45d
commit
9c19aff7c7
@@ -2,9 +2,14 @@ from django.forms.models import inlineformset_factory
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import (
|
||||
AutoPKChildOfUUIDPKParent, AutoPKParent, ChildRelatedViaAK,
|
||||
ChildWithEditablePK, ParentWithUUIDAlternateKey, UUIDPKChild,
|
||||
UUIDPKChildOfAutoPKParent, UUIDPKParent,
|
||||
AutoPKChildOfUUIDPKParent,
|
||||
AutoPKParent,
|
||||
ChildRelatedViaAK,
|
||||
ChildWithEditablePK,
|
||||
ParentWithUUIDAlternateKey,
|
||||
UUIDPKChild,
|
||||
UUIDPKChildOfAutoPKParent,
|
||||
UUIDPKParent,
|
||||
)
|
||||
|
||||
|
||||
@@ -17,24 +22,26 @@ class InlineFormsetTests(TestCase):
|
||||
|
||||
Tests the case where both the parent and child have a UUID primary key.
|
||||
"""
|
||||
FormSet = inlineformset_factory(UUIDPKParent, UUIDPKChild, fields='__all__')
|
||||
FormSet = inlineformset_factory(UUIDPKParent, UUIDPKChild, fields="__all__")
|
||||
formset = FormSet()
|
||||
self.assertIsNone(formset.forms[0].fields['parent'].initial)
|
||||
self.assertIsNone(formset.forms[0].fields["parent"].initial)
|
||||
|
||||
def test_inlineformset_factory_ignores_default_pks_on_submit(self):
|
||||
"""
|
||||
#24377 - Inlines with a model field default should ignore that default
|
||||
value to avoid triggering validation on empty forms.
|
||||
"""
|
||||
FormSet = inlineformset_factory(UUIDPKParent, UUIDPKChild, fields='__all__')
|
||||
formset = FormSet({
|
||||
'uuidpkchild_set-TOTAL_FORMS': 3,
|
||||
'uuidpkchild_set-INITIAL_FORMS': 0,
|
||||
'uuidpkchild_set-MAX_NUM_FORMS': '',
|
||||
'uuidpkchild_set-0-name': 'Foo',
|
||||
'uuidpkchild_set-1-name': '',
|
||||
'uuidpkchild_set-2-name': '',
|
||||
})
|
||||
FormSet = inlineformset_factory(UUIDPKParent, UUIDPKChild, fields="__all__")
|
||||
formset = FormSet(
|
||||
{
|
||||
"uuidpkchild_set-TOTAL_FORMS": 3,
|
||||
"uuidpkchild_set-INITIAL_FORMS": 0,
|
||||
"uuidpkchild_set-MAX_NUM_FORMS": "",
|
||||
"uuidpkchild_set-0-name": "Foo",
|
||||
"uuidpkchild_set-1-name": "",
|
||||
"uuidpkchild_set-2-name": "",
|
||||
}
|
||||
)
|
||||
self.assertTrue(formset.is_valid())
|
||||
|
||||
def test_inlineformset_factory_nulls_default_pks_uuid_parent_auto_child(self):
|
||||
@@ -43,9 +50,11 @@ class InlineFormsetTests(TestCase):
|
||||
the case of a parent object with a UUID primary key and a child object
|
||||
with an AutoField primary key.
|
||||
"""
|
||||
FormSet = inlineformset_factory(UUIDPKParent, AutoPKChildOfUUIDPKParent, fields='__all__')
|
||||
FormSet = inlineformset_factory(
|
||||
UUIDPKParent, AutoPKChildOfUUIDPKParent, fields="__all__"
|
||||
)
|
||||
formset = FormSet()
|
||||
self.assertIsNone(formset.forms[0].fields['parent'].initial)
|
||||
self.assertIsNone(formset.forms[0].fields["parent"].initial)
|
||||
|
||||
def test_inlineformset_factory_nulls_default_pks_auto_parent_uuid_child(self):
|
||||
"""
|
||||
@@ -53,9 +62,11 @@ class InlineFormsetTests(TestCase):
|
||||
the case of a parent object with an AutoField primary key and a child
|
||||
object with a UUID primary key.
|
||||
"""
|
||||
FormSet = inlineformset_factory(AutoPKParent, UUIDPKChildOfAutoPKParent, fields='__all__')
|
||||
FormSet = inlineformset_factory(
|
||||
AutoPKParent, UUIDPKChildOfAutoPKParent, fields="__all__"
|
||||
)
|
||||
formset = FormSet()
|
||||
self.assertIsNone(formset.forms[0].fields['parent'].initial)
|
||||
self.assertIsNone(formset.forms[0].fields["parent"].initial)
|
||||
|
||||
def test_inlineformset_factory_nulls_default_pks_child_editable_pk(self):
|
||||
"""
|
||||
@@ -63,9 +74,11 @@ class InlineFormsetTests(TestCase):
|
||||
the case of a parent object with a UUID primary key and a child
|
||||
object with an editable natural key for a primary key.
|
||||
"""
|
||||
FormSet = inlineformset_factory(UUIDPKParent, ChildWithEditablePK, fields='__all__')
|
||||
FormSet = inlineformset_factory(
|
||||
UUIDPKParent, ChildWithEditablePK, fields="__all__"
|
||||
)
|
||||
formset = FormSet()
|
||||
self.assertIsNone(formset.forms[0].fields['parent'].initial)
|
||||
self.assertIsNone(formset.forms[0].fields["parent"].initial)
|
||||
|
||||
def test_inlineformset_factory_nulls_default_pks_alternate_key_relation(self):
|
||||
"""
|
||||
@@ -73,6 +86,8 @@ class InlineFormsetTests(TestCase):
|
||||
the case of a parent object with a UUID alternate key and a child
|
||||
object that relates to that alternate key.
|
||||
"""
|
||||
FormSet = inlineformset_factory(ParentWithUUIDAlternateKey, ChildRelatedViaAK, fields='__all__')
|
||||
FormSet = inlineformset_factory(
|
||||
ParentWithUUIDAlternateKey, ChildRelatedViaAK, fields="__all__"
|
||||
)
|
||||
formset = FormSet()
|
||||
self.assertIsNone(formset.forms[0].fields['parent'].initial)
|
||||
self.assertIsNone(formset.forms[0].fields["parent"].initial)
|
||||
|
||||
Reference in New Issue
Block a user