MCPcopy
hub / github.com/django/django / _test_create_model

Method _test_create_model

tests/migrations/test_multidb.py:47–70  ·  view source on GitHub ↗

CreateModel honors multi-db settings.

(self, app_label, should_run)

Source from the content-addressed store, hash-verified

45 databases = {"default", "other"}
46
47 def _test_create_model(self, app_label, should_run):
48 """
49 CreateModel honors multi-db settings.
50 """
51 operation = migrations.CreateModel(
52 "Pony",
53 [("id", models.AutoField(primary_key=True))],
54 )
55 # Test the state alteration
56 project_state = ProjectState()
57 new_state = project_state.clone()
58 operation.state_forwards(app_label, new_state)
59 # Test the database alteration
60 self.assertTableNotExists("%s_pony" % app_label)
61 with connection.schema_editor() as editor:
62 operation.database_forwards(app_label, editor, project_state, new_state)
63 if should_run:
64 self.assertTableExists("%s_pony" % app_label)
65 else:
66 self.assertTableNotExists("%s_pony" % app_label)
67 # And test reversal
68 with connection.schema_editor() as editor:
69 operation.database_backwards(app_label, editor, new_state, project_state)
70 self.assertTableNotExists("%s_pony" % app_label)
71
72 @override_settings(DATABASE_ROUTERS=[AgnosticRouter()])
73 def test_create_model(self):

Callers 4

test_create_modelMethod · 0.95
test_create_model2Method · 0.95
test_create_model3Method · 0.95
test_create_model4Method · 0.95

Calls 8

cloneMethod · 0.95
state_forwardsMethod · 0.95
database_forwardsMethod · 0.95
database_backwardsMethod · 0.95
ProjectStateClass · 0.90
schema_editorMethod · 0.80
assertTableNotExistsMethod · 0.45
assertTableExistsMethod · 0.45

Tested by

no test coverage detected