summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIuri de Silvio <iurisilvio@gmail.com>2020-08-07 09:57:42 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-08 20:43:40 +0200
commit366a93f17498940b823d7d67a8bee51a776a16ee (patch)
tree5da2916b3df19ec949aca368e7c6d4c7ef9e6f8c /tests
parentb2b0711b555fa292751763c2df4fe577c396f265 (diff)
Refs #31831 -- Added autodector test for unique/index_together on _order field.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_autodetector.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index 236af43834..0c30cd0489 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -2151,6 +2151,34 @@ class AutodetectorTests(TestCase):
)
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):
"""
Changing the model managers adds a new operation.