[1.6.x] Fixed gis test to run on non gis-enabled settings
Refs #20998.
Backport of 973502c0
from master.
This commit is contained in:
parent
4e3794dd1f
commit
0c57868908
|
@ -245,6 +245,8 @@ class SpecializedFieldTest(SimpleTestCase):
|
||||||
@skipUnless(HAS_GDAL and HAS_SPATIALREFSYS,
|
@skipUnless(HAS_GDAL and HAS_SPATIALREFSYS,
|
||||||
"CustomGeometryWidgetTest needs gdal support and a spatial database")
|
"CustomGeometryWidgetTest needs gdal support and a spatial database")
|
||||||
class CustomGeometryWidgetTest(SimpleTestCase):
|
class CustomGeometryWidgetTest(SimpleTestCase):
|
||||||
|
|
||||||
|
def test_custom_serialization_widget(self):
|
||||||
class CustomGeometryWidget(forms.BaseGeometryWidget):
|
class CustomGeometryWidget(forms.BaseGeometryWidget):
|
||||||
template_name = 'gis/openlayers.html'
|
template_name = 'gis/openlayers.html'
|
||||||
deserialize_called = 0
|
deserialize_called = 0
|
||||||
|
@ -255,15 +257,14 @@ class CustomGeometryWidgetTest(SimpleTestCase):
|
||||||
self.deserialize_called += 1
|
self.deserialize_called += 1
|
||||||
return GEOSGeometry(value)
|
return GEOSGeometry(value)
|
||||||
|
|
||||||
def test_custom_serialization_widget(self):
|
|
||||||
class PointForm(forms.Form):
|
class PointForm(forms.Form):
|
||||||
p = forms.PointField(widget=self.CustomGeometryWidget)
|
p = forms.PointField(widget=CustomGeometryWidget)
|
||||||
|
|
||||||
point = GEOSGeometry("SRID=4326;POINT(9.052734375 42.451171875)")
|
point = GEOSGeometry("SRID=4326;POINT(9.052734375 42.451171875)")
|
||||||
form = PointForm(data={'p': point})
|
form = PointForm(data={'p': point})
|
||||||
self.assertIn(escape(point.json), form.as_p())
|
self.assertIn(escape(point.json), form.as_p())
|
||||||
|
|
||||||
self.CustomGeometryWidget.called = 0
|
CustomGeometryWidget.called = 0
|
||||||
widget = form.fields['p'].widget
|
widget = form.fields['p'].widget
|
||||||
# Force deserialize use due to a string value
|
# Force deserialize use due to a string value
|
||||||
self.assertIn(escape(point.json), widget.render('p', point.json))
|
self.assertIn(escape(point.json), widget.render('p', point.json))
|
||||||
|
|
Loading…
Reference in New Issue