summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-02-15 13:33:55 -0500
committerTim Graham <timograham@gmail.com>2017-02-15 20:15:02 -0500
commitb008f7cc5655d01817a8825e6317877b43c92181 (patch)
tree4e70b2dbab77c2dee5e6fdc43c87535c52126740 /tests
parenta7214f0e84913a27e0b73de89d4c827ef1c53b94 (diff)
downloaddjango-b008f7cc5655d01817a8825e6317877b43c92181.tar.gz
Fixed #27135 -- Made index introspection return Index.suffix.
Diffstat (limited to 'tests')
-rw-r--r--tests/introspection/tests.py3
-rw-r--r--tests/model_indexes/tests.py7
-rw-r--r--tests/postgres_tests/test_indexes.py10
3 files changed, 15 insertions, 5 deletions
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index 2993592e4f..4d96bf8514 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -1,6 +1,7 @@
from unittest import mock, skipUnless
from django.db import connection
+from django.db.models import Index
from django.db.utils import DatabaseError
from django.test import TransactionTestCase, skipUnlessDBFeature
from django.test.utils import ignore_warnings
@@ -191,7 +192,7 @@ class IntrospectionTests(TransactionTestCase):
for key, val in constraints.items():
if val['columns'] == ['headline', 'pub_date']:
index = val
- self.assertEqual(index['type'], 'btree')
+ self.assertEqual(index['type'], Index.suffix)
@skipUnlessDBFeature('supports_index_column_ordering')
def test_get_constraints_indexes_orders(self):
diff --git a/tests/model_indexes/tests.py b/tests/model_indexes/tests.py
index 0e276dbd15..33e4bfaa7c 100644
--- a/tests/model_indexes/tests.py
+++ b/tests/model_indexes/tests.py
@@ -1,10 +1,13 @@
from django.db import models
-from django.test import TestCase
+from django.test import SimpleTestCase
from .models import Book
-class IndexesTests(TestCase):
+class IndexesTests(SimpleTestCase):
+
+ def test_suffix(self):
+ self.assertEqual(models.Index.suffix, 'idx')
def test_repr(self):
index = models.Index(fields=['title'])
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index 9298b86e73..db61561200 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -9,6 +9,9 @@ from .models import CharFieldModel, IntegerArrayModel
@skipUnlessDBFeature('has_brin_index_support')
class BrinIndexTests(PostgreSQLTestCase):
+ def test_suffix(self):
+ self.assertEqual(BrinIndex.suffix, 'brin')
+
def test_repr(self):
index = BrinIndex(fields=['title'], pages_per_range=4)
another_index = BrinIndex(fields=['title'])
@@ -41,6 +44,9 @@ class BrinIndexTests(PostgreSQLTestCase):
class GinIndexTests(PostgreSQLTestCase):
+ def test_suffix(self):
+ self.assertEqual(GinIndex.suffix, 'gin')
+
def test_repr(self):
index = GinIndex(fields=['title'])
self.assertEqual(repr(index), "<GinIndex: fields='title'>")
@@ -84,7 +90,7 @@ class SchemaTests(PostgreSQLTestCase):
editor.add_index(IntegerArrayModel, index)
constraints = self.get_constraints(IntegerArrayModel._meta.db_table)
# Check gin index was added
- self.assertEqual(constraints[index_name]['type'], 'gin')
+ self.assertEqual(constraints[index_name]['type'], GinIndex.suffix)
# Drop the index
with connection.schema_editor() as editor:
editor.remove_index(IntegerArrayModel, index)
@@ -97,7 +103,7 @@ class SchemaTests(PostgreSQLTestCase):
with connection.schema_editor() as editor:
editor.add_index(CharFieldModel, index)
constraints = self.get_constraints(CharFieldModel._meta.db_table)
- self.assertEqual(constraints[index_name]['type'], 'brin')
+ self.assertEqual(constraints[index_name]['type'], BrinIndex.suffix)
self.assertEqual(constraints[index_name]['options'], ['pages_per_range=4'])
with connection.schema_editor() as editor:
editor.remove_index(CharFieldModel, index)