def test_no_name_param(self): from pyramid.testing import DummyRequest from pyramid.httpexceptions import HTTPBadRequest from c2cgeoportal_geoportal.views.export import exportgpxkml request = DummyRequest() request.method = "POST" request.params = { "format": "gpx", "doc": "<gpx>éç</gpx>", } response = exportgpxkml(request) self.assertEqual(type(response), HTTPBadRequest)
def test_gpx(self): from pyramid.testing import DummyRequest from c2cgeoportal_geoportal.views.export import exportgpxkml request = DummyRequest() request.method = "POST" request.params = { "format": "gpx", "name": "foo", "doc": "<gpx>éç</gpx>", } response = exportgpxkml(request) self.assertEqual(response.content_disposition, "attachment; filename=foo.gpx") self.assertEqual(response.content_type, "application/gpx") self.assertEqual(response.body, "<gpx>éç</gpx>".encode("UTF-8"))
def test_kml(self): from pyramid.testing import DummyRequest from c2cgeoportal_geoportal.views.export import exportgpxkml request = DummyRequest() request.method = "POST" request.params = { "format": "kml", "name": "foo", "doc": "<kml>éç</kml>", } response = exportgpxkml(request) self.assertEqual(response.content_disposition, "attachment; filename=foo.kml") self.assertEqual(response.content_type, "application/vnd.google-earth.kml+xml") self.assertEqual(response.body, "<kml>éç</kml>".encode("UTF-8"))