summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkshesh <aksheshdoshi@gmail.com>2016-08-25 12:42:17 +0530
committerTim Graham <timograham@gmail.com>2016-09-02 21:14:12 -0400
commitdbccf163b6e45bf2a673c249d4667360676acddc (patch)
tree55f45364d66e03cee18d76ab84669988c7a2b34d /tests
parent082f5bfdbcc9b18d064dd6c72a910188c459d617 (diff)
Fixed #27097 -- Added index type introspection to built-in db backends.
Diffstat (limited to 'tests')
-rw-r--r--tests/introspection/tests.py7
-rw-r--r--tests/postgres_tests/test_indexes.py9
2 files changed, 9 insertions, 7 deletions
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index 766e51dea7..68d621d762 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -184,13 +184,14 @@ class IntrospectionTests(TransactionTestCase):
self.assertNotIn('first_name', indexes)
self.assertIn('id', indexes)
- @skipUnlessDBFeature('can_introspect_index_type')
def test_get_constraints_index_types(self):
with connection.cursor() as cursor:
constraints = connection.introspection.get_constraints(cursor, Article._meta.db_table)
+ index = {}
for key, val in constraints.items():
- if val['index'] and not (val['primary_key'] or val['unique']):
- self.assertEqual(val['type'], 'btree')
+ if val['columns'] == ['headline', 'pub_date']:
+ index = val
+ self.assertEqual(index['type'], 'btree')
@skipUnlessDBFeature('supports_index_column_ordering')
def test_get_constraints_indexes_orders(self):
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index 8c15f01d47..235d72c532 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -44,13 +44,14 @@ class SchemaTests(PostgreSQLTestCase):
# Ensure the table is there and doesn't have an index.
self.assertNotIn('field', self.get_constraints(IntegerArrayModel._meta.db_table))
# Add the index
- index = GinIndex(fields=['field'], name='integer_array_model_field_gin')
+ index_name = 'integer_array_model_field_gin'
+ index = GinIndex(fields=['field'], name=index_name)
with connection.schema_editor() as editor:
editor.add_index(IntegerArrayModel, index)
- self.assertIn('integer_array_model_field_gin', self.get_constraints(IntegerArrayModel._meta.db_table))
constraints = self.get_constraints(IntegerArrayModel._meta.db_table)
- self.assertEqual(constraints['integer_array_model_field_gin']['type'], 'gin')
+ # Check gin index was added
+ self.assertEqual(constraints[index_name]['type'], 'gin')
# Drop the index
with connection.schema_editor() as editor:
editor.remove_index(IntegerArrayModel, index)
- self.assertNotIn('integer_array_model_field_gin', self.get_constraints(IntegerArrayModel._meta.db_table))
+ self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table))