예제 #1
0
    def test_no_name_param(self):
        from pyramid.testing import DummyRequest
        from pyramid.httpexceptions import HTTPBadRequest
        from c2cgeoportal.views.export import exportgpxkml

        request = DummyRequest()
        request.method = "POST"
        request.params = {
            "format": "gpx",
            "doc": u"<gpx>éç</gpx>",
        }
        response = exportgpxkml(request)
        self.assertEqual(type(response), HTTPBadRequest)
예제 #2
0
    def test_no_name_param(self):
        from pyramid.testing import DummyRequest
        from pyramid.httpexceptions import HTTPBadRequest
        from c2cgeoportal.views.export import exportgpxkml

        request = DummyRequest()
        request.method = "POST"
        request.params = {
            "format": "gpx",
            "doc": u"<gpx>éç</gpx>",
        }
        response = exportgpxkml(request)
        self.assertEqual(type(response), HTTPBadRequest)
예제 #3
0
    def test_gpx(self):
        from pyramid.testing import DummyRequest
        from c2cgeoportal.views.export import exportgpxkml

        request = DummyRequest()
        request.method = "POST"
        request.params = {
            "format": u"gpx",
            "name": u"foo",
            "doc": u"<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, u"<gpx>éç</gpx>".encode("UTF-8"))
예제 #4
0
    def test_kml(self):
        from pyramid.testing import DummyRequest
        from c2cgeoportal.views.export import exportgpxkml

        request = DummyRequest()
        request.method = "POST"
        request.params = {
            "format": u"kml",
            "name": u"foo",
            "doc": u"<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, u"<kml>éç</kml>".encode("UTF-8"))