MCPcopy
hub / github.com/django/django / test_trim_apps

Method test_trim_apps

tests/migrations/test_autodetector.py:1222–1243  ·  view source on GitHub ↗

Trim does not remove dependencies but does remove unwanted apps.

(self)

Source from the content-addressed store, hash-verified

1220 )
1221
1222 def test_trim_apps(self):
1223 """
1224 Trim does not remove dependencies but does remove unwanted apps.
1225 """
1226 # Use project state to make a new migration change set
1227 before = self.make_project_state([])
1228 after = self.make_project_state(
1229 [self.author_empty, self.other_pony, self.other_stable, self.third_thing]
1230 )
1231 autodetector = MigrationAutodetector(
1232 before, after, MigrationQuestioner({"ask_initial": True})
1233 )
1234 changes = autodetector._detect_changes()
1235 # Run through arrange_for_graph
1236 graph = MigrationGraph()
1237 changes = autodetector.arrange_for_graph(changes, graph)
1238 changes["testapp"][0].dependencies.append(("otherapp", "0001_initial"))
1239 changes = autodetector._trim_to_apps(changes, {"testapp"})
1240 # Make sure there's the right set of migrations
1241 self.assertEqual(changes["testapp"][0].name, "0001_initial")
1242 self.assertEqual(changes["otherapp"][0].name, "0001_initial")
1243 self.assertNotIn("thirdapp", changes)
1244
1245 def test_custom_migration_name(self):
1246 """Tests custom naming of migrations for graph matching."""

Callers

nothing calls this directly

Calls 8

_detect_changesMethod · 0.95
arrange_for_graphMethod · 0.95
_trim_to_appsMethod · 0.95
MigrationQuestionerClass · 0.90
MigrationGraphClass · 0.90
make_project_stateMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected