예제 #1
0
    def test_tile_unhandled_error_code(self, app):
        expected_req = [(
            {
                "path": "/foo/1/1/0.png"
            },
            {
                "body": b"error",
                "status": 500,
                "headers": {
                    "content-type": "text/plain"
                },
            },
        )]

        with mock_httpd(("localhost", 42423), expected_req):
            resp = app.get(self.common_tile_req, status=500)
            assert_no_cache(resp)
            assert resp.content_type == "text/plain"
            assert b"500" in resp.body
예제 #2
0
    def test_wms_catchall_error_no_image_response(self, app):
        expected_req = [(
            {
                "path": "/foo/1/1/0.png"
            },
            {
                "body": b"error",
                "status": 200,
                "headers": {
                    "content-type": "text/plain"
                },
            },
        )]

        with mock_httpd(("localhost", 42423), expected_req):
            self.common_map_req.params["layers"] = "tilesource_catchall"
            resp = app.get(self.common_map_req)
            assert_no_cache(resp)
            assert resp.content_type == "image/png"
            img = img_from_buf(resp.body)
            assert img.getcolors() == [(250 * 250, (100, 50, 50))]
예제 #3
0
    def test_tile_uncached_response(self, app, cache_dir):
        expected_req = [(
            {
                "path": "/foo/1/1/0.png"
            },
            {
                "body": b"not found",
                "status": 404,
                "headers": {
                    "content-type": "text/plain"
                },
            },
        )]

        with mock_httpd(("localhost", 42423), expected_req):
            resp = app.get(self.common_tile_req)
            assert_no_cache(resp)
            assert resp.content_type == "image/png"
            img = img_from_buf(resp.body)
            assert img.getcolors() == [(256 * 256, (255, 0, 128))]
            assert not cache_dir.join(
                "tilesource_cache_EPSG4326/01/000/000/001/000/000/000.png"
            ).check()
예제 #4
0
    def test_mixed_layer_source(self, app):
        common_params = (r"?SERVICE=WMS&FORMAT=image%2Fpng"
                         "&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles="
                         "&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0"
                         "&WIDTH=200&transparent=True")

        expected_req = [(
            {
                "path": "/service_a" + common_params + "&layers=a_one"
            },
            {
                "body": transp,
                "headers": {
                    "content-type": "image/png"
                }
            },
        )]

        with mock_httpd(("localhost", 42423), expected_req):
            self.common_map_req.params.layers = "mixed"
            resp = app.get(self.common_map_req)
            assert_no_cache(resp)
            assert resp.content_type == "image/png"
            assert 0.99 > bgcolor_ratio(resp.body) > 0.95
예제 #5
0
 def test_get_tile_wrong_size(self, app):
     self.common_map_req.params.size = (256, 255)
     resp = app.get(str(self.common_map_req) + "&tiled=true")
     assert_no_cache(resp)
     is_111_exception(resp.lxml,
                      re_msg="Invalid request: invalid.*size.*256x256")
예제 #6
0
 def test_get_tile_wrong_fromat(self, app):
     self.common_map_req.params.format = "image/png"
     resp = app.get(str(self.common_map_req) + "&tiled=true")
     assert_no_cache(resp)
     is_111_exception(resp.lxml,
                      re_msg="Invalid request: invalid.*format.*jpeg")
예제 #7
0
 def test_get_tile_wrong_bbox(self, app):
     self.common_map_req.params.bbox = "-20037508,0.0,200000.0,20037508"
     resp = app.get(str(self.common_map_req) + "&tiled=true")
     assert_no_cache(resp)
     is_111_exception(resp.lxml, re_msg=".*invalid bbox")