summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_indexes.py
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2018-01-05 11:53:08 +0000
committerTim Graham <timograham@gmail.com>2018-08-02 11:26:58 -0400
commitd6381d3559b469ce25f4906151b9329c1f946f14 (patch)
tree0b9be8304933cc918bc8f9d0f3cfa7bbed68bd46 /tests/postgres_tests/test_indexes.py
parent4c36e9e492b5c127d839ebf280fdf5556af8e824 (diff)
Fixed #28990 -- Added autosummarize parameter to BrinIndex.
Diffstat (limited to 'tests/postgres_tests/test_indexes.py')
-rw-r--r--tests/postgres_tests/test_indexes.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index b07716e40d..9bca4510fe 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -31,11 +31,16 @@ class BrinIndexTests(IndexTestMixin, PostgreSQLTestCase):
self.assertEqual(BrinIndex.suffix, 'brin')
def test_deconstruction(self):
- index = BrinIndex(fields=['title'], name='test_title_brin', pages_per_range=16)
+ index = BrinIndex(fields=['title'], name='test_title_brin', autosummarize=True, pages_per_range=16)
path, args, kwargs = index.deconstruct()
self.assertEqual(path, 'django.contrib.postgres.indexes.BrinIndex')
self.assertEqual(args, ())
- self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_brin', 'pages_per_range': 16})
+ self.assertEqual(kwargs, {
+ 'fields': ['title'],
+ 'name': 'test_title_brin',
+ 'autosummarize': True,
+ 'pages_per_range': 16,
+ })
def test_invalid_pages_per_range(self):
with self.assertRaisesMessage(ValueError, 'pages_per_range must be None or a positive integer'):
@@ -176,6 +181,19 @@ class SchemaTests(PostgreSQLTestCase):
editor.remove_index(CharFieldModel, index)
self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table))
+ @skipUnlessDBFeature('has_brin_index_support', 'has_brin_autosummarize')
+ def test_brin_parameters(self):
+ index_name = 'char_field_brin_params'
+ index = BrinIndex(fields=['field'], name=index_name, autosummarize=True)
+ 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'], BrinIndex.suffix)
+ self.assertEqual(constraints[index_name]['options'], ['autosummarize=on'])
+ with connection.schema_editor() as editor:
+ editor.remove_index(CharFieldModel, index)
+ self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table))
+
def test_gist_index(self):
# Ensure the table is there and doesn't have an index.
self.assertNotIn('field', self.get_constraints(CharFieldModel._meta.db_table))