class TestWMSMapRequestParams(object): def setup(self): self.m = WMSMapRequestParams( url_decode('layers=bar&bBOx=-90,-80,70.0, 80&format=image/png' '&WIdth=100&heIGHT=200&LAyerS=foo&srs=EPSG%3A0815')) def test_empty(self): m = WMSMapRequestParams() assert m.query_string == '' def test_size(self): assert self.m.size == (100, 200) self.m.size = (250, 350) assert self.m.size == (250, 350) assert self.m['width'] == '250' assert self.m['height'] == '350' del self.m['width'] assert self.m.size == None def test_format(self): assert self.m.format == 'png' assert self.m.format_mime_type == 'image/png' self.m['transparent'] = 'True' assert self.m.format == 'png' def test_bbox(self): assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) del self.m['bbox'] assert self.m.bbox is None self.m.bbox = (-90.0, -80.0, 70.0, 80.0) assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) self.m.bbox = '0.0, -40.0, 70.0, 80.0' assert self.m.bbox == (0.0, -40.0, 70.0, 80.0) self.m.bbox = None assert self.m.bbox is None def test_transparent(self): assert self.m.transparent == False self.m['transparent'] = 'trUe' assert self.m.transparent == True def test_transparent_bool(self): self.m['transparent'] = True assert self.m['transparent'] == 'True' def test_bgcolor(self): assert self.m.bgcolor == '#ffffff' self.m['bgcolor'] = '0x42cafe' assert self.m.bgcolor == '#42cafe' def test_srs(self): print(self.m.srs) assert self.m.srs == 'EPSG:0815' del self.m['srs'] assert self.m.srs is None self.m.srs = SRS('EPSG:4326') assert self.m.srs == 'EPSG:4326' def test_layers(self): assert list(self.m.layers) == ['bar', 'foo'] def test_query_string(self): print(self.m.query_string) assert_query_eq( self.m.query_string, 'layers=bar,foo&WIdth=100&bBOx=-90,-80,70.0,+80' '&format=image%2Fpng&srs=EPSG%3A0815&heIGHT=200') def test_get(self): assert self.m.get('LAYERS') == 'bar' assert self.m.get('width', type_func=int) == 100 def test_set(self): self.m.set('Layers', 'baz', append=True) assert self.m.get('LAYERS') == 'bar' self.m.set('Layers', 'baz') assert self.m.get('LAYERS') == 'baz' def test_attr_access(self): assert self.m['width'] == '100' assert self.m['height'] == '200' try: self.m.invalid except AttributeError: pass else: assert False def test_with_defaults(self): orig_req = WMSMapRequestParams(param=dict(layers='baz')) new_req = self.m.with_defaults(orig_req) assert new_req is not self.m assert self.m.get('LayErs') == 'bar' assert new_req.get('LAyers') == 'baz' assert new_req.size == (100, 200)
class TestWMSMapRequestParams(object): def setup(self): self.m = WMSMapRequestParams( url_decode("layers=bar&bBOx=-90,-80,70.0, 80&format=image/png" "&WIdth=100&heIGHT=200&LAyerS=foo&srs=EPSG%3A0815")) def test_empty(self): m = WMSMapRequestParams() assert m.query_string == "" def test_size(self): assert self.m.size == (100, 200) self.m.size = (250, 350) assert self.m.size == (250, 350) assert self.m["width"] == "250" assert self.m["height"] == "350" del self.m["width"] assert self.m.size == None def test_format(self): assert self.m.format == "png" assert self.m.format_mime_type == "image/png" self.m["transparent"] = "True" assert self.m.format == "png" def test_bbox(self): assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) del self.m["bbox"] assert self.m.bbox is None self.m.bbox = (-90.0, -80.0, 70.0, 80.0) assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) self.m.bbox = "0.0, -40.0, 70.0, 80.0" assert self.m.bbox == (0.0, -40.0, 70.0, 80.0) self.m.bbox = None assert self.m.bbox is None def test_transparent(self): assert self.m.transparent == False self.m["transparent"] = "trUe" assert self.m.transparent == True def test_transparent_bool(self): self.m["transparent"] = True assert self.m["transparent"] == "True" def test_bgcolor(self): assert self.m.bgcolor == "#ffffff" self.m["bgcolor"] = "0x42cafe" assert self.m.bgcolor == "#42cafe" def test_srs(self): print(self.m.srs) assert self.m.srs == "EPSG:0815" del self.m["srs"] assert self.m.srs is None self.m.srs = SRS("EPSG:4326") assert self.m.srs == "EPSG:4326" def test_layers(self): assert list(self.m.layers) == ["bar", "foo"] def test_query_string(self): assert_query_eq( self.m.query_string, "layers=bar,foo&WIdth=100&bBOx=-90,-80,70.0,+80" "&format=image%2Fpng&srs=EPSG%3A0815&heIGHT=200", ) def test_query_string_encoding(self): m = WMSMapRequestParams() m.layers = ["layer with whitespace", u"layer with ümlauts"] assert (m.query_string == "layers=layer%20with%20whitespace,layer%20with%20%C3%BCmlauts") def test_get(self): assert self.m.get("LAYERS") == "bar" assert self.m.get("width", type_func=int) == 100 def test_set(self): self.m.set("Layers", "baz", append=True) assert self.m.get("LAYERS") == "bar" self.m.set("Layers", "baz") assert self.m.get("LAYERS") == "baz" def test_attr_access(self): assert self.m["width"] == "100" assert self.m["height"] == "200" try: self.m.invalid except AttributeError: pass else: assert False def test_with_defaults(self): orig_req = WMSMapRequestParams(param=dict(layers="baz")) new_req = self.m.with_defaults(orig_req) assert new_req is not self.m assert self.m.get("LayErs") == "bar" assert new_req.get("LAyers") == "baz" assert new_req.size == (100, 200)
class TestWMSMapRequestParams(object): def setup(self): self.m = WMSMapRequestParams(url_decode('layers=bar&bBOx=-90,-80,70.0, 80&format=image/png' '&WIdth=100&heIGHT=200&LAyerS=foo&srs=EPSG%3A0815')) def test_empty(self): m = WMSMapRequestParams() assert m.query_string == '' def test_size(self): assert self.m.size == (100, 200) self.m.size = (250, 350) assert self.m.size == (250, 350) assert self.m['width'] == '250' assert self.m['height'] == '350' del self.m['width'] assert self.m.size == None def test_format(self): assert self.m.format == 'png' assert self.m.format_mime_type == 'image/png' self.m['transparent'] = 'True' assert self.m.format == 'png' def test_bbox(self): assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) del self.m['bbox'] assert self.m.bbox is None self.m.bbox = (-90.0, -80.0, 70.0, 80.0) assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) self.m.bbox = '0.0, -40.0, 70.0, 80.0' assert self.m.bbox == (0.0, -40.0, 70.0, 80.0) self.m.bbox = None assert self.m.bbox is None def test_transparent(self): assert self.m.transparent == False self.m['transparent'] = 'trUe' assert self.m.transparent == True def test_transparent_bool(self): self.m['transparent'] = True assert self.m['transparent'] == 'True' def test_bgcolor(self): assert self.m.bgcolor == '#ffffff' self.m['bgcolor'] = '0x42cafe' assert self.m.bgcolor == '#42cafe' def test_srs(self): print(self.m.srs) assert self.m.srs == 'EPSG:0815' del self.m['srs'] assert self.m.srs is None self.m.srs = SRS('EPSG:4326') assert self.m.srs == 'EPSG:4326' def test_layers(self): assert list(self.m.layers) == ['bar', 'foo'] def test_query_string(self): print(self.m.query_string) assert_query_eq(self.m.query_string, 'layers=bar,foo&WIdth=100&bBOx=-90,-80,70.0,+80' '&format=image%2Fpng&srs=EPSG%3A0815&heIGHT=200') def test_get(self): assert self.m.get('LAYERS') == 'bar' assert self.m.get('width', type_func=int) == 100 def test_set(self): self.m.set('Layers', 'baz', append=True) assert self.m.get('LAYERS') == 'bar' self.m.set('Layers', 'baz') assert self.m.get('LAYERS') == 'baz' def test_attr_access(self): assert self.m['width'] == '100' assert self.m['height'] == '200' try: self.m.invalid except AttributeError: pass else: assert False def test_with_defaults(self): orig_req = WMSMapRequestParams(param=dict(layers='baz')) new_req = self.m.with_defaults(orig_req) assert new_req is not self.m assert self.m.get('LayErs') == 'bar' assert new_req.get('LAyers') == 'baz' assert new_req.size == (100, 200)
class TestWMSMapRequestParams(object): def setup(self): self.m = WMSMapRequestParams( url_decode( "layers=bar&bBOx=-90,-80,70.0, 80&format=image/png" "&WIdth=100&heIGHT=200&LAyerS=foo&srs=EPSG%3A0815" ) ) def test_empty(self): m = WMSMapRequestParams() assert m.query_string == "" def test_size(self): assert self.m.size == (100, 200) self.m.size = (250, 350) assert self.m.size == (250, 350) assert self.m["width"] == "250" assert self.m["height"] == "350" del self.m["width"] assert self.m.size == None def test_format(self): assert self.m.format == "png" assert self.m.format_mime_type == "image/png" self.m["transparent"] = "True" assert self.m.format == "png" def test_bbox(self): assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) del self.m["bbox"] assert self.m.bbox is None self.m.bbox = (-90.0, -80.0, 70.0, 80.0) assert self.m.bbox == (-90.0, -80.0, 70.0, 80.0) self.m.bbox = "0.0, -40.0, 70.0, 80.0" assert self.m.bbox == (0.0, -40.0, 70.0, 80.0) self.m.bbox = None assert self.m.bbox is None def test_transparent(self): assert self.m.transparent == False self.m["transparent"] = "trUe" assert self.m.transparent == True def test_transparent_bool(self): self.m["transparent"] = True assert self.m["transparent"] == "True" def test_bgcolor(self): assert self.m.bgcolor == "#ffffff" self.m["bgcolor"] = "0x42cafe" assert self.m.bgcolor == "#42cafe" def test_srs(self): print(self.m.srs) assert self.m.srs == "EPSG:0815" del self.m["srs"] assert self.m.srs is None self.m.srs = SRS("EPSG:4326") assert self.m.srs == "EPSG:4326" def test_layers(self): assert list(self.m.layers) == ["bar", "foo"] def test_query_string(self): assert_query_eq( self.m.query_string, "layers=bar,foo&WIdth=100&bBOx=-90,-80,70.0,+80" "&format=image%2Fpng&srs=EPSG%3A0815&heIGHT=200", ) def test_query_string_encoding(self): m = WMSMapRequestParams() m.layers = ["layer with whitespace", u"layer with ümlauts"] eq_(m.query_string, "layers=layer%20with%20whitespace,layer%20with%20%C3%BCmlauts") def test_get(self): assert self.m.get("LAYERS") == "bar" assert self.m.get("width", type_func=int) == 100 def test_set(self): self.m.set("Layers", "baz", append=True) assert self.m.get("LAYERS") == "bar" self.m.set("Layers", "baz") assert self.m.get("LAYERS") == "baz" def test_attr_access(self): assert self.m["width"] == "100" assert self.m["height"] == "200" try: self.m.invalid except AttributeError: pass else: assert False def test_with_defaults(self): orig_req = WMSMapRequestParams(param=dict(layers="baz")) new_req = self.m.with_defaults(orig_req) assert new_req is not self.m assert self.m.get("LayErs") == "bar" assert new_req.get("LAyers") == "baz" assert new_req.size == (100, 200)