From ddb2d2e1586b04326a14825470f780fd2857bfa5 Mon Sep 17 00:00:00 2001 From: Wannes Rombouts <wapiflapi@yahoo.fr> Date: Thu, 6 Jun 2013 15:32:00 +0200 Subject: [PATCH] moved mapfile's delete function to server.py, Also added create/delete mapfile to testScenario --- src/mapfile.py | 5 ----- src/server.py | 12 ++++-------- tests/testScenario.py | 5 +++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/mapfile.py b/src/mapfile.py index b9665dd..05f725b 100644 --- a/src/mapfile.py +++ b/src/mapfile.py @@ -726,11 +726,6 @@ class Mapfile(MetadataMixin): path = self.path self.ms.save(path) - def delete(self, path=None): - if path is None: - path = self.path - os.remove(path) - def rawtext(self): open(self.path, "r").read() diff --git a/src/server.py b/src/server.py index ab31b38..905a18a 100755 --- a/src/server.py +++ b/src/server.py @@ -94,7 +94,7 @@ class mapfiles(object): map_name = data.pop("name") path = tools.mk_mapfile_path(map_name) - with webapp.mightConflict("Mapfile", mapfile=map_name): + with webapp.mightConflict(message="Mapfile '{exception}' already exists."): maptools.create_mapfile(path, map_name, data) webapp.Created("%s/maps/%s%s" % (web.ctx.home, map_name, (".%s" % format) if format else "")) @@ -121,21 +121,17 @@ class named_mapfile(object): data = get_data(name="mapfile", mandatory=["name"], authorized=["name", "title", "abstract"]) if map_name != data.pop("name"): raise webapp.Forbidden("Can't change the name of a mapfile.") - - with webapp.mightConflict("Mapfile", mapfile=map_name): - mf.update(data) + mf.update(data) mf.save() @HTTPCompatible() def DELETE(self, map_name, format): mf = get_mapfile(map_name) - path = tools.mk_mapfile_path(map_name) # TODO: We need to check if this mapfile is empty. - - with webapp.mightConflict("Mapfile", mapfile=map_name): - mf.delete() + with webapp.mightNotFound("Mapfile", mapfile=map_name): + os.remove(mf.path) class workspaces(object): diff --git a/tests/testScenario.py b/tests/testScenario.py index 98a3a54..ae60def 100644 --- a/tests/testScenario.py +++ b/tests/testScenario.py @@ -365,8 +365,9 @@ def test_scenario(): map_name = "tests" # Clean the test file, now we are sure it is empty. - APIRequest("PUT", target + "/tests/" + map_name) - + # APIRequest("PUT", target + "/tests/" + map_name) + APIRequest("DELETE", target + "/maps/" + map_name) + APIRequest("POST", target + "/maps", {"mapfile":{"name":map_name}}) # _test_workspaces(target, map_name) # _test_styles(target, map_name) -- GitLab