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

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

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

revision 1247 by bh, Thu Jun 19 19:53:36 2003 UTC revision 1257 by bh, Fri Jun 20 12:22:25 2003 UTC
# Line 17  Maintenance of the test cases: Line 17  Maintenance of the test cases:
17    
18  When during a development period the file format is changed with respect  When during a development period the file format is changed with respect
19  to the last released version for the first, the tests here should be  to the last released version for the first, the tests here should be
20  copied to the version specific test file.  copied to the version specific test file. The round-trip tests which
21    save the session again and compare the XML files should not be copied
22    over as they only make sense here to make sure th that the files checked
23    here are actually ones that may have been written by the current thuban
24    version.
25  """  """
26    
27  __version__ = "$Revision$"  __version__ = "$Revision$"
# Line 30  import unittest Line 34  import unittest
34  import support  import support
35  support.initthuban()  support.initthuban()
36    
37    from xmlsupport import sax_eventlist
38    from Thuban.Model.save import save_session
39  from Thuban.Model.load import load_session, parse_color  from Thuban.Model.load import load_session, parse_color
40  from Thuban.Model.color import Color  from Thuban.Model.color import Color
41  from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\  from Thuban.Model.classification import ClassGroupProperties, ClassGroupRange,\
# Line 70  class LoadSessionTest(support.FileLoadTe Line 76  class LoadSessionTest(support.FileLoadTe
76              self.session.Destroy()              self.session.Destroy()
77          self.session = None          self.session = None
78    
79        def check_format(self):
80            """Check whether the file we loaded from matches the one that
81            would be written. Call this from each test case after loading
82            the session
83            """
84            filename = self.temp_file_name(self.id() + ".roundtrip.thuban")
85            save_session(self.session, filename)
86            el1 = sax_eventlist(filename = filename)
87            el2 = sax_eventlist(filename = self.filename())
88            self.assertEquals(el1, el2)
89    
90    
91  class ClassificationTest(LoadSessionTest):  class ClassificationTest(LoadSessionTest):
92    
# Line 129  class TestSingleLayer(LoadSessionTest): Line 146  class TestSingleLayer(LoadSessionTest):
146  <!DOCTYPE session SYSTEM "thuban.dtd">  <!DOCTYPE session SYSTEM "thuban.dtd">
147  <session title="single map&amp;layer">  <session title="single map&amp;layer">
148          <map title="Test Map">          <map title="Test Map">
149                  <projection>                  <projection name="Unknown">
150                          <parameter value="zone=26"/>                          <parameter value="zone=26"/>
151                          <parameter value="proj=utm"/>                          <parameter value="proj=utm"/>
152                          <parameter value="ellps=clrk66"/>                          <parameter value="ellps=clrk66"/>
153                  </projection>                  </projection>
154                  <layer title="My Layer" stroke_width="1" fill="None"                  <layer title="My Layer" stroke_width="1" fill="None"
155                      filename="../../Data/iceland/political.shp"                      filename="../../Data/iceland/political.shp"
156                      stroke="#000000"/>                      stroke="#000000" visible="true"/>
157          </map>          </map>
158  </session>  </session>
159  '''  '''
# Line 174  class TestSingleLayer(LoadSessionTest): Line 191  class TestSingleLayer(LoadSessionTest):
191          eq(layer.GetClassification().GetDefaultLineColor().hex(), "#000000")          eq(layer.GetClassification().GetDefaultLineColor().hex(), "#000000")
192          eq(layer.Visible(), True)          eq(layer.Visible(), True)
193    
194            self.check_format()
195    
196          self.session.Destroy()          self.session.Destroy()
197          self.session = None          self.session = None
198    
# Line 185  class TestLayerVisibility(LoadSessionTes Line 204  class TestLayerVisibility(LoadSessionTes
204  <!DOCTYPE session SYSTEM "thuban.dtd">  <!DOCTYPE session SYSTEM "thuban.dtd">
205  <session title="single map&amp;layer">  <session title="single map&amp;layer">
206          <map title="Test Map">          <map title="Test Map">
207                  <projection>                  <projection name="Unknown">
208                          <parameter value="zone=26"/>                          <parameter value="zone=26"/>
209                          <parameter value="proj=utm"/>                          <parameter value="proj=utm"/>
210                          <parameter value="ellps=clrk66"/>                          <parameter value="ellps=clrk66"/>
# Line 212  class TestLayerVisibility(LoadSessionTes Line 231  class TestLayerVisibility(LoadSessionTes
231    
232          eq(layer.Visible(), False)          eq(layer.Visible(), False)
233    
234            self.check_format()
235    
236    
237  class TestClassification(ClassificationTest):  class TestClassification(ClassificationTest):
# Line 303  class TestLabels(ClassificationTest): Line 322  class TestLabels(ClassificationTest):
322  <!DOCTYPE session SYSTEM "thuban.dtd">  <!DOCTYPE session SYSTEM "thuban.dtd">
323  <session title="single map&amp;layer">  <session title="single map&amp;layer">
324          <map title="Test Map">          <map title="Test Map">
325                  <projection>                  <projection name="Unknown">
326                          <parameter value="zone=26"/>                          <parameter value="zone=26"/>
327                          <parameter value="proj=utm"/>                          <parameter value="proj=utm"/>
328                          <parameter value="ellps=clrk66"/>                          <parameter value="ellps=clrk66"/>
329                  </projection>                  </projection>
330                  <layer title="My Layer" stroke_width="1" fill="None"                  <layer title="My Layer" stroke_width="1" fill="None"
331                      filename="../../Data/iceland/political.shp"                      filename="../../Data/iceland/political.shp"
332                      stroke="#000000">                      stroke="#000000" visible="true">
333              <classification field="POPYREG" field_type="string">              <classification field="POPYREG" field_type="string">
334                  <clnull label="hallo">                  <clnull label="hallo">
335                      <cldata stroke="#000000" stroke_width="1" fill="None"/>                      <cldata stroke="#000000" stroke_width="1" fill="None"/>
# Line 339  class TestLabels(ClassificationTest): Line 358  class TestLabels(ClassificationTest):
358                              ("#000000", 2, "None"))])]                              ("#000000", 2, "None"))])]
359    
360          self.TestLayers(map.Layers(), expected)          self.TestLayers(map.Layers(), expected)
361            self.check_format()
362    
363    
364  class TestLayerProjection(LoadSessionTest):  class TestLayerProjection(LoadSessionTest):
# Line 348  class TestLayerProjection(LoadSessionTes Line 368  class TestLayerProjection(LoadSessionTes
368  <!DOCTYPE session SYSTEM "thuban.dtd">  <!DOCTYPE session SYSTEM "thuban.dtd">
369  <session title="single map&amp;layer">  <session title="single map&amp;layer">
370          <map title="Test Map">          <map title="Test Map">
371                  <projection>                  <projection name="Unknown">
372                          <parameter value="zone=26"/>                          <parameter value="zone=26"/>
373                          <parameter value="proj=utm"/>                          <parameter value="proj=utm"/>
374                          <parameter value="ellps=clrk66"/>                          <parameter value="ellps=clrk66"/>
375                  </projection>                  </projection>
376                  <layer title="My Layer" stroke_width="1" fill="None"                  <layer title="My Layer" stroke_width="1" fill="None"
377                      filename="../../Data/iceland/political.shp"                      filename="../../Data/iceland/political.shp"
378                      stroke="#000000">                      stroke="#000000" visible="true">
379                      <projection name="hello">                      <projection name="hello">
380                          <parameter value="zone=13"/>                          <parameter value="zone=13"/>
381                          <parameter value="proj=tmerc"/>                          <parameter value="proj=tmerc"/>
# Line 372  class TestLayerProjection(LoadSessionTes Line 392  class TestLayerProjection(LoadSessionTes
392          </layer>          </layer>
393                  <layer title="My Layer" stroke_width="1" fill="None"                  <layer title="My Layer" stroke_width="1" fill="None"
394                      filename="../../Data/iceland/political.shp"                      filename="../../Data/iceland/political.shp"
395                      stroke="#000000">                      stroke="#000000" visible="true">
396                      <projection>                      <projection name="Unknown">
397                          <parameter value="proj=lcc"/>                          <parameter value="proj=lcc"/>
398                          <parameter value="ellps=clrk66"/>                          <parameter value="ellps=clrk66"/>
399                      </projection>                      </projection>
# Line 409  class TestLayerProjection(LoadSessionTes Line 429  class TestLayerProjection(LoadSessionTes
429          eq(proj.GetParameter("proj"), "lcc")          eq(proj.GetParameter("proj"), "lcc")
430          eq(proj.GetParameter("ellps"), "clrk66")          eq(proj.GetParameter("ellps"), "clrk66")
431    
432            self.check_format()
433    
434    
435  class TestRasterLayer(LoadSessionTest):  class TestRasterLayer(LoadSessionTest):
436    
# Line 443  class TestRasterLayer(LoadSessionTest): Line 465  class TestRasterLayer(LoadSessionTest):
465                                                       os.pardir, os.pardir,                                                       os.pardir, os.pardir,
466                                                       "Data", "iceland",                                                       "Data", "iceland",
467                                                       "island.tif")))                                                       "island.tif")))
468            self.check_format()
469    
470  if __name__ == "__main__":  if __name__ == "__main__":
471      unittest.main()      unittest.main()

Legend:
Removed from v.1247  
changed lines
  Added in v.1257

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26