예제 #1
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        ex_handler = self.mock(ExceptionHandler)

        req_ex = RequestError("the exception message", request=req)
        self.expect(req.exception_handler).result(ex_handler)
        self.expect(ex_handler.render(req_ex))

        self.replay()
        req_ex.render()
예제 #2
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        ex_handler = self.mock(ExceptionHandler)

        req_ex = RequestError('the exception message', request=req)
        self.expect(req.exception_handler).result(ex_handler)
        self.expect(ex_handler.render(req_ex))

        self.replay()
        req_ex.render()
예제 #3
0
    def test_exception(self):
        self.req["exceptions"] = "blank"
        req = WMSMapRequest(self.req)
        req_ex = RequestError("the exception message", request=req)

        response = req_ex.render()
        assert response.content_type == "image/png"
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        eq_(img.getpixel((0, 0)), 0)  # pallete image
        eq_(img.getpalette()[0:3], [255, 255, 255])
예제 #4
0
    def test_exception(self):
        self.req.set("exceptions", "inimage")
        self.req.set("transparent", "true")

        req = WMSMapRequest(self.req)
        req_ex = RequestError("the exception message", request=req)

        response = req_ex.render()
        assert response.content_type == "image/png"
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
예제 #5
0
    def test_exception(self):
        self.req.set('exceptions', 'inimage')
        self.req.set('transparent', 'true')

        req = WMSMapRequest(self.req)
        req_ex = RequestError('the exception message', request=req)

        response = req_ex.render()
        assert response.content_type == 'image/png'
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
예제 #6
0
    def test_exception(self):
        self.req['exceptions'] = 'blank'
        req = WMSMapRequest(self.req)
        req_ex = RequestError('the exception message', request=req)

        response = req_ex.render()
        assert response.content_type == 'image/png'
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        eq_(img.getpixel((0, 0)), 0)  #pallete image
        eq_(img.getpalette()[0:3], [255, 255, 255])
예제 #7
0
    def test_exception_w_bgcolor(self):
        self.req.set('exceptions', 'blank')
        self.req.set('bgcolor', '0xff00ff')

        req = WMSMapRequest(self.req)
        req_ex = RequestError('the exception message', request=req)

        response = req_ex.render()
        assert response.content_type == 'image/png'
        data = BytesIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        assert img.getpixel((0, 0)) == 0  #pallete image
        assert img.getpalette()[0:3] == [255, 0, 255]
예제 #8
0
    def test_exception_w_transparent(self):
        self.req.set("exceptions", "inimage")
        self.req.set("transparent", "true")

        req = WMSMapRequest(self.req)
        req_ex = RequestError("the exception message", request=req)

        response = req_ex.render()
        assert response.content_type == "image/png"
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        eq_(sorted([x for x in img.histogram() if x > 25]), [377, 14623])
        img = img.convert("RGBA")
        eq_(img.getpixel((0, 0))[3], 0)
예제 #9
0
    def test_exception_w_transparent(self):
        self.req.set("exceptions", "blank")
        self.req.set("transparent", "true")

        req = WMSMapRequest(self.req)
        req_ex = RequestError("the exception message", request=req)

        response = req_ex.render()
        assert response.content_type == "image/png"
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        assert img.mode == "P"
        img = img.convert("RGBA")
        eq_(img.getpixel((0, 0))[3], 0)
예제 #10
0
    def test_exception_w_transparent(self):
        self.req.set('exceptions', 'inimage')
        self.req.set('transparent', 'true')

        req = WMSMapRequest(self.req)
        req_ex = RequestError('the exception message', request=req)

        response = req_ex.render()
        assert response.content_type == 'image/png'
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        eq_(sorted([x for x in img.histogram() if x > 25]), [377, 14623])
        img = img.convert('RGBA')
        eq_(img.getpixel((0, 0))[3], 0)
예제 #11
0
    def test_exception_w_transparent(self):
        self.req.set('exceptions', 'blank')
        self.req.set('transparent', 'true')

        req = WMSMapRequest(self.req)
        req_ex = RequestError('the exception message', request=req)

        response = req_ex.render()
        assert response.content_type == 'image/png'
        data = StringIO(response.data)
        assert is_png(data)
        img = Image.open(data)
        assert img.size == (150, 100)
        assert img.mode == 'P'
        img = img.convert('RGBA')
        eq_(img.getpixel((0, 0))[3], 0)
예제 #12
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        req_ex = RequestError("the exception message", request=req)
        ex_handler = WMS100ExceptionHandler()
        self.expect(req.exception_handler).result(ex_handler)

        self.replay()
        response = req_ex.render()

        assert response.content_type == "text/xml"
        expected_resp = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<WMTException version="1.0.0">
the exception message
</WMTException>
"""
        assert expected_resp.strip() == response.data
예제 #13
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        req_ex = RequestError('the exception message', request=req)
        ex_handler = WMS100ExceptionHandler()
        self.expect(req.exception_handler).result(ex_handler)

        self.replay()
        response = req_ex.render()

        assert response.content_type == 'text/xml'
        expected_resp = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<WMTException version="1.0.0">
the exception message
</WMTException>
"""
        assert expected_resp.strip() == response.data
예제 #14
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        req_ex = RequestError("the exception message", request=req)
        ex_handler = WMS110ExceptionHandler()
        self.expect(req.exception_handler).result(ex_handler)

        self.replay()
        response = req_ex.render()
        assert response.content_type == "application/vnd.ogc.se_xml"
        expected_resp = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.0/exception_1_1_0.dtd">
<ServiceExceptionReport version="1.1.0">
    <ServiceException>the exception message</ServiceException>
</ServiceExceptionReport>
"""
        assert expected_resp.strip() == response.data
        assert validate_with_dtd(response.data, "wms/1.1.0/exception_1_1_0.dtd")
예제 #15
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        req_ex = RequestError('the exception message', request=req)
        ex_handler = WMS110ExceptionHandler()
        self.expect(req.exception_handler).result(ex_handler)

        self.replay()
        response = req_ex.render()
        assert response.content_type == 'application/vnd.ogc.se_xml'
        expected_resp = b"""
<?xml version="1.0"?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.0/exception_1_1_0.dtd">
<ServiceExceptionReport version="1.1.0">
    <ServiceException>the exception message</ServiceException>
</ServiceExceptionReport>
"""
        assert expected_resp.strip() == response.data
        assert validate_with_dtd(response.data, 'wms/1.1.0/exception_1_1_0.dtd')
예제 #16
0
    def test_render(self):
        req = self.mock(WMSMapRequest)
        req_ex = RequestError('the exception message', request=req)
        ex_handler = WMS130ExceptionHandler()
        self.expect(req.exception_handler).result(ex_handler)

        self.replay()
        response = req_ex.render()
        assert response.content_type == 'text/xml; charset=utf-8'
        expected_resp = b"""
<?xml version="1.0"?>
<ServiceExceptionReport version="1.3.0"
  xmlns="http://www.opengis.net/ogc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
    <ServiceException>the exception message</ServiceException>
</ServiceExceptionReport>
"""
        assert expected_resp.strip() == response.data
        assert validate_with_xsd(response.data, 'wms/1.3.0/exceptions_1_3_0.xsd')
예제 #17
0
    def test_render_w_code(self):
        req = self.mock(WMSMapRequest)
        req_ex = RequestError("the exception message", code="InvalidFormat", request=req)
        ex_handler = WMS130ExceptionHandler()
        self.expect(req.exception_handler).result(ex_handler)

        self.replay()
        response = req_ex.render()
        assert response.content_type == "text/xml; charset=utf-8"
        expected_resp = """
<?xml version='1.0' encoding="UTF-8"?>
<ServiceExceptionReport version="1.3.0"
  xmlns="http://www.opengis.net/ogc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
    <ServiceException code="InvalidFormat">the exception message</ServiceException>
</ServiceExceptionReport>
"""
        assert expected_resp.strip() == response.data
        assert validate_with_xsd(response.data, "wms/1.3.0/exceptions_1_3_0.xsd")