Exemplo n.º 1
0
    def test_echo_bad_method(self):
        from c2cgeoportal.views import echo

        request = testing.DummyRequest()

        response = echo.echo(request)
        self.assertEquals(response.status_int, 400)
Exemplo n.º 2
0
    def test_echo_bad_method(self):
        from c2cgeoportal.views import echo

        request = testing.DummyRequest()

        response = echo.echo(request)
        self.assertEquals(response.status_int, 400)
Exemplo n.º 3
0
    def test_echo(self):
        from c2cgeoportal.views import echo
        from webob import Request

        request = Request.blank("/")
        request.method = "POST"
        request.content_type = 'multipart/form-data; boundary="foobar"'
        request.body = """
--foobar
Content-Disposition: form-data; name="file"; filename="a file name"
Content-Type: text/html

some content with non-ASCII chars ç à é
--foobar--
""".encode("utf-8")

        response = echo.echo(request)
        self.assertEqual(response.status_int, 200)
        self.assertEqual(response.content_type, "text/html")
        self.assertEqual(
            json.loads(response.body.decode("utf-8")), {
                "filename": "a file name",
                "data":
                "c29tZSBjb250ZW50IHdpdGggbm9uLUFTQ0lJIGNoYXJzIMOnIMOgIMOp",
                "success": True
            })
Exemplo n.º 4
0
    def test_echo(self):
        from c2cgeoportal.views import echo
        from webob import Request

        request = Request.blank('/')
        request.method = 'POST'
        request.content_type = 'multipart/form-data; boundary="foobar"'
        request.body = '''\
--foobar
Content-Disposition: form-data; name="file"; filename="a file name"
Content-Type: text/html

some content with non-ASCII chars ç à é
--foobar--
'''

        response = echo.echo(request)
        self.assertEquals(response.status_int, 200)
        self.assertEquals(response.content_type, 'text/html')
        self.assertEquals(response.body, '{"filename":"a file name","data":"c29tZSBjb250ZW50IHdpdGggbm9uLUFTQ0lJIGNoYXJzIMOnIMOgIMOp","success":true}')  # NOQA
Exemplo n.º 5
0
    def test_echo(self):
        from c2cgeoportal.views import echo
        from webob import Request

        request = Request.blank('/')
        request.method = 'POST'
        request.content_type = 'multipart/form-data; boundary="foobar"'
        request.body = '''\
--foobar
Content-Disposition: form-data; name="file"; filename="a file name"
Content-Type: text/html

some content with non-ASCII chars ç à é
--foobar--
'''

        response = echo.echo(request)
        self.assertEquals(response.status_int, 200)
        self.assertEquals(response.content_type, 'text/html')
        self.assertEquals(
            response.body,
            '{"filename":"a file name","data":"c29tZSBjb250ZW50IHdpdGggbm9uLUFTQ0lJIGNoYXJzIMOnIMOgIMOp","success":true}'
        )  # NOQA