summaryrefslogtreecommitdiff
path: root/tests/introspection
diff options
context:
space:
mode:
authorAkshesh <aksheshdoshi@gmail.com>2016-07-26 06:34:28 +0530
committerTim Graham <timograham@gmail.com>2016-08-12 11:51:09 -0400
commitf842d1011c1195aa26071a6ab6f96e0b8d907343 (patch)
tree18431668220d89053fe169f736f872f7fedd57ca /tests/introspection
parent5eab1f6f8348497e87c19112786efb970e41f36e (diff)
downloaddjango-f842d1011c1195aa26071a6ab6f96e0b8d907343.tar.gz
Refs #20888 -- Added index order introspection.
Diffstat (limited to 'tests/introspection')
-rw-r--r--tests/introspection/tests.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index d36269d8cf..31b0214704 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -182,6 +182,26 @@ class IntrospectionTests(TransactionTestCase):
self.assertNotIn('first_name', indexes)
self.assertIn('id', indexes)
+ @skipUnlessDBFeature('supports_index_column_ordering')
+ def test_get_constraints_indexes_orders(self):
+ """
+ Indexes have the 'orders' key with a list of 'ASC'/'DESC' values.
+ """
+ with connection.cursor() as cursor:
+ constraints = connection.introspection.get_constraints(cursor, Article._meta.db_table)
+ indexes_verified = 0
+ expected_columns = [
+ ['reporter_id'],
+ ['headline', 'pub_date'],
+ ['response_to_id'],
+ ]
+ for key, val in constraints.items():
+ if val['index'] and not (val['primary_key'] or val['unique']):
+ self.assertIn(val['columns'], expected_columns)
+ self.assertEqual(val['orders'], ['ASC'] * len(val['columns']))
+ indexes_verified += 1
+ self.assertEqual(indexes_verified, 3)
+
def datatype(dbtype, description):
"""Helper to convert a data type into a string."""