Skip to content

Commit

Permalink
Use "GeoJSON" as type name, not "JSON"
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Feb 2, 2013
1 parent ee3156c commit d476acc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions leaflet_storage/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ class Meta:

class UploadDataForm(forms.Form):

JSON = "json"
GEOJSON = "geojson"
KML = "kml"
GPX = "gpx"
CONTENT_TYPES = (
(JSON, "JSON"),
(GEOJSON, "GeoJSON"),
(KML, "KML"),
(GPX, "GPX"),
)
Expand Down Expand Up @@ -174,7 +174,7 @@ def content_to_features(self, content):
features = []
content_type = self.cleaned_data.get('content_type')
MAP = {
self.JSON: geojson.GeoJSON,
self.GEOJSON: geojson.GeoJSON,
self.KML: kml.KML,
self.GPX: gpx.GPX
}
Expand Down
12 changes: 6 additions & 6 deletions leaflet_storage/tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def process_file(self, filename, content_type):

def test_GeoJSON_generic(self):
# Contains tow Point, two Polygons and one Polyline
response = self.process_file("test_upload_data.json", "json")
response = self.process_file("test_upload_data.json", "geojson")
self.client.login(username=self.user.username, password="123123")
self.assertEqual(response.status_code, 200)
self.assertEqual(Marker.objects.filter(category=self.category).count(), 2)
Expand All @@ -331,21 +331,21 @@ def test_GeoJSON_empty_coordinates_should_not_be_imported(self):
self.assertEqual(Marker.objects.filter(category=self.category).count(), 0)
self.assertEqual(Polyline.objects.filter(category=self.category).count(), 0)
self.assertEqual(Polygon.objects.filter(category=self.category).count(), 0)
response = self.process_file("test_upload_empty_coordinates.json", "json")
response = self.process_file("test_upload_empty_coordinates.json", "geojson")
self.assertEqual(response.status_code, 200)
self.assertEqual(Marker.objects.filter(category=self.category).count(), 0)
self.assertEqual(Polyline.objects.filter(category=self.category).count(), 0)
self.assertEqual(Polygon.objects.filter(category=self.category).count(), 0)

def test_GeoJSON_non_linear_ring_should_not_be_imported(self):
response = self.process_file("test_upload_non_linear_ring.json", "json")
response = self.process_file("test_upload_non_linear_ring.json", "geojson")
self.assertEqual(response.status_code, 200)
self.assertEqual(Polygon.objects.filter(category=self.category).count(), 0)

def test_GeoJSON_missing_name_should_be_set_with_category_name(self):
# One feature is missing a name
self.assertEqual(Marker.objects.filter(category=self.category).count(), 0)
response = self.process_file("test_upload_missing_name.json", "json")
response = self.process_file("test_upload_missing_name.json", "geojson")
self.assertEqual(response.status_code, 200)
self.assertEqual(Marker.objects.filter(category=self.category).count(), 2)
self.assertEqual(Marker.objects.filter(category=self.category, name=self.category.name).count(), 1)
Expand All @@ -363,11 +363,11 @@ def test_import_data_from_url(self):
post_data = {
'category': self.category.pk,
'data_file': "file://%s" % fixture_path,
'content_type': 'json'
'content_type': 'geojson'
}
self.client.login(username=self.user.username, password="123123")
response = self.client.post(url, post_data)
response = self.process_file("test_upload_data.json", "json")
response = self.process_file("test_upload_data.json", "geojson")
self.client.login(username=self.user.username, password="123123")
self.assertEqual(response.status_code, 200)
self.assertEqual(Marker.objects.filter(category=self.category).count(), 2)
Expand Down

0 comments on commit d476acc

Please sign in to comment.