Commits

Yohan Boniface  committed 98fffcf

Update tests (cf yohanboniface/Leaflet.Storage#62)

  • Participants
  • Parent commits c6316ee

Comments (0)

Files changed (4)

File leaflet_storage/tests/base.py

 from leaflet_storage.forms import DEFAULT_CENTER
 
 
-class LicenceFactory(factory.Factory):
+class LicenceFactory(factory.DjangoModelFactory):
     FACTORY_FOR = Licence
     name = "WTFPL"
 
 
-class TileLayerFactory(factory.Factory):
+class TileLayerFactory(factory.DjangoModelFactory):
     FACTORY_FOR = TileLayer
     name = "Test zoom layer"
     url_template = "http://{s}.test.org/{z}/{x}/{y}.png"
     attribution = "Test layer attribution"
 
 
-class UserFactory(factory.Factory):
+class UserFactory(factory.DjangoModelFactory):
     FACTORY_FOR = User
     username = 'Joe'
     email = factory.LazyAttribute(lambda a: '{0}@example.com'.format(a.username).lower())
         return user
 
 
-class MapFactory(factory.Factory):
+class MapFactory(factory.DjangoModelFactory):
     FACTORY_FOR = Map
     name = "test map"
     slug = "test-map"
     center = DEFAULT_CENTER
+    settings = {
+        'geometry': {
+            'coordinates': [13.447265624999998, 48.94415123418794],
+            'type': 'Point'
+        },
+        'properties': {
+            'datalayersControl': True,
+            'description': 'Which is just the Danube, at the end, I mean, JUST THE DANUBE',
+            'displayCaptionOnLoad': False,
+            'displayDataBrowserOnLoad': False,
+            'displayPopupFooter': False,
+            'licence': '',
+            'miniMap': False,
+            'moreControl': True,
+            'name': 'Cruising on the Donau',
+            'scaleControl': True,
+            'tilelayer': {
+                'attribution': u'\xa9 OSM Contributors - tiles OpenRiverboatMap',
+                'maxZoom': 18,
+                'minZoom': 0,
+                'url_template': 'http://{s}.layers.openstreetmap.fr/openriverboatmap/{z}/{x}/{y}.png'
+            },
+            'tilelayersControl': True,
+            'zoom': 7,
+            'zoomControl': True},
+            'type': 'Feature'
+        }
+
     licence = factory.SubFactory(LicenceFactory)
     owner = factory.SubFactory(UserFactory)
 
 
-class DataLayerFactory(factory.Factory):
+class DataLayerFactory(factory.DjangoModelFactory):
     FACTORY_FOR = DataLayer
     map = factory.SubFactory(MapFactory)
     name = "test datalayer"
     description = "test description"
     display_on_load = True
+    geojson = factory.django.FileField(data="""{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[13.68896484375,48.55297816440071]},"properties":{"_storage_options":{"color":"DarkCyan","iconClass":"Ball"},"name":"Here","description":"Da place anonymous again 755"}}],"_storage":{"displayOnLoad":true,"name":"Donau","id":926}}""")
 
 
-class BaseFeatureFactory(factory.Factory):
+class BaseFeatureFactory(factory.DjangoModelFactory):
     ABSTRACT_FACTORY = True
     name = "test feature"
     description = "test description"

File leaflet_storage/tests/base_models.py

         self.assertEqual(new_owner, clone.owner)
 
     def test_clone_should_clone_datalayers_and_features_too(self):
-        marker = MarkerFactory(datalayer=self.datalayer)
         clone = self.map.clone()
         self.assertNotEqual(self.map.pk, clone.pk)
         self.assertEqual(self.map.datalayer_set.count(), 1)
         self.assertIn(self.datalayer, self.map.datalayer_set.all())
         self.assertNotEqual(self.datalayer.pk, datalayer.pk)
         self.assertEqual(self.datalayer.name, datalayer.name)
-        self.assertEqual(len(datalayer.features), 1)
-        new_marker = datalayer.features[0]
-        self.assertNotEqual(marker.pk, new_marker.pk)
-        self.assertEqual(marker.name, new_marker.name)
-        self.assertEqual(marker.options, new_marker.options)
+        self.assertIsNotNone(datalayer.geojson)
+        self.assertNotEqual(datalayer.geojson.path, self.datalayer.geojson.path)
 
 
 class LicenceModel(BaseTest):
 
 class DataLayerModel(BaseTest):
 
-    def test_features_should_be_locally_cached(self):
-        MarkerFactory(datalayer=self.datalayer)
-        MarkerFactory(datalayer=self.datalayer)
-        MarkerFactory(datalayer=self.datalayer)
-        self.datalayer.features
-        with self.assertNumQueries(0):
-            self.datalayer.features
-
     def test_datalayers_should_be_ordered_by_name(self):
         c4 = DataLayerFactory(map=self.map, name="eeeeeee")
         c1 = DataLayerFactory(map=self.map, name="1111111")
             [c1, c2, c3, c4, self.datalayer]
         )
 
