mirror of https://github.com/django/django.git
Refs #29522 -- Improved test coverage of deserializers.
This commit is contained in:
parent
f4813211e2
commit
b2501759eb
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
{"pk": "1", "model": "fixtures_regress.animal", "fields": {"name": "Eagle", "latin_name": "Aquila", "count": 3, "weight": 1.2}}
|
|
@ -0,0 +1,2 @@
|
||||||
|
{"pk": "1", "model": "fixtures_regress.animal", "fields": {"name": "Eagle", "extra_name": "Super Eagle", "latin_name": "Aquila", "count": 3, "weight": 1.2}}
|
||||||
|
{"pk": "1", "model": "fixtures_regress.animal_extra", "fields": {"name": "Nonexistent model", "extra_name": "test for ticket #29522", "latin_name": "Aquila", "count": 3, "weight": 1.2}}
|
|
@ -0,0 +1,17 @@
|
||||||
|
- pk: "1"
|
||||||
|
model: fixtures_regress.animal
|
||||||
|
fields:
|
||||||
|
name: Cat
|
||||||
|
extra_name: Super Cat
|
||||||
|
latin_name: Felis catus
|
||||||
|
count: 3
|
||||||
|
weight: 1.2
|
||||||
|
|
||||||
|
- pk: "1"
|
||||||
|
model: fixtures_regress.animal_extra
|
||||||
|
fields:
|
||||||
|
name: Nonexistent model
|
||||||
|
extra_name: test for ticket \#29522
|
||||||
|
latin_name: Felis catus
|
||||||
|
count: 3
|
||||||
|
weight: 1.2
|
|
@ -96,10 +96,18 @@ class TestFixtures(TestCase):
|
||||||
the serialized data for fields that have been removed
|
the serialized data for fields that have been removed
|
||||||
from the database when not ignored.
|
from the database when not ignored.
|
||||||
"""
|
"""
|
||||||
with self.assertRaises(DeserializationError):
|
for fixture_file in (
|
||||||
|
"sequence_extra",
|
||||||
|
"sequence_extra_jsonl",
|
||||||
|
"sequence_extra_yaml",
|
||||||
|
):
|
||||||
|
with (
|
||||||
|
self.subTest(fixture_file=fixture_file),
|
||||||
|
self.assertRaises(DeserializationError),
|
||||||
|
):
|
||||||
management.call_command(
|
management.call_command(
|
||||||
"loaddata",
|
"loaddata",
|
||||||
"sequence_extra",
|
fixture_file,
|
||||||
verbosity=0,
|
verbosity=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -130,6 +138,32 @@ class TestFixtures(TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(Animal.specimens.all()[0].name, "Wolf")
|
self.assertEqual(Animal.specimens.all()[0].name, "Wolf")
|
||||||
|
|
||||||
|
def test_loaddata_not_found_fields_ignore_jsonl(self):
|
||||||
|
management.call_command(
|
||||||
|
"loaddata",
|
||||||
|
"sequence_extra_jsonl",
|
||||||
|
ignore=True,
|
||||||
|
verbosity=0,
|
||||||
|
)
|
||||||
|
self.assertEqual(Animal.specimens.all()[0].name, "Eagle")
|
||||||
|
|
||||||
|
def test_loaddata_not_found_fields_ignore_yaml(self):
|
||||||
|
management.call_command(
|
||||||
|
"loaddata",
|
||||||
|
"sequence_extra_yaml",
|
||||||
|
ignore=True,
|
||||||
|
verbosity=0,
|
||||||
|
)
|
||||||
|
self.assertEqual(Animal.specimens.all()[0].name, "Cat")
|
||||||
|
|
||||||
|
def test_loaddata_empty_lines_jsonl(self):
|
||||||
|
management.call_command(
|
||||||
|
"loaddata",
|
||||||
|
"sequence_empty_lines_jsonl.jsonl",
|
||||||
|
verbosity=0,
|
||||||
|
)
|
||||||
|
self.assertEqual(Animal.specimens.all()[0].name, "Eagle")
|
||||||
|
|
||||||
@skipIfDBFeature("interprets_empty_strings_as_nulls")
|
@skipIfDBFeature("interprets_empty_strings_as_nulls")
|
||||||
def test_pretty_print_xml(self):
|
def test_pretty_print_xml(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue