1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

[1.7.x] Fixed #22951 -- Checked for types during deep_deconstruct migration serializ

Thanks Sam Hartsfield for the report.

Backport of 4680d25df2 from master
This commit is contained in:
Andrew Pinkham
2014-09-08 07:56:35 -04:00
committed by Tim Graham
parent 267b121b1e
commit 27e7972e63
3 changed files with 28 additions and 1 deletions

View File

@@ -665,6 +665,31 @@ class AutodetectorTests(TestCase):
changes = autodetector._detect_changes()
self.assertEqual(changes, {})
def test_deconstruct_type(self):
"""
#22951 -- Uninstanted classes with deconstruct are correctly returned
by deep_deconstruct during serialization.
"""
author = ModelState(
"testapp",
"Author",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(
max_length=200,
# IntegerField intentionally not instantiated.
default=models.IntegerField,
))
],
)
# Make state
before = self.make_project_state([])
after = self.make_project_state([author])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_changes()
self.assertNumberMigrations(changes, 'testapp', 1)
self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel"])
def test_replace_string_with_foreignkey(self):
"""
Adding an FK in the same "spot" as a deleted CharField should work. (#22300).