-    def test_features_should_be_mixed_and_ordered_by_name(self):
-        f4 = MarkerFactory(datalayer=self.datalayer, name="eeee")
-        f1 = PolygonFactory(datalayer=self.datalayer, name="1111")
-        f3 = PolylineFactory(datalayer=self.datalayer, name="cccc")
-        f2 = MarkerFactory(datalayer=self.datalayer, name="aaaa")
-        self.assertEqual(
-            list(self.datalayer.features),
-            [f1, f2, f3, f4]
-        )
-
     def test_clone_should_return_new_instance(self):
         clone = self.datalayer.clone()
         self.assertNotEqual(self.datalayer.pk, clone.pk)
         self.assertNotEqual(self.datalayer.map, clone.map)
         self.assertEqual(new_map, clone.map)
 
-    def test_clone_should_clone_features_too(self):
-        marker = MarkerFactory(datalayer=self.datalayer)
+    def test_clone_should_clone_geojson_too(self):
         clone = self.datalayer.clone()
         self.assertNotEqual(self.datalayer.pk, clone.pk)
-        self.assertEqual(len(clone.features), 1)
-        cloned_marker = clone.features[0]
-        self.assertNotEqual(marker.pk, cloned_marker.pk)
-        self.assertEqual(marker.name, cloned_marker.name)
-
-
-class MarkerModel(BaseTest):
-
-    def test_clone_should_return_new_instance(self):
-        original = MarkerFactory(datalayer=self.datalayer)
-        clone = original.clone()
-        self.assertNotEqual(original.pk, clone.pk)
-        self.assertEqual(original.name, clone.name)
-        self.assertEqual(original.datalayer, clone.datalayer)
-        self.assertEqual(original.latlng, clone.latlng)
-
-    def test_clone_should_update_datalayer_if_passed(self):
-        datalayer = DataLayerFactory(map=self.map)
-        original = MarkerFactory(datalayer=self.datalayer)
-        clone = original.clone(datalayer=datalayer)
-        self.assertNotEqual(original.pk, clone.pk)
-        self.assertNotEqual(original.datalayer, clone.datalayer)
-        self.assertEqual(datalayer, clone.datalayer)
-        self.assertEqual(original.name, clone.name)
-        self.assertEqual(original.latlng, clone.latlng)
+        self.assertIsNotNone(clone.geojson)
+        self.assertNotEqual(clone.geojson.path, self.datalayer.geojson.path)

File leaflet_storage/tests/views.py

+# -*- coding: utf-8 -*-
 import os
 
 from django.test import TransactionTestCase
 @override_settings(LEAFLET_STORAGE_ALLOW_ANONYMOUS=False)
 class MapViews(BaseTest):
 
-    def test_quick_create_GET(self):
-        url = reverse('map_add')
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("form", json['html'])
-
-    def test_quick_create_POST(self):
-        url = reverse('map_add')
+    def test_create(self):
+        url = reverse('map_create')
         # POST only mendatory fields
         name = 'test-map-with-new-name'
         post_data = {
             'name': name,
-            'licence': self.licence.pk
+            'center': '{"type":"Point","coordinates":[13.447265624999998,48.94415123418794]}',
+            'settings': '{"type":"Feature","geometry":{"type":"Point","coordinates":[5.0592041015625,52.05924589011585]},"properties":{"tilelayer":{"maxZoom":20,"url_template":"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png","minZoom":0,"attribution":"HOT and friends"},"licence":"","description":"","name":"test enrhûmé","tilelayersControl":true,"displayDataBrowserOnLoad":false,"displayPopupFooter":true,"displayCaptionOnLoad":false,"miniMap":true,"moreControl":true,"scaleControl":true,"zoomControl":true,"datalayersControl":true,"zoom":8}}'
         }
         self.client.login(username=self.user.username, password="123123")
         response = self.client.post(url, post_data)
         self.assertEqual(response.status_code, 200)
         json = simplejson.loads(response.content)
         created_map = Map.objects.latest('pk')
-        self.assertEqual(json['redirect'], created_map.get_absolute_url())
+        self.assertEqual(json['id'], created_map.pk)
         self.assertEqual(created_map.name, name)
-        # A datalayer must have been created automatically
-        self.assertEqual(DataLayer.objects.filter(map=created_map).count(), 1)
-        # Default tilelayer must have been linked to the map
-        self.assertEqual(created_map.tilelayer, self.tilelayer)
 
-    def test_quick_update_GET(self):
-        url = reverse('map_update', kwargs={'map_id': self.map.pk})
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn(self.map.name, json['html'])
-
-    def test_quick_update_POST(self):
+    def test_update(self):
         url = reverse('map_update', kwargs={'map_id': self.map.pk})
         # POST only mendatory fields
         new_name = 'new map name'
         post_data = {
             'name': new_name,
-            'licence': self.map.licence.pk
+            'center': '{"type":"Point","coordinates":[13.447265624999998,48.94415123418794]}',
+            'settings': '{"type":"Feature","geometry":{"type":"Point","coordinates":[5.0592041015625,52.05924589011585]},"properties":{"tilelayer":{"maxZoom":20,"url_template":"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png","minZoom":0,"attribution":"HOT and friends"},"licence":"","description":"","name":"test enrhûmé","tilelayersControl":true,"displayDataBrowserOnLoad":false,"displayPopupFooter":true,"displayCaptionOnLoad":false,"miniMap":true,"moreControl":true,"scaleControl":true,"zoomControl":true,"datalayersControl":true,"zoom":8}}'
         }
         self.client.login(username=self.user.username, password="123123")
         response = self.client.post(url, post_data)
         json = simplejson.loads(response.content)
         self.assertNotIn("html", json)
         updated_map = Map.objects.get(pk=self.map.pk)
-        self.assertEqual(json['redirect'], updated_map.get_absolute_url())
+        self.assertEqual(json['id'], updated_map.pk)
         self.assertEqual(updated_map.name, new_name)
 
-    def test_delete_GET(self):
+    def test_delete(self):
         url = reverse('map_delete', args=(self.map.pk, ))
         self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("form", json['html'])
-
-    def test_delete_POST(self):
-        # create some features
-        marker1 = MarkerFactory(datalayer=self.datalayer)
-        marker2 = MarkerFactory(datalayer=self.datalayer)
-        marker3 = MarkerFactory(datalayer=self.datalayer)
-        url = reverse('map_delete', args=(self.map.pk, ))
-        post_data = {
-            'confirm': "yes",
-        }
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.post(url, post_data, follow=True)
+        response = self.client.post(url, {}, follow=True)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(Map.objects.filter(pk=self.map.pk).count(), 0)
         self.assertEqual(DataLayer.objects.filter(pk=self.datalayer.pk).count(), 0)
-        # Check that features have been delete
-        self.assertEqual(Marker.objects.filter(pk=marker1.pk).count(), 0)
-        self.assertEqual(Marker.objects.filter(pk=marker2.pk).count(), 0)
-        self.assertEqual(Marker.objects.filter(pk=marker3.pk).count(), 0)
         # Check that user has not been impacted
         self.assertEqual(User.objects.filter(pk=self.user.pk).count(), 1)
         # Test response is a json
         self.assertEqual(Map.objects.count(), 1)
         url = reverse('map_clone', kwargs={'map_id': self.map.pk})
         self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
+        response = self.client.post(url)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(Map.objects.count(), 2)
         clone = Map.objects.latest('pk')
         url = reverse('map_clone', kwargs={'map_id': self.map.pk})
         self.map.edit_status = self.map.OWNER
         self.map.save()
-        response = self.client.get(url)
+        response = self.client.post(url)
         self.assertLoginRequired(response)
         other_user = UserFactory(username="Bob", password="123123")
         self.client.login(username=other_user.username, password="123123")
-        response = self.client.get(url)
+        response = self.client.post(url)
         self.assertEqual(response.status_code, 403)
         self.map.edit_status = self.map.ANONYMOUS
         self.map.save()
         self.client.logout()
-        response = self.client.get(url)
+        response = self.client.post(url)
         self.assertEqual(response.status_code, 403)
         self.assertEqual(Map.objects.count(), 1)
 
         self.map.editors.add(other_user)
         self.map.save()
         self.client.login(username=other_user.username, password="123123")
-        response = self.client.get(url)
+        response = self.client.post(url)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(Map.objects.count(), 2)
         clone = Map.objects.latest('pk')
         self.anonymous_map = MapFactory(
             name="an-anonymous-map",
             owner=None,
-            licence=self.licence
         )
         key, value = self.anonymous_map.signed_cookie_elements
         self.anonymous_cookie_key = key
         self.anonymous_cookie_value = get_cookie_signer(salt=key).sign(value)
 
-    def test_quick_create_GET(self):
-        url = reverse('map_add')
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("form", json['html'])
-
-    def test_quick_create_POST(self):
-        url = reverse('map_add')
+    def test_create(self):
+        url = reverse('map_create')
         # POST only mendatory fields
         name = 'test-map-with-new-name'
         post_data = {
             'name': name,
-            'licence': self.licence.pk
+            'center': '{"type":"Point","coordinates":[13.447265624999998,48.94415123418794]}',
+            'settings': '{"type":"Feature","geometry":{"type":"Point","coordinates":[5.0592041015625,52.05924589011585]},"properties":{"tilelayer":{"maxZoom":20,"url_template":"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png","minZoom":0,"attribution":"HOT and friends"},"licence":"","description":"","name":"test enrhûmé","tilelayersControl":true,"displayDataBrowserOnLoad":false,"displayPopupFooter":true,"displayCaptionOnLoad":false,"miniMap":true,"moreControl":true,"scaleControl":true,"zoomControl":true,"datalayersControl":true,"zoom":8}}'
         }
         response = self.client.post(url, post_data)
         self.assertEqual(response.status_code, 200)
         json = simplejson.loads(response.content)
         created_map = Map.objects.latest('pk')
-        self.assertEqual(json['redirect'], created_map.get_absolute_url())
+        self.assertEqual(json['id'], created_map.pk)
         self.assertEqual(created_map.name, name)
         key, value = created_map.signed_cookie_elements
         self.assertIn(key, self.client.cookies)
 
