summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Wiesmann <daniel.wiesmann@gmail.com>2016-08-15 18:21:12 +0100
committerTim Graham <timograham@gmail.com>2016-09-02 20:26:16 -0400
commit082f5bfdbcc9b18d064dd6c72a910188c459d617 (patch)
treea4fb6fe9f52b327a904c717dfcac0e3b168355de /tests
parentd6b9aab37c41a772e5519e46b42b39958f99cadd (diff)
Added error messages for GIS DB functions when used with rasters.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/rasterapp/test_rasterfield.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/gis_tests/rasterapp/test_rasterfield.py b/tests/gis_tests/rasterapp/test_rasterfield.py
index f838f56bdc..5934fcc690 100644
--- a/tests/gis_tests/rasterapp/test_rasterfield.py
+++ b/tests/gis_tests/rasterapp/test_rasterfield.py
@@ -1,5 +1,6 @@
import json
+from django.contrib.gis.db.models.functions import Distance
from django.contrib.gis.db.models.lookups import (
DistanceLookupBase, gis_lookups,
)
@@ -326,3 +327,18 @@ class RasterFieldTest(TransactionTestCase):
msg = "Couldn't create spatial object from lookup value '%s'." % obj
with self.assertRaisesMessage(ValueError, msg):
RasterModel.objects.filter(geom__intersects=obj)
+
+ def test_db_function_errors(self):
+ """
+ Errors are raised when using DB functions with raster content.
+ """
+ point = GEOSGeometry("SRID=3086;POINT (-697024.9213808845 683729.1705516104)")
+ rast = GDALRaster(json.loads(JSON_RASTER))
+ msg = "Please provide a geometry object."
+ with self.assertRaisesMessage(TypeError, msg):
+ RasterModel.objects.annotate(distance_from_point=Distance("geom", rast))
+ with self.assertRaisesMessage(TypeError, msg):
+ RasterModel.objects.annotate(distance_from_point=Distance("rastprojected", rast))
+ msg = "Geometry functions not supported for raster fields."
+ with self.assertRaisesMessage(TypeError, msg):
+ RasterModel.objects.annotate(distance_from_point=Distance("rastprojected", point)).count()