Refs #31831 -- Added autodector test for unique/index_together on _order field.

This commit is contained in:
Iuri de Silvio 2020-08-07 09:57:42 +02:00 committed by Mariusz Felisiak
parent b2b0711b55
commit 366a93f174
1 changed files with 28 additions and 0 deletions

View File

@ -2151,6 +2151,34 @@ class AutodetectorTests(TestCase):
) )
self.assertNotIn("_order", [name for name, field in changes['testapp'][0].operations[0].fields]) self.assertNotIn("_order", [name for name, field in changes['testapp'][0].operations[0].fields])
def test_add_model_order_with_respect_to_index_foo_together(self):
changes = self.get_changes([], [
self.book,
ModelState('testapp', 'Author', [
('id', models.AutoField(primary_key=True)),
('name', models.CharField(max_length=200)),
('book', models.ForeignKey('otherapp.Book', models.CASCADE)),
], options={
'order_with_respect_to': 'book',
'index_together': {('name', '_order')},
'unique_together': {('id', '_order')},
}),
])
self.assertNumberMigrations(changes, 'testapp', 1)
self.assertOperationTypes(changes, 'testapp', 0, ['CreateModel'])
self.assertOperationAttributes(
changes,
'testapp',
0,
0,
name='Author',
options={
'order_with_respect_to': 'book',
'index_together': {('name', '_order')},
'unique_together': {('id', '_order')},
},
)
def test_alter_model_managers(self): def test_alter_model_managers(self):
""" """
Changing the model managers adds a new operation. Changing the model managers adds a new operation.