From 1da170a203819ffda7764e53e3c268b8fc2ab452 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 18 Jul 2015 14:50:08 +0200 Subject: 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. --- tests/gis_tests/geoapp/test_serializers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') 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. -- cgit v1.3