-    def test_quick_update_no_cookie_GET(self):
-        url = reverse('map_update', kwargs={'map_id': self.anonymous_map.pk})
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertNotIn("html", json)
-        self.assertIn("login_required", json)
-
-    def test_quick_update_no_cookie_POST(self):
+    def test_update_no_cookie(self):
         url = reverse('map_update', kwargs={'map_id': self.anonymous_map.pk})
         # POST only mendatory fields
         new_name = 'new map name'
         post_data = {
             'name': new_name,
-            'licence': self.anonymous_map.licence.pk
+            'center': '{"type":"Point","coordinates":[13.447265624999998,48.94415123418794]}',
+            'settings': '{"type":"Feature","geometry":{"type":"Point","coordinates":[5.0592041015625,52.05924589011585]},"properties":{"tilelayer":{"maxZoom":20,"url_template":"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png","minZoom":0,"attribution":"HOT and friends"},"licence":"","description":"","name":"test enrhûmé","tilelayersControl":true,"displayDataBrowserOnLoad":false,"displayPopupFooter":true,"displayCaptionOnLoad":false,"miniMap":true,"moreControl":true,"scaleControl":true,"zoomControl":true,"datalayersControl":true,"zoom":8}}'
         }
         response = self.client.post(url, post_data)
         self.assertEqual(response.status_code, 200)
         json = simplejson.loads(response.content)
-        self.assertNotIn("html", json)
+        self.assertNotIn("id", json)
         self.assertIn("login_required", json)
 
-    def test_quick_update_with_cookie_GET(self):
-        url = reverse('map_update', kwargs={'map_id': self.anonymous_map.pk})
-        self.client.cookies[self.anonymous_cookie_key] = self.anonymous_cookie_value
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-
-    def test_quick_update_with_cookie_POST(self):
+    def test_update_with_cookie(self):
         url = reverse('map_update', kwargs={'map_id': self.anonymous_map.pk})
         self.client.cookies[self.anonymous_cookie_key] = self.anonymous_cookie_value
         # POST only mendatory fields
         new_name = 'new map name'
         post_data = {
             'name': new_name,
-            'licence': self.anonymous_map.licence.pk
+            'center': '{"type":"Point","coordinates":[13.447265624999998,48.94415123418794]}',
+            'settings': '{"type":"Feature","geometry":{"type":"Point","coordinates":[5.0592041015625,52.05924589011585]},"properties":{"tilelayer":{"maxZoom":20,"url_template":"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png","minZoom":0,"attribution":"HOT and friends"},"licence":"","description":"","name":"test enrhûmé","tilelayersControl":true,"displayDataBrowserOnLoad":false,"displayPopupFooter":true,"displayCaptionOnLoad":false,"miniMap":true,"moreControl":true,"scaleControl":true,"zoomControl":true,"datalayersControl":true,"zoom":8}}'
         }
         response = self.client.post(url, post_data)
         self.assertEqual(response.status_code, 200)
         json = simplejson.loads(response.content)
         updated_map = Map.objects.get(pk=self.anonymous_map.pk)
-        self.assertEqual(json['redirect'], updated_map.get_absolute_url())
+        self.assertEqual(json['id'], updated_map.pk)
 
     def test_anonymous_edit_url(self):
         url = self.anonymous_map.get_anonymous_edit_url()
         new_name = 'new map name for authenticated user'
         post_data = {
             'name': new_name,
-            'licence': self.anonymous_map.licence.pk
+            'center': '{"type":"Point","coordinates":[13.447265624999998,48.94415123418794]}',
+            'settings': '{"type":"Feature","geometry":{"type":"Point","coordinates":[5.0592041015625,52.05924589011585]},"properties":{"tilelayer":{"maxZoom":20,"url_template":"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png","minZoom":0,"attribution":"HOT and friends"},"licence":"","description":"","name":"test enrhûmé","tilelayersControl":true,"displayDataBrowserOnLoad":false,"displayPopupFooter":true,"displayCaptionOnLoad":false,"miniMap":true,"moreControl":true,"scaleControl":true,"zoomControl":true,"datalayersControl":true,"zoom":8}}'
         }
         response = self.client.post(url, post_data)
         self.assertEqual(response.status_code, 200)
         json = simplejson.loads(response.content)
         updated_map = Map.objects.get(pk=self.anonymous_map.pk)
-        self.assertEqual(json['redirect'], updated_map.get_absolute_url())
+        self.assertEqual(json['id'], updated_map.pk)
         self.assertEqual(updated_map.owner.pk, self.user.pk)
 
     def test_clone_map_should_not_be_possible_if_user_is_not_allowed(self):
         self.assertEqual(response.status_code, 403)
         self.assertEqual(Map.objects.count(), 2)
 
