/[thuban]/trunk/thuban/test/test_save.py
ViewVC logotype

Diff of /trunk/thuban/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 1599 by bh, Mon Aug 18 12:45:28 2003 UTC
# Line 226  class SaveSessionTest(unittest.TestCase, Line 226  class SaveSessionTest(unittest.TestCase,
226          layer = RasterLayer("My RasterLayer", imgfile)          layer = RasterLayer("My RasterLayer", imgfile)
227          map.AddLayer(layer)          map.AddLayer(layer)
228    
229          filename = self.temp_file_name("save_singlemap.thuban")          filename = self.temp_file_name("%s.thuban" % self.id())
230          save_session(session, filename)          save_session(session, filename)
231          session.Destroy()          session.Destroy()
232    
# Line 242  class SaveSessionTest(unittest.TestCase, Line 242  class SaveSessionTest(unittest.TestCase,
242                               visible="true">                               visible="true">
243                  </rasterlayer>                  </rasterlayer>
244              </map>              </map>
245          </session>''' % os.path.join(os.path.dirname(__file__),          </session>''' % os.path.join(os.pardir, os.pardir, "Data", "iceland",
                                      os.pardir, "Data", "iceland",  
246                                       "island.tif")                                       "island.tif")
247          #print written_contents          #print written_contents
248          #print "********************************************"          #print "********************************************"
# Line 253  class SaveSessionTest(unittest.TestCase, Line 252  class SaveSessionTest(unittest.TestCase,
252          self.validate_data(written_contents)          self.validate_data(written_contents)
253    
254      def testClassifiedLayer(self):      def testClassifiedLayer(self):
255          """Save a session with a single map with a single layer          """Save a session with a single map with classifications"""
            with a classificaton.  
         """  
256          # deliberately put an apersand in the title :)          # deliberately put an apersand in the title :)
257          session = Session("single map&layer")          session = Session("Map with Classifications")
258          proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"])          proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"])
259          map = Map("Test Map", projection = proj)          map = Map("Test Map", projection = proj)
260          session.AddMap(map)          session.AddMap(map)
# Line 266  class SaveSessionTest(unittest.TestCase, Line 263  class SaveSessionTest(unittest.TestCase,
263                                 os.pardir, "Data", "iceland", "political.shp")                                 os.pardir, "Data", "iceland", "political.shp")
264          layer = Layer("My Layer", session.OpenShapefile(shpfile))          layer = Layer("My Layer", session.OpenShapefile(shpfile))
265          map.AddLayer(layer)          map.AddLayer(layer)
266            layer2 = Layer("My Layer", layer.ShapeStore())
267            map.AddLayer(layer2)
268    
269          clazz = layer.GetClassification()          clazz = layer.GetClassification()
270    
271          clazz.SetFieldInfo("AREA", None)          layer.SetClassificationColumn("AREA")
272    
273          clazz.AppendGroup(ClassGroupSingleton(42,          clazz.AppendGroup(ClassGroupSingleton(42, ClassGroupProperties(),
274                                             ClassGroupProperties(),                                                "single"))
275                                             "single"))          clazz.AppendGroup(ClassGroupSingleton("text", ClassGroupProperties(),
276          clazz.AppendGroup(ClassGroupSingleton("text",                                                "single-text"))
                                            ClassGroupProperties(),  
                                            "single-text"))  
277    
278          clazz.AppendGroup(ClassGroupRange((0, 42),          clazz.AppendGroup(ClassGroupRange((0, 42),
279                                             ClassGroupProperties(),                                             ClassGroupProperties(),
# Line 287  class SaveSessionTest(unittest.TestCase, Line 284  class SaveSessionTest(unittest.TestCase,
284          range.SetLabel("new-range")          range.SetLabel("new-range")
285          clazz.AppendGroup(range)          clazz.AppendGroup(range)
286    
287          filename = self.temp_file_name("save_singlemap.thuban")  
288            clazz = layer2.GetClassification()
289            layer2.SetClassificationColumn("POPYCOUN")
290    
291            # Classification with Latin 1 text
292            clazz.AppendGroup(ClassGroupSingleton('\xe4\xf6\xfc', # ae, oe, ue
293                                                  ClassGroupProperties(),
294                                                  '\xdcml\xe4uts')) # Uemlaeuts
295    
296    
297            filename = self.temp_file_name("%s.thuban" % self.id())
298          save_session(session, filename)          save_session(session, filename)
299    
300          file = open(filename)          file = open(filename)
# Line 295  class SaveSessionTest(unittest.TestCase, Line 302  class SaveSessionTest(unittest.TestCase,
302          file.close()          file.close()
303          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>
304          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
305          <session title="single map&amp;layer"          <session title="Map with Classifications"
306             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
307              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>
308              <map title="Test Map">              <map title="Test Map">
# Line 324  class SaveSessionTest(unittest.TestCase, Line 331  class SaveSessionTest(unittest.TestCase,
331                          </clrange>                          </clrange>
332                      </classification>                      </classification>
333                  </layer>                  </layer>
334                    <layer title="My Layer" shapestore="D1"
335                    fill="None" stroke="#000000" stroke_width="1" visible="true">
336                        <classification field="POPYCOUN" field_type="string">
337                            <clnull label="">
338                                <cldata fill="None" stroke="#000000" stroke_width="1"/>
339                            </clnull>
340                            <clpoint value="\xc3\xa4\xc3\xb6\xc3\xbc"
341                                 label="\xc3\x9cml\xc3\xa4uts">
342                                <cldata fill="None" stroke="#000000" stroke_width="1"/>
343                            </clpoint>
344                        </classification>
345                    </layer>
346              </map>              </map>
347          </session>'''          </session>'''
348    
# Line 361  class SaveSessionTest(unittest.TestCase, Line 380  class SaveSessionTest(unittest.TestCase,
380              <filetable id="D1" filename="%s" filetype="DBF" title="political"/>              <filetable id="D1" filename="%s" filetype="DBF" title="political"/>
381          </session>'''          </session>'''
382    
383          expected_contents = expected_template % dbffile          expected_contents = (expected_template
384                                 % os.path.join(os.pardir, os.pardir, "Data",
385                                                "iceland", "political.dbf"))
386          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
387    
388      def test_joined_table(self):      def test_joined_table(self):

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26