/[thuban]/branches/WIP-pyshapelib-bramz/test/test_save.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/test_save.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1375 by bh, Tue Jul 8 10:53:05 2003 UTC revision 1417 by bh, Tue Jul 15 08:43:53 2003 UTC
# Line 253  class SaveSessionTest(unittest.TestCase, Line 253  class SaveSessionTest(unittest.TestCase,
253          self.validate_data(written_contents)          self.validate_data(written_contents)
254    
255      def testClassifiedLayer(self):      def testClassifiedLayer(self):
256          """Save a session with a single map with a single layer          """Save a session with a single map with classifications"""
            with a classificaton.  
         """  
257          # deliberately put an apersand in the title :)          # deliberately put an apersand in the title :)
258          session = Session("single map&layer")          session = Session("Map with Classifications")
259          proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"])          proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"])
260          map = Map("Test Map", projection = proj)          map = Map("Test Map", projection = proj)
261          session.AddMap(map)          session.AddMap(map)
# Line 266  class SaveSessionTest(unittest.TestCase, Line 264  class SaveSessionTest(unittest.TestCase,
264                                 os.pardir, "Data", "iceland", "political.shp")                                 os.pardir, "Data", "iceland", "political.shp")
265          layer = Layer("My Layer", session.OpenShapefile(shpfile))          layer = Layer("My Layer", session.OpenShapefile(shpfile))
266          map.AddLayer(layer)          map.AddLayer(layer)
267            layer2 = Layer("My Layer", layer.ShapeStore())
268            map.AddLayer(layer2)
269    
270          clazz = layer.GetClassification()          clazz = layer.GetClassification()
271    
272          clazz.SetFieldInfo("AREA", None)          clazz.SetFieldInfo("AREA", None)
273    
274          clazz.AppendGroup(ClassGroupSingleton(42,          clazz.AppendGroup(ClassGroupSingleton(42, ClassGroupProperties(),
275                                             ClassGroupProperties(),                                                "single"))
276                                             "single"))          clazz.AppendGroup(ClassGroupSingleton("text", ClassGroupProperties(),
277          clazz.AppendGroup(ClassGroupSingleton("text",                                                "single-text"))
                                            ClassGroupProperties(),  
                                            "single-text"))  
278    
279          clazz.AppendGroup(ClassGroupRange((0, 42),          clazz.AppendGroup(ClassGroupRange((0, 42),
280                                             ClassGroupProperties(),                                             ClassGroupProperties(),
# Line 287  class SaveSessionTest(unittest.TestCase, Line 285  class SaveSessionTest(unittest.TestCase,
285          range.SetLabel("new-range")          range.SetLabel("new-range")
286          clazz.AppendGroup(range)          clazz.AppendGroup(range)
287    
288          filename = self.temp_file_name("save_singlemap.thuban")  
289            clazz = layer2.GetClassification()
290            clazz.SetFieldInfo("POPYCOUN", None)
291    
292            # Classification with Latin 1 text
293            clazz.AppendGroup(ClassGroupSingleton('\xe4\xf6\xfc', # ae, oe, ue
294                                                  ClassGroupProperties(),
295                                                  '\xdcml\xe4uts')) # Uemlaeuts
296    
297    
298            filename = self.temp_file_name("%s.thuban" % self.id())
299          save_session(session, filename)          save_session(session, filename)
300    
301          file = open(filename)          file = open(filename)
# Line 295  class SaveSessionTest(unittest.TestCase, Line 303  class SaveSessionTest(unittest.TestCase,
303          file.close()          file.close()
304          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>
305          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
306          <session title="single map&amp;layer"          <session title="Map with Classifications"
307             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
308              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>
309              <map title="Test Map">              <map title="Test Map">
# Line 324  class SaveSessionTest(unittest.TestCase, Line 332  class SaveSessionTest(unittest.TestCase,
332                          </clrange>                          </clrange>
333                      </classification>                      </classification>
334                  </layer>                  </layer>
335                    <layer title="My Layer" shapestore="D1"
336                    fill="None" stroke="#000000" stroke_width="1" visible="true">
337                        <classification field="POPYCOUN" field_type="string">
338                            <clnull label="">
339                                <cldata fill="None" stroke="#000000" stroke_width="1"/>
340                            </clnull>
341                            <clpoint value="\xc3\xa4\xc3\xb6\xc3\xbc"
342                                 label="\xc3\x9cml\xc3\xa4uts">
343                                <cldata fill="None" stroke="#000000" stroke_width="1"/>
344                            </clpoint>
345                        </classification>
346                    </layer>
347              </map>              </map>
348          </session>'''          </session>'''
349    

Legend:
Removed from v.1375  
changed lines
  Added in v.1417

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26