-    def test_clone_map_should_be_possible_if_edit_status_is_anonnymous(self):
+    def test_clone_map_should_be_possible_if_edit_status_is_anonymous(self):
         self.assertEqual(Map.objects.count(), 2)
         url = reverse('map_clone', kwargs={'map_id': self.map.pk})
         self.map.edit_status = self.map.ANONYMOUS
         self.map.save()
-        response = self.client.get(url)
+        response = self.client.post(url)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(Map.objects.count(), 3)
         clone = Map.objects.latest('pk')
 @override_settings(LEAFLET_STORAGE_ALLOW_ANONYMOUS=False)
 class MapViewsPermissions(ViewsPermissionsTest):
 
-    def test_map_add_permissions(self):
-        url = reverse('map_add')
-        # GET anonymous
-        response = self.client.get(url)
-        self.assertLoginRequired(response)
+    def test_map_create_permissions(self):
+        url = reverse('map_create')
         # POST anonymous
         response = self.client.post(url, {})
         self.assertLoginRequired(response)
         url = reverse('map_update', kwargs={'map_id': self.map.pk})
         self.check_url_permissions(url)
 
-    def test_upload_data_permissions(self):
-        url = reverse('upload_data', kwargs={'map_id': self.map.pk})
-        self.check_url_permissions(url)
-
-    def test_map_update_extend_permissions(self):
-        # only POST is available for this view
-        url = reverse('map_update_extent', kwargs={'map_id': self.map.pk})
-        # POST anonymous
-        response = self.client.post(url, {})
-        self.assertLoginRequired(response)
-        # POST with wrong permissions
-        self.client.login(username=self.other_user.username, password="123123")
-        response = self.client.post(url, {})
-        self.assertEqual(response.status_code, 403)
-
-    def test_embed_view_should_be_open_bar(self):
-        url = reverse('map_embed', kwargs={'map_id': self.map.pk})
-        # HTTP_HOST is needed by the view for now
-        response = self.client.get(url, HTTP_HOST="local.local")
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("iframe", json['html'])
-
     def test_only_owner_can_delete(self):
         self.map.editors.add(self.other_user)
         url = reverse('map_delete', kwargs={'map_id': self.map.pk})
-        post_data = {
-            'confirm': "yes",
-        }
         self.client.login(username=self.other_user.username, password="123123")
-        response = self.client.post(url, post_data, follow=True)
+        response = self.client.post(url, {}, follow=True)
         self.assertEqual(response.status_code, 403)
 
 
-@override_settings(LEAFLET_STORAGE_ALLOW_ANONYMOUS=False)
-class MarkerViewsPermissions(ViewsPermissionsTest):
-
-    def test_marker_add(self):
-        url = reverse('marker_add', kwargs={'map_id': self.map.pk})
-        self.check_url_permissions(url)
-
-    def test_marker_update(self):
-        marker = MarkerFactory(datalayer=self.datalayer)
-        url = reverse('marker_update', kwargs={'map_id': self.map.pk, 'pk': marker.pk})
-        self.check_url_permissions(url)
-
-    def test_marker_delete(self):
-        marker = MarkerFactory(datalayer=self.datalayer)
-        url = reverse('marker_delete', kwargs={'map_id': self.map.pk, 'pk': marker.pk})
-        self.check_url_permissions(url)
-
-
-class MarkerViews(BaseTest):
-
-    def test_add_GET(self):
-        url = reverse('marker_add', args=(self.map.pk, ))
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("form", json['html'])
-
-    def test_add_POST(self):
-        url = reverse('marker_add', args=(self.map.pk, ))
-        name = 'test-marker'
-        post_data = {
-            'name': name,
-            'datalayer': self.datalayer.pk,
-            'latlng': '{"type": "Point","coordinates": [-0.1318359375,51.474540439419755]}'
-        }
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.post(url, post_data, follow=True)
-        self.assertEqual(response.status_code, 200)
-        created_marker = Marker.objects.latest('pk')
-        self.assertEqual(created_marker.name, name)
-        # Test response is a json
-        json = simplejson.loads(response.content)
-        self.assertIn("geometry", json)
-
-    def test_delete_GET(self):
-        marker = MarkerFactory(datalayer=self.datalayer)
-        url = reverse('marker_delete', args=(self.map.pk, marker.pk))
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("form", json['html'])
-
-    def test_delete_POST(self):
-        marker = MarkerFactory(datalayer=self.datalayer)
-        url = reverse('marker_delete', args=(self.map.pk, marker.pk))
-        post_data = {
-            'confirm': "yes",
-        }
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.post(url, post_data, follow=True)
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Marker.objects.filter(pk=marker.pk).count(), 0)
-        # Check that datalayer and map have not been impacted
-        self.assertEqual(Map.objects.filter(pk=self.map.pk).count(), 1)
-        self.assertEqual(DataLayer.objects.filter(pk=self.datalayer.pk).count(), 1)
-        # Test response is a json
-        json = simplejson.loads(response.content)
-        self.assertIn("info", json)
-
-
-class UploadData(TransactionTestCase):
-
-    def setUp(self):
-        self.user = UserFactory(password="123123")
-        self.map = MapFactory(owner=self.user)
-        self.datalayer = DataLayerFactory(map=self.map)
-
-    def tearDown(self):
-        self.user.delete()
-
-    def process_file(self, filename, content_type):
-        """
-        Process a file stored in tests/fixtures/
-        """
-        url = reverse('upload_data', kwargs={'map_id': self.map.pk})
-        current_path = os.path.dirname(os.path.realpath(__file__))
-        fixture_path = os.path.join(
-            current_path,
-            'fixtures',
-            filename
-        )
-        f = open(fixture_path)
-        post_data = {
-            'datalayer': self.datalayer.pk,
-            'data_file': f,
-            'content_type': content_type
-        }
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.post(url, post_data)
-        return response
-
-    def test_GeoJSON_generic(self):
-        # Contains tow Point, two Polygons and one Polyline
-        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(datalayer=self.datalayer).count(), 2)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 2)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 1)
-        # Check properties population
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer, name="London").count(), 1)
-        marker = Marker.objects.get(datalayer=self.datalayer, name="London")
-        self.assertEqual(marker.description, "London description")
-        self.assertEqual(marker.options["color"], "Pink")
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer, name="Antwerpen").count(), 1)
-        marker = Marker.objects.get(datalayer=self.datalayer, name="Antwerpen")
-        self.assertEqual(marker.description, None)
-        self.assertFalse("color" in marker.options)
-
-    def test_GeoJSON_empty_coordinates_should_not_be_imported(self):
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 0)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 0)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 0)
-        response = self.process_file("test_upload_empty_coordinates.json", "geojson")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 0)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 0)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 0)
-
-    def test_GeoJSON_non_linear_ring_should_not_be_imported(self):
-        response = self.process_file("test_upload_non_linear_ring.json", "geojson")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 0)
-
-    def test_GeoJSON_missing_name_should_be_set_with_datalayer_name(self):
-        # One feature is missing a name
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 0)
-        response = self.process_file("test_upload_missing_name.json", "geojson")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 2)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer, name=self.datalayer.name).count(), 1)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 1)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 1)
-
-    def test_import_data_from_url(self):
-        url = reverse('upload_data', kwargs={'map_id': self.map.pk})
-        current_path = os.path.dirname(os.path.realpath(__file__))
-        fixture_path = os.path.join(
-            current_path,
-            'fixtures',
-            "test_upload_data.json"
-        )
-        post_data = {
-            'datalayer': self.datalayer.pk,
-            'data_url': "file://%s" % fixture_path,
-            '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", "geojson")
-        self.client.login(username=self.user.username, password="123123")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 2)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 2)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 1)
-
-    def test_KML_generic(self):
-        response = self.process_file("test_upload_data.kml", "kml")
-        self.client.login(username=self.user.username, password="123123")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 1)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 1)
-        self.assertEqual(Polygon.objects.filter(datalayer=self.datalayer).count(), 1)
-
-    def test_GPX_generic(self):
-        response = self.process_file("test_upload_data.gpx", "gpx")
-        self.client.login(username=self.user.username, password="123123")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Polyline.objects.filter(datalayer=self.datalayer).count(), 1)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 1)
-
-    def test_CSV_generic(self):
-        response = self.process_file("test_upload_data.csv", "csv")
-        self.client.login(username=self.user.username, password="123123")
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 1)
-        marker = Marker.objects.get(datalayer=self.datalayer)
-        self.assertEqual(marker.name, "a point somewhere")
-
-    def test_import_data_from_textarea(self):
-        url = reverse('upload_data', kwargs={'map_id': self.map.pk})
-        data_raw = """latitude,longitude,name\n41.1,118,my title"""
-        post_data = {
-            'datalayer': self.datalayer.pk,
-            'data_raw': data_raw,
-            'content_type': 'csv'
-        }
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.post(url, post_data)
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(Marker.objects.filter(datalayer=self.datalayer).count(), 1)
-
-
-class DownloadDataViews(BaseTest):
-
-    def test_geojson_download(self):
-        url = reverse('download_data', kwargs={'map_id': self.map.pk})
-        marker = MarkerFactory(
-            datalayer=self.datalayer,
-            description="this is a description",
-            options={'color': '#123456'})
-        response = self.client.get(url)
-        self.assertEqual(response['Content-Type'], 'application/json')
-        json = simplejson.loads(response.content)
-        self.assertIn("features", json)
-        feature = json['features'][0]
-        self.assertEqual(feature['properties']['description'], marker.description)
-        self.assertEqual(feature['properties']['color'], marker.options['color'])
-
-
 class DataLayerViews(BaseTest):
 
