示例#1
0
    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")
示例#2
0
    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')
示例#3
0
    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')
示例#4
0
 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")
示例#5
0
    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")
示例#6
0
    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')
示例#7
0
 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")
示例#8
0
    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)
示例#9
0
    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')
示例#10
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)
示例#11
0
    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)
示例#12
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)
示例#13
0
    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'))
示例#14
0
    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'))
示例#15
0
文件: test_copy.py 项目: Mappy/pycnik
    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')
示例#16
0
    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')
示例#17
0
 def setup(self):
     self.xml = parse_resource('sample.py')
示例#18
0
 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)
示例#19
0
 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)
示例#20
0
 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')
示例#21
0
 def setup(self):
     "set up test fixtures"
     self.xml = parse_resource('sample.py')
示例#22
0
    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)
示例#23
0
 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')
示例#24
0
 def setup(self):
     "set up test fixtures"
     self.xml = parse_resource('metawriter.py')
示例#25
0
    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)
示例#26
0
 def setup(self):
     "set up test fixtures"
     self.xml = parse_resource("sample.py")