MCPcopy
hub / github.com/django/django / _test_composed_index_with_fk

Method _test_composed_index_with_fk

tests/schema/tests.py:3417–3430  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

3415 editor.alter_unique_together(Book, [["author", "title"]], [])
3416
3417 def _test_composed_index_with_fk(self, index):
3418 with connection.schema_editor() as editor:
3419 editor.create_model(Author)
3420 editor.create_model(Book)
3421 table = Book._meta.db_table
3422 self.assertEqual(Book._meta.indexes, [])
3423 Book._meta.indexes = [index]
3424 with connection.schema_editor() as editor:
3425 editor.add_index(Book, index)
3426 self.assertIn(index.name, self.get_constraints(table))
3427 Book._meta.indexes = []
3428 with connection.schema_editor() as editor:
3429 editor.remove_index(Book, index)
3430 self.assertNotIn(index.name, self.get_constraints(table))
3431
3432 def test_composed_index_with_fk(self):
3433 index = Index(fields=["author", "title"], name="book_author_title_idx")

Calls 5

get_constraintsMethod · 0.95
schema_editorMethod · 0.80
create_modelMethod · 0.45
add_indexMethod · 0.45
remove_indexMethod · 0.45

Tested by

no test coverage detected