MCPcopy
hub / github.com/django/django / test_last_dependency

Method test_last_dependency

tests/migrations/test_autodetector.py:5103–5121  ·  view source on GitHub ↗

A dependency to an app with existing migrations uses the last migration of that app.

(self)

Source from the content-addressed store, hash-verified

5101
5102 @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
5103 def test_last_dependency(self):
5104 """
5105 A dependency to an app with existing migrations uses the
5106 last migration of that app.
5107 """
5108 # Load graph
5109 loader = MigrationLoader(connection)
5110 before = self.make_project_state([])
5111 after = self.make_project_state([self.book_migrations_fk])
5112 after.real_apps = {"migrations"}
5113 autodetector = MigrationAutodetector(before, after)
5114 changes = autodetector._detect_changes(graph=loader.graph)
5115 # Right number/type of migrations?
5116 self.assertNumberMigrations(changes, "otherapp", 1)
5117 self.assertOperationTypes(changes, "otherapp", 0, ["CreateModel"])
5118 self.assertOperationAttributes(changes, "otherapp", 0, 0, name="Book")
5119 self.assertMigrationDependencies(
5120 changes, "otherapp", 0, [("migrations", "0002_second")]
5121 )
5122
5123 def test_alter_fk_before_model_deletion(self):
5124 """

Callers

nothing calls this directly

Calls 8

_detect_changesMethod · 0.95
MigrationLoaderClass · 0.90
make_project_stateMethod · 0.80
assertOperationTypesMethod · 0.80

Tested by

no test coverage detected