-    def test_delete_GET(self):
+    def test_delete(self):
         url = reverse('datalayer_delete', args=(self.map.pk, self.datalayer.pk))
         self.client.login(username=self.user.username, password="123123")
-        response = self.client.get(url)
-        self.assertEqual(response.status_code, 200)
-        json = simplejson.loads(response.content)
-        self.assertIn("html", json)
-        self.assertIn("form", json['html'])
-
-    def test_delete_POST(self):
-        # create some features
-        marker1 = MarkerFactory(datalayer=self.datalayer)
-        marker2 = MarkerFactory(datalayer=self.datalayer)
-        marker3 = MarkerFactory(datalayer=self.datalayer)
-        url = reverse('datalayer_delete', args=(self.map.pk, self.datalayer.pk))
-        post_data = {
-            'confirm': "yes",
-        }
-        self.client.login(username=self.user.username, password="123123")
-        response = self.client.post(url, post_data, follow=True)
+        response = self.client.post(url, {}, follow=True)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(DataLayer.objects.filter(pk=self.datalayer.pk).count(), 0)
-        # Check that features have been delete
-        self.assertEqual(Marker.objects.filter(pk=marker1.pk).count(), 0)
-        self.assertEqual(Marker.objects.filter(pk=marker2.pk).count(), 0)
-        self.assertEqual(Marker.objects.filter(pk=marker3.pk).count(), 0)
         # Check that map has not been impacted
         self.assertEqual(Map.objects.filter(pk=self.map.pk).count(), 1)
         # Test response is a json

File leaflet_storage/views.py

         else:
             msg = _("Congratulations, your map has been created!")
         response = simple_json_response(
-            pk=self.object.pk,
+            id=self.object.pk,
             url=self.object.get_absolute_url(),
             info=msg
         )
         self.object.settings = form.cleaned_data["settings"]
         self.object.save()
         return simple_json_response(
-            pk=self.object.pk,
+            id=self.object.pk,
             url=self.object.get_absolute_url(),
             info=_("Map has been updated!")
         )