summaryrefslogtreecommitdiff
path: root/tests/gis_tests/gis_migrations/test_operations.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-08-31 21:05:39 +0200
committerClaude Paroz <claude@2xlibre.net>2016-09-12 09:26:33 +0200
commita1ad896422437b376462361560086609538779fc (patch)
tree8adc57c4dffd30aff83d2143c7158b2388b1266b /tests/gis_tests/gis_migrations/test_operations.py
parent0c6fbea59ba592586140115bd654c7f6c0983f56 (diff)
downloaddjango-a1ad896422437b376462361560086609538779fc.tar.gz
Refs #27098 -- Added introspection for expression-based index on PostgreSQL
Also test it on PostGIS raster fields.
Diffstat (limited to 'tests/gis_tests/gis_migrations/test_operations.py')
-rw-r--r--tests/gis_tests/gis_migrations/test_operations.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/gis_tests/gis_migrations/test_operations.py b/tests/gis_tests/gis_migrations/test_operations.py
index 84735d8fbd..ff1a621c6c 100644
--- a/tests/gis_tests/gis_migrations/test_operations.py
+++ b/tests/gis_tests/gis_migrations/test_operations.py
@@ -67,10 +67,17 @@ class OperationTests(TransactionTestCase):
expected_count
)
- def assertSpatialIndexExists(self, table, column):
+ def assertSpatialIndexExists(self, table, column, raster=False):
with connection.cursor() as cursor:
constraints = connection.introspection.get_constraints(cursor, table)
- self.assertIn([column], [c['columns'] for c in constraints.values()])
+ if raster:
+ self.assertTrue(any(
+ 'st_convexhull(%s)' % column in c['definition']
+ for c in constraints.values()
+ if c['definition'] is not None
+ ))
+ else:
+ self.assertIn([column], [c['columns'] for c in constraints.values()])
def alter_gis_model(self, migration_class, model_name, field_name,
blank=False, field_class=None):
@@ -111,7 +118,7 @@ class OperationTests(TransactionTestCase):
# Test spatial indices when available
if self.has_spatial_indexes:
- self.assertSpatialIndexExists('gis_neighborhood', 'heatmap')
+ self.assertSpatialIndexExists('gis_neighborhood', 'heatmap', raster=True)
@skipIfDBFeature('supports_raster')
def test_create_raster_model_on_db_without_raster_support(self):
@@ -159,7 +166,7 @@ class OperationTests(TransactionTestCase):
# Test spatial indices when available
if self.has_spatial_indexes:
- self.assertSpatialIndexExists('gis_neighborhood', 'heatmap')
+ self.assertSpatialIndexExists('gis_neighborhood', 'heatmap', raster=True)
def test_remove_geom_field(self):
"""
@@ -189,7 +196,7 @@ class OperationTests(TransactionTestCase):
self.assertSpatialIndexExists('gis_neighborhood', 'geom')
if connection.features.supports_raster:
- self.assertSpatialIndexExists('gis_neighborhood', 'rast')
+ self.assertSpatialIndexExists('gis_neighborhood', 'rast', raster=True)
@property
def has_spatial_indexes(self):