mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #26709 -- Replaced Index.get_name() with set_name_with_model().
This removes the dependency of the Index class on its 'model' attribute.
This commit is contained in:
@@ -40,19 +40,19 @@ class IndexesTests(TestCase):
|
||||
|
||||
def test_name_auto_generation(self):
|
||||
index = models.Index(fields=['author'])
|
||||
index.model = Book
|
||||
index.set_name_with_model(Book)
|
||||
self.assertEqual(index.name, 'model_index_author_0f5565_idx')
|
||||
|
||||
# fields may be truncated in the name. db_column is used for naming.
|
||||
long_field_index = models.Index(fields=['pages'])
|
||||
long_field_index.model = Book
|
||||
long_field_index.set_name_with_model(Book)
|
||||
self.assertEqual(long_field_index.name, 'model_index_page_co_69235a_idx')
|
||||
|
||||
# suffix can't be longer than 3 characters.
|
||||
long_field_index.suffix = 'suff'
|
||||
msg = 'Index too long for multiple database support. Is self.suffix longer than 3 characters?'
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
long_field_index.get_name()
|
||||
long_field_index.set_name_with_model(Book)
|
||||
|
||||
def test_deconstruction(self):
|
||||
index = models.Index(fields=['title'])
|
||||
|
||||
Reference in New Issue
Block a user