Esempio n. 1
0
    def test_missing_parameters(self):
        """Test response for a Bad Request when parameters are missing."""
        request = Request.blank('/')

        from cnxmathml2svg import convert
        with self.assertRaises(httpexceptions.HTTPBadRequest):
            convert(request)
Esempio n. 2
0
    def test_transform_failure(self):
        """Test MathML2SVG post with content that won't transform,
        but contains valid xml and MathML elements.
        """
        request = Request.blank('/', POST={'MathML': INVALID_MATHML})

        from cnxmathml2svg import convert
        exception_cls = httpexceptions.HTTPInternalServerError
        with self.assertRaises(exception_cls) as caught_exc:
            convert(request)

        exception = caught_exc.exception
        self.assertIn(b'Error reported by XML parser: ', exception.comment)
Esempio n. 3
0
    def test_success_w_multiform_post(self):
        """Test MathML2SVG post using a multipart form value."""
        request = Request.blank('/', POST={'MathML': ('mathml.xml', MATHML)})

        from cnxmathml2svg import convert
        response = convert(request)

        self.assertIn(b'<svg ', response.body)
        self.assertEqual(response.content_type, 'image/svg+xml')