Skip to content

Commit

Permalink
Merge pull request #56 from sikmir/master
Browse files Browse the repository at this point in the history
Add python 3.2 compatibility (fixes #55)
  • Loading branch information
leplatrem committed Apr 15, 2015
2 parents 436867f + 47870d8 commit a0aa2f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
6 changes: 4 additions & 2 deletions djgeojson/fields.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.forms.widgets import HiddenInput
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import (ValidationError,
Expand Down Expand Up @@ -34,10 +36,10 @@ def __call__(self, value):
"Polygon", "MultiPolygon", "GeometryCollection"
)
if not is_geometry:
err_msg = u'%s is not a valid GeoJSON geometry type' % geom_type
err_msg = '%s is not a valid GeoJSON geometry type' % geom_type
else:
if self.geom_type.lower() != geom_type.lower():
err_msg = u'%s does not match geometry type' % geom_type
err_msg = '%s does not match geometry type' % geom_type

if err_msg:
raise ValidationError(err_msg)
Expand Down
34 changes: 18 additions & 16 deletions djgeojson/tests.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

import json

from django.test import TestCase
Expand Down Expand Up @@ -483,9 +485,9 @@ def test_view_default_options(self):
[[0.0, 0.0], [1.0, 1.0]])

def test_view_can_control_properties(self):
klass = type('FullGeoJSON', (GeoJSONLayerView,),
{'properties': ['name']})
view = klass(model=Route)
class FullGeoJSON(GeoJSONLayerView):
properties = ['name']
view = FullGeoJSON(model=Route)
view.object_list = []
response = view.render_to_response(context={})
geojson = json.loads(smart_text(response.content))
Expand Down Expand Up @@ -618,13 +620,13 @@ def test_field_can_be_serialized(self):
features = json.loads(geojson)
self.assertEqual(
features, {
u'type': u'FeatureCollection',
u'features': [{
u'id': self.address.id,
u'type': u'Feature',
u'geometry': {u'type': u'Point', u'coordinates': [0, 0]},
u'properties': {
u'model': u'djgeojson.address'
'type': u'FeatureCollection',
'features': [{
'id': self.address.id,
'type': 'Feature',
'geometry': {'type': 'Point', 'coordinates': [0, 0]},
'properties': {
'model': 'djgeojson.address'
}
}]
})
Expand Down Expand Up @@ -660,12 +662,12 @@ def test_model_can_be_omitted(self):
"type": "proj4"
}
},
u'type': u'FeatureCollection',
u'features': [{
u'id': self.address.id,
u'type': u'Feature',
u'geometry': {u'type': u'Point', u'coordinates': [0, 0]},
u'properties': {}
'type': 'FeatureCollection',
'features': [{
'id': self.address.id,
'type': 'Feature',
'geometry': {'type': 'Point', 'coordinates': [0, 0]},
'properties': {}
}]
})

Expand Down

0 comments on commit a0aa2f3

Please sign in to comment.