summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-07-29 09:38:08 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-07-29 09:39:01 -0700
commit0a4fbf4e13b194383f9eecc0af337a50fb6dfe98 (patch)
treea76bcbc998050935b936a1fc9b0452751f30ff97 /tests
parentfb8ddac27afa2720226051cb0daff47bd0377a49 (diff)
[1.7.x] Fixed #23101: Prefer doing deletes before creates in autodetector.
Makes declined or missed renames still work (but drop data).
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_autodetector.py35
1 files changed, 10 insertions, 25 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index 3e0195d0d2..096102ed78 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -276,16 +276,10 @@ class AutodetectorTests(TestCase):
after = self.make_project_state([self.author_name_renamed])
autodetector = MigrationAutodetector(before, after, MigrationQuestioner({"ask_rename": True}))
changes = autodetector._detect_changes()
- # Right number of migrations?
- self.assertEqual(len(changes['testapp']), 1)
- # Right number of actions?
- migration = changes['testapp'][0]
- self.assertEqual(len(migration.operations), 1)
- # Right action?
- action = migration.operations[0]
- self.assertEqual(action.__class__.__name__, "RenameField")
- self.assertEqual(action.old_name, "name")
- self.assertEqual(action.new_name, "names")
+ # Check
+ self.assertNumberMigrations(changes, 'testapp', 1)
+ self.assertOperationTypes(changes, 'testapp', 0, ["RenameField"])
+ self.assertOperationAttributes(changes, 'testapp', 0, 0, old_name="name", new_name="names")
def test_rename_model(self):
"Tests autodetection of renamed models"
@@ -719,21 +713,12 @@ class AutodetectorTests(TestCase):
after = self.make_project_state([self.author_with_publisher, self.publisher])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_changes()
- # Right number of migrations?
- self.assertEqual(len(changes['testapp']), 1)
- # Right number of actions?
- migration = changes['testapp'][0]
- self.assertEqual(len(migration.operations), 3)
- # Right actions?
- action = migration.operations[0]
- self.assertEqual(action.__class__.__name__, "CreateModel")
- self.assertEqual(action.name, "Publisher")
- action = migration.operations[1]
- self.assertEqual(action.__class__.__name__, "AddField")
- self.assertEqual(action.name, "publisher")
- action = migration.operations[2]
- self.assertEqual(action.__class__.__name__, "RemoveField")
- self.assertEqual(action.name, "publisher_name")
+ # Right result?
+ self.assertNumberMigrations(changes, 'testapp', 1)
+ self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel", "RemoveField", "AddField"])
+ self.assertOperationAttributes(changes, 'testapp', 0, 0, name="Publisher")
+ self.assertOperationAttributes(changes, 'testapp', 0, 1, name="publisher_name")
+ self.assertOperationAttributes(changes, 'testapp', 0, 2, name="publisher")
def test_foreign_key_removed_before_target_model(self):
"""