def test_single_style(self): '''Should serialize a single style in a single layer''' xml = parse_resource('sample.py') assert_equal(len(xml.xpath('/Map/Layer/StyleName')), 1) style = xml.xpath('/Map/Layer/StyleName')[0] assert_equal(style.text, "world_My Style")
def test_layers_ordering(self): '''Should parse a many layer tags in order''' xml = parse_resource('natural.py') layers = xml.xpath('/Map/Layer') assert_equal(len(layers), 2) assert_equal(layers[0].attrib['name'], 'natural_earth') assert_equal(layers[1].attrib['name'], 'country boundaries')
def test_preserve_order(self): '''Copy should preserve layer ordering''' xml = parse_resource('copy_all.py') assert_equal(len(xml.xpath('/Map')), 1) layers = xml.xpath('/Map/Layer') assert_equal(layers[0].attrib['name'], 'natural_earth') assert_equal(layers[1].attrib['name'], 'country boundaries')
def test_single_layer_tag(self): '''Should parse a single layer tag''' xml = parse_resource('sample.py') layers = xml.xpath('/Map/Layer') assert_equal(len(layers), 1) assert_equal(layers[0].attrib['name'], 'world') assert_equal(layers[0].attrib['srs'], "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
def test_many_layer_single_style(self): '''Should serialize a single style in a many layers template''' xml = parse_resource('natural.py') path = '/Map/Layer[@name="natural_earth"]/StyleName' assert_equal(len(xml.xpath(path)), 1) style = xml.xpath(path)[0] assert_equal(style.text, "natural_earth_default")
def test_copy_list(self): '''Should copy a list of feature''' xml = parse_resource('copy_list.py') assert_equal(len(xml.xpath('/Map')), 1) assert_equal(len(xml.xpath('/Map/Layer')), 1) assert_equal(len(xml.xpath('/Map/Layer[@name="natural_earth"]')), 1) assert_equal(len(xml.xpath('/Map/Layer[@name="country boundaries"]')), 0)
def test_copy_exclude(self): '''Should not copy excluded feature list''' xml = parse_resource('copy_exclude.py') assert_equal(len(xml.xpath('/Map')), 1) assert_equal(len(xml.xpath('/Map/Layer')), 1) assert_equal(len(xml.xpath('/Map/Layer[@name="natural_earth"]')), 0) assert_equal(len(xml.xpath('/Map/Layer[@name="country boundaries"]')), 1)
def test_many_layer_tags(self): '''Should parse a many layer tags''' xml = parse_resource('natural.py') assert_equal(len(xml.xpath('/Map/Layer')), 2) natural_earth = xml.xpath('/Map/Layer[@name="natural_earth"]')[0] assert_equal(natural_earth.attrib['name'], 'natural_earth') assert_is_not_none(etree.SubElement(natural_earth, 'datasource')) boundaries = xml.xpath('/Map/Layer[@name="country boundaries"]')[0] assert_equal(boundaries.attrib['name'], 'country boundaries') assert_is_not_none(etree.SubElement(boundaries, 'datasource'))
def test_override(self): '''Copy should allow standard overriding''' xml = parse_resource('copy_all.py') node = xml.xpath('/Map')[0] assert_equal(node.attrib['background-color'], 'steelblue') assert_equal(node.attrib['srs'], "+init=epsg:4326") from lxml import etree print etree.tostring(xml, pretty_print=True) nodes = xml.xpath('/Map/Style[@name="natural_earth_default"]/Rule') assert_equal(len(nodes), 2) for node in nodes: if len(node.xpath('RasterSymbolizer')[0].attrib) == 2: assert_equal(node.xpath('RasterSymbolizer')[0].attrib['scaling'], 'fast') else: assert_equal(node.xpath('RasterSymbolizer')[0].attrib['scaling'], 'bilinear')
def test_override(self): '''Copy should allow standard overriding''' xml = parse_resource('copy_all.py') node = xml.xpath('/Map')[0] assert_equal(node.attrib['background-color'], 'steelblue') assert_equal(node.attrib['srs'], "+init=epsg:4326") from lxml import etree print etree.tostring(xml, pretty_print=True) nodes = xml.xpath('/Map/Style[@name="natural_earth_default"]/Rule') assert_equal(len(nodes), 2) for node in nodes: if len(node.xpath('RasterSymbolizer')[0].attrib) == 2: assert_equal( node.xpath('RasterSymbolizer')[0].attrib['scaling'], 'fast') else: assert_equal( node.xpath('RasterSymbolizer')[0].attrib['scaling'], 'bilinear')
def setup(self): self.xml = parse_resource('sample.py')
def test_same_symbolizer_inheritance(self): '''Should inherite same symbolizer in a single style''' xml = parse_resource('natural.py') assert_equal(len(xml.xpath('/Map/Style[@name="country boundaries_green"]/Rule[2]/LineSymbolizer')), 2) assert_equal(len(xml.xpath('/Map/Style[@name="country boundaries_green"]/Rule[1]/LineSymbolizer')), 2)
def test_linePatternSymbolizer_in_style(self): '''Should serialize linePatternSymbolizer''' xml = parse_resource('natural.py') assert_equal(len(xml.xpath('/Map/Style[@name="country boundaries_blue"]/Rule/LinePatternSymbolizer')), 2)
def test_layer_attribute(self): '''Should get layer attributes''' xml = parse_resource('natural.py') layers = xml.xpath('/Map/Layer') assert_equal(len(layers[1].attrib), 3) assert_equal(layers[1].attrib['buffer-size'], '0')
def setup(self): "set up test fixtures" self.xml = parse_resource('sample.py')
def test_copy_all(self): '''Should copy all features''' xml = parse_resource('copy_all.py') assert_equal(len(xml.xpath('/Map')), 1) assert_equal(len(xml.xpath('/Map/Layer')), 2)
def setup(self): "set up test fixtures" self.xml = parse_resource('metawriter.py')
def setup(self): "set up test fixtures" self.xml = parse_resource("sample.py")