def test_base_url(self): req = Request(self.env) assert req.base_url == 'http://localhost:5050/service' del self.env['HTTP_HOST'] req = Request(self.env) assert req.base_url == 'http://127.0.0.1:5050/service' self.env['SERVER_PORT'] = '80' req = Request(self.env) assert req.base_url == 'http://127.0.0.1/service'
def test_base_url(self): req = Request(self.env) assert req.base_url == "http://localhost:5050/service" del self.env["HTTP_HOST"] req = Request(self.env) assert req.base_url == "http://127.0.0.1:5050/service" self.env["SERVER_PORT"] = "80" req = Request(self.env) assert req.base_url == "http://127.0.0.1/service"
def test_script_url(self): req = Request(self.env) assert req.script_url == "http://localhost:5050" self.env["SCRIPT_NAME"] = "/" req = Request(self.env) assert req.script_url == "http://localhost:5050" self.env["SCRIPT_NAME"] = "/proxy" req = Request(self.env) assert req.script_url == "http://localhost:5050/proxy" self.env["SCRIPT_NAME"] = "/proxy/" req = Request(self.env) assert req.script_url == "http://localhost:5050/proxy"
def test_script_url(self): req = Request(self.env) eq_(req.script_url, 'http://localhost:5050') self.env['SCRIPT_NAME'] = '/' req = Request(self.env) eq_(req.script_url, 'http://localhost:5050') self.env['SCRIPT_NAME'] = '/proxy' req = Request(self.env) eq_(req.script_url, 'http://localhost:5050/proxy') self.env['SCRIPT_NAME'] = '/proxy/' req = Request(self.env) eq_(req.script_url, 'http://localhost:5050/proxy')
def test_query_string_encoding(self): env = { 'QUERY_STRING': 'foo=some%20special%20chars%20%26%20%3D' } req = Request(env) print(req.args['foo']) assert req.args['foo'] == u'some special chars & ='
def test_pop_path(self): self.env["PATH_INFO"] = "/foo/service" req = Request(self.env) part = req.pop_path() assert part == "foo" assert self.env["PATH_INFO"] == "/service" assert self.env["SCRIPT_NAME"] == "/foo" part = req.pop_path() assert part == "service" assert self.env["PATH_INFO"] == "" assert self.env["SCRIPT_NAME"] == "/foo/service" part = req.pop_path() assert part == "" assert self.env["PATH_INFO"] == "" assert self.env["SCRIPT_NAME"] == "/foo/service"
def test_pop_path(self): self.env['PATH_INFO'] = '/foo/service' req = Request(self.env) part = req.pop_path() eq_(part, 'foo') eq_(self.env['PATH_INFO'], '/service') eq_(self.env['SCRIPT_NAME'], '/foo') part = req.pop_path() eq_(part, 'service') eq_(self.env['PATH_INFO'], '') eq_(self.env['SCRIPT_NAME'], '/foo/service') part = req.pop_path() eq_(part, '') eq_(self.env['PATH_INFO'], '') eq_(self.env['SCRIPT_NAME'], '/foo/service')
def tile_request(self, tile, auth): env = make_wsgi_env('', extra_environ={ 'mapproxy.authorize': auth, 'PATH_INFO': '/kml/' + tile }) req = Request(env) return kml_request(req)
def test_pop_path(self): self.env['PATH_INFO'] = '/foo/service' req = Request(self.env) part = req.pop_path() eq_(part, 'foo') eq_(self.env['PATH_INFO'], '/service') eq_(self.env['SCRIPT_NAME'], '/foo') part = req.pop_path() eq_(part, 'service') eq_(self.env['PATH_INFO'], '') eq_(self.env['SCRIPT_NAME'], '/foo/service') part = req.pop_path() eq_(part, '') eq_(self.env['PATH_INFO'], '') eq_(self.env['SCRIPT_NAME'], '/foo/service')
def test_pop_path(self): self.env["PATH_INFO"] = "/foo/service" req = Request(self.env) part = req.pop_path() eq_(part, "foo") eq_(self.env["PATH_INFO"], "/service") eq_(self.env["SCRIPT_NAME"], "/foo") part = req.pop_path() eq_(part, "service") eq_(self.env["PATH_INFO"], "") eq_(self.env["SCRIPT_NAME"], "/foo/service") part = req.pop_path() eq_(part, "") eq_(self.env["PATH_INFO"], "") eq_(self.env["SCRIPT_NAME"], "/foo/service")
def test_tms_request(self): env = {"PATH_INFO": "/tms/1.0.0/osm/5/2/3.png", "QUERY_STRING": ""} req = Request(env) tms = tile_request(req) assert isinstance(tms, TMSRequest) assert tms.tile == (2, 3, 5) assert tms.format == "png" assert tms.layer == "osm" assert tms.dimensions == {}
def test_maprequest_from_request(): env = { 'QUERY_STRING': 'layers=bar&bBOx=-90,-80,70.0,+80&format=image/png&'\ 'WIdth=100&heIGHT=200&LAyerS=foo' } req = WMSMapRequest(param=Request(env).args) assert req.params.bbox == (-90.0, -80.0, 70.0, 80.0) assert req.params.layers == ['bar', 'foo'] assert req.params.size == (100, 200)
def test_maprequest_from_request(): env = { "QUERY_STRING": "layers=bar&bBOx=-90,-80,70.0,+80&format=image/png&" "WIdth=100&heIGHT=200&LAyerS=foo" } req = WMSMapRequest(param=Request(env).args) assert req.params.bbox == (-90.0, -80.0, 70.0, 80.0) assert req.params.layers == ["bar", "foo"] assert req.params.size == (100, 200)
def test_tile_request(self): env = {"PATH_INFO": "/tiles/1.0.0/osm/5/2/3.png", "QUERY_STRING": ""} req = Request(env) tile_req = tile_request(req) assert isinstance(tile_req, TileRequest) assert tile_req.tile == (2, 3, 5) assert tile_req.origin == None assert tile_req.format == "png" assert tile_req.layer == "osm" assert tile_req.dimensions == {}
def test_tile_request_w_epsg(self): env = { "PATH_INFO": "/tiles/1.0.0/osm/EPSG4326/5/2/3.png", "QUERY_STRING": "" } req = Request(env) tile_req = tile_request(req) assert isinstance(tile_req, TileRequest) assert tile_req.tile == (2, 3, 5) assert tile_req.format == "png" assert tile_req.layer == "osm" assert tile_req.dimensions == {"_layer_spec": "EPSG4326"}
def test_tile_request_w_epsg(self): env = { 'PATH_INFO': '/tiles/1.0.0/osm/EPSG4326/5/2/3.png', 'QUERY_STRING': '', } req = Request(env) tile_req = tile_request(req) assert isinstance(tile_req, TileRequest) eq_(tile_req.tile, (2, 3, 5)) eq_(tile_req.format, 'png') eq_(tile_req.layer, 'osm') eq_(tile_req.dimensions, {'_layer_spec': 'EPSG4326'})
def test_tms_request(self): env = { 'PATH_INFO': '/tms/1.0.0/osm/5/2/3.png', 'QUERY_STRING': '', } req = Request(env) tms = tile_request(req) assert isinstance(tms, TMSRequest) eq_(tms.tile, (2, 3, 5)) eq_(tms.format, 'png') eq_(tms.layer, 'osm') eq_(tms.dimensions, {})
def test_tile_request_flipped_y(self): env = { 'PATH_INFO': '/tiles/1.0.0/osm/5/2/3.png', 'QUERY_STRING': 'origin=nw', } req = Request(env) tile_req = tile_request(req) assert isinstance(tile_req, TileRequest) eq_(tile_req.tile, (2, 3, 5)) # not jet flipped eq_(tile_req.origin, 'nw') eq_(tile_req.format, 'png') eq_(tile_req.layer, 'osm') eq_(tile_req.dimensions, {})
def test_tile_request(self): env = { 'PATH_INFO': '/tiles/1.0.0/osm/5/2/3.png', 'QUERY_STRING': '', } req = Request(env) tile_req = tile_request(req) assert isinstance(tile_req, TileRequest) eq_(tile_req.tile, (2, 3, 5)) eq_(tile_req.origin, None) eq_(tile_req.format, 'png') eq_(tile_req.layer, 'osm') eq_(tile_req.dimensions, tuple())
def setup(self): self.req = Request(self.env)
def map_request(self, layers, auth): env = make_wsgi_env(MAP_REQ + '&layers=' + layers, extra_environ={'mapproxy.authorize': auth}) req = Request(env) return wms_request(req)
def fi_request(self, layers, auth): env = make_wsgi_env(FI_REQ + '&layers=%s&query_layers=%s' % (layers, layers), extra_environ={'mapproxy.authorize': auth}) req = Request(env) return wms_request(req)
def test_query_string(self): self.env['QUERY_STRING'] = 'Foo=boo&baz=baa&fOO=bizz' req = Request(self.env) print(req.args['foo']) assert req.args.get_all('foo') == ['boo', 'bizz']
def test_query_string(self): self.env["QUERY_STRING"] = "Foo=boo&baz=baa&fOO=bizz" req = Request(self.env) print(req.args["foo"]) assert req.args.get_all("foo") == ["boo", "bizz"]
def test_host_url(self): req = Request(self.env) assert req.host_url == 'http://localhost:5050/'
def test_path(self): req = Request(self.env) assert req.path == '/service'
def test_query_string_encoding(self): env = {"QUERY_STRING": "foo=some%20special%20chars%20%26%20%3D"} req = Request(env) print(req.args["foo"]) assert req.args["foo"] == u"some special chars & ="