MCPcopy
hub / github.com/django/django / test_create_proxy_model

Method test_create_proxy_model

tests/migrations/test_operations.py:373–407  ·  view source on GitHub ↗

CreateModel ignores proxy models.

(self)

Source from the content-addressed store, hash-verified

371 self.assertTableNotExists("test_crmoih_shetlandpony")
372
373 def test_create_proxy_model(self):
374 """
375 CreateModel ignores proxy models.
376 """
377 project_state = self.set_up_test_model("test_crprmo")
378 # Test the state alteration
379 operation = migrations.CreateModel(
380 "ProxyPony",
381 [],
382 options={"proxy": True},
383 bases=("test_crprmo.Pony",),
384 )
385 self.assertEqual(operation.describe(), "Create proxy model ProxyPony")
386 new_state = project_state.clone()
387 operation.state_forwards("test_crprmo", new_state)
388 self.assertIn(("test_crprmo", "proxypony"), new_state.models)
389 # Test the database alteration
390 self.assertTableNotExists("test_crprmo_proxypony")
391 self.assertTableExists("test_crprmo_pony")
392 with connection.schema_editor() as editor:
393 operation.database_forwards("test_crprmo", editor, project_state, new_state)
394 self.assertTableNotExists("test_crprmo_proxypony")
395 self.assertTableExists("test_crprmo_pony")
396 # And test reversal
397 with connection.schema_editor() as editor:
398 operation.database_backwards(
399 "test_crprmo", editor, new_state, project_state
400 )
401 self.assertTableNotExists("test_crprmo_proxypony")
402 self.assertTableExists("test_crprmo_pony")
403 # And deconstruction
404 definition = operation.deconstruct()
405 self.assertEqual(definition[0], "CreateModel")
406 self.assertEqual(definition[1], [])
407 self.assertEqual(sorted(definition[2]), ["bases", "fields", "name", "options"])
408
409 def test_create_unmanaged_model(self):
410 """

Callers

nothing calls this directly

Calls 10

describeMethod · 0.95
state_forwardsMethod · 0.95
database_forwardsMethod · 0.95
database_backwardsMethod · 0.95
deconstructMethod · 0.95
schema_editorMethod · 0.80
set_up_test_modelMethod · 0.45
cloneMethod · 0.45
assertTableNotExistsMethod · 0.45
assertTableExistsMethod · 0.45

Tested by

no test coverage detected