summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-07-18 14:50:08 +0200
committerClaude Paroz <claude@2xlibre.net>2015-07-20 20:22:29 +0200
commit1da170a203819ffda7764e53e3c268b8fc2ab452 (patch)
tree0d859a9c1ff4e7ffdee6f3bc09e536ff93e58c0b /tests
parent774c16d16ed67d7cf12bc2b2752768b544bdb363 (diff)
Fixed #25141 -- Diminished GDAL dependence during geojson serialization
Only require GDAL if contained geometries need coordinate transformations. Thanks drepo for the report and Tim Graham for the review.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geoapp/test_serializers.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/gis_tests/geoapp/test_serializers.py b/tests/gis_tests/geoapp/test_serializers.py
index 09f837417b..1bf3ec0acf 100644
--- a/tests/gis_tests/geoapp/test_serializers.py
+++ b/tests/gis_tests/geoapp/test_serializers.py
@@ -4,7 +4,8 @@ import json
from django.contrib.gis.geos import LinearRing, Point, Polygon
from django.core import serializers
-from django.test import TestCase, skipUnlessDBFeature
+from django.test import TestCase, mock, skipUnlessDBFeature
+from django.utils import six
from .models import City, MultiFields, PennsylvaniaCity
@@ -70,6 +71,14 @@ class GeoJSONSerializerTests(TestCase):
[int(c) for c in geodata['features'][0]['geometry']['coordinates']],
[1564802, 5613214])
+ @mock.patch('django.contrib.gis.serializers.geojson.HAS_GDAL', False)
+ def test_without_gdal(self):
+ # Without coordinate transformation, the serialization should succeed:
+ serializers.serialize('geojson', City.objects.all())
+ with six.assertRaisesRegex(self, serializers.base.SerializationError, '.*GDAL is not installed'):
+ # Coordinate transformations need GDAL
+ serializers.serialize('geojson', City.objects.all(), srid=2847)
+
def test_deserialization_exception(self):
"""
GeoJSON cannot be deserialized.