/[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 1646 by bh, Mon Aug 25 13:43:56 2003 UTC revision 1683 by bh, Thu Aug 28 15:20:57 2003 UTC
# Line 82  class LoadSessionTest(support.FileLoadTe Line 82  class LoadSessionTest(support.FileLoadTe
82          self.session = None          self.session = None
83    
84    
85      dtd = "http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"      dtd = "http://thuban.intevation.org/dtds/thuban-0.9.dtd"
86      thubanids = [((dtd, n), (None, "id")) for n in      thubanids = [((dtd, n), (None, "id")) for n in
87                   ["fileshapesource", "filetable", "jointable",                   ["fileshapesource", "filetable", "jointable",
88                    "derivedshapesource"]]                    "derivedshapesource"]]
# Line 92  class LoadSessionTest(support.FileLoadTe Line 92  class LoadSessionTest(support.FileLoadTe
92                       ("jointable", "right"),                       ("jointable", "right"),
93                       ("derivedshapesource", "table"),                       ("derivedshapesource", "table"),
94                       ("derivedshapesource", "shapesource")]]                       ("derivedshapesource", "shapesource")]]
95        filenames = [((dtd, n), (None, m)) for n, m in
96                     [("fileshapesource", "filename"),
97                      ("rasterlayer", "filename"),
98                      ("filetable", "filename")]]
99      del n, m, dtd      del n, m, dtd
100    
101      def check_format(self):      def check_format(self):
# Line 102  class LoadSessionTest(support.FileLoadTe Line 106  class LoadSessionTest(support.FileLoadTe
106          filename = self.temp_file_name(self.id() + ".roundtrip.thuban")          filename = self.temp_file_name(self.id() + ".roundtrip.thuban")
107          save_session(self.session, filename)          save_session(self.session, filename)
108          el1 = sax_eventlist(filename = filename, ids = self.thubanids,          el1 = sax_eventlist(filename = filename, ids = self.thubanids,
109                              idrefs = self.thubanidrefs)                              idrefs = self.thubanidrefs,
110                                filenames = self.filenames)
111          el2 = sax_eventlist(filename = self.filename(), ids = self.thubanids,          el2 = sax_eventlist(filename = self.filename(), ids = self.thubanids,
112                              idrefs = self.thubanidrefs)                              idrefs = self.thubanidrefs,
113                                filenames = self.filenames)
114          if 0:          if 0:
115              for a, b in zip(el1, el2):              for a, b in zip(el1, el2):
116                  print a != b and "***************" or ""                  print a != b and "***************" or ""
# Line 170  class TestSingleLayer(LoadSessionTest): Line 176  class TestSingleLayer(LoadSessionTest):
176      file_contents = '''\      file_contents = '''\
177  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
178  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
179  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
180          title="single map&amp;layer">          title="single map&amp;layer">
181      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
182          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
# Line 231  class TestLayerVisibility(LoadSessionTes Line 237  class TestLayerVisibility(LoadSessionTes
237      file_contents = '''\      file_contents = '''\
238  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
239  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
240  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
241          title="single map&amp;layer">          title="single map&amp;layer">
242      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
243          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
# Line 356  class TestLabels(ClassificationTest): Line 362  class TestLabels(ClassificationTest):
362      file_contents = '''\      file_contents = '''\
363  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
364  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
365  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
366          title="single map&amp;layer">          title="single map&amp;layer">
367      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
368          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
# Line 404  class TestLayerProjection(LoadSessionTes Line 410  class TestLayerProjection(LoadSessionTes
410      file_contents = '''\      file_contents = '''\
411  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
412  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
413  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
414          title="single map&amp;layer">          title="single map&amp;layer">
415      <fileshapesource filetype="shapefile" id="D2"      <fileshapesource filetype="shapefile" id="D2"
416          filename="../../Data/iceland/roads-line.shp"/>          filename="../../Data/iceland/roads-line.shp"/>
# Line 478  class TestRasterLayer(LoadSessionTest): Line 484  class TestRasterLayer(LoadSessionTest):
484      file_contents = '''\      file_contents = '''\
485  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
486  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
487  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
488          title="single map&amp;layer">          title="single map&amp;layer">
489      <map title="Test Map">      <map title="Test Map">
490          <rasterlayer visible="false" filename="../../Data/iceland/island.tif"          <rasterlayer visible="false" filename="../../Data/iceland/island.tif"
# Line 512  class TestJoinedTable(LoadSessionTest): Line 518  class TestJoinedTable(LoadSessionTest):
518    
519      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>
520  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
521  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd" title="A Joined Table session">  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd" title="A Joined Table session">
522      <fileshapesource filetype="shapefile" id="D137227612"      <fileshapesource filetype="shapefile" id="D137227612"
523          filename="../../Data/iceland/roads-line.shp"/>          filename="../../Data/iceland/roads-line.shp"/>
524      <filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140"      <filetable filetype="DBF" filename="load_joinedtable.dbf" id="D136171140"
# Line 561  class TestPostGISLayer(LoadSessionTest): Line 567  class TestPostGISLayer(LoadSessionTest):
567    
568      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>
569  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
570  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
571          title="unnamed session">          title="unnamed session">
572      <dbconnection port="%(port)s" host="%(host)s" user="%(user)s"      <dbconnection port="%(port)s" host="%(host)s" user="%(user)s"
573          dbtype="postgis" id="D142684948" dbname="%(dbname)s"/>          dbtype="postgis" id="D142684948" dbname="%(dbname)s"/>
# Line 610  class TestPostGISLayerPassword(LoadSessi Line 616  class TestPostGISLayerPassword(LoadSessi
616    
617      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>      file_contents = '''<?xml version="1.0" encoding="UTF-8"?>
618  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
619  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
620          title="unnamed session">          title="unnamed session">
621      <dbconnection port="%(port)s" host="%(host)s" user="%(user)s"      <dbconnection port="%(port)s" host="%(host)s" user="%(user)s"
622          dbtype="postgis" id="D142684948" dbname="%(dbname)s"/>          dbtype="postgis" id="D142684948" dbname="%(dbname)s"/>
# Line 705  class TestLoadError(LoadSessionTest): Line 711  class TestLoadError(LoadSessionTest):
711      file_contents = '''\      file_contents = '''\
712  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
713  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">  <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
714  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-0.9.dtd"
715          title="single map&amp;layer">          title="single map&amp;layer">
716      <fileshapesource id="D1" filename="../../Data/iceland/political.shp"/>      <fileshapesource id="D1" filename="../../Data/iceland/political.shp"/>
717      <map title="Test Map">      <map title="Test Map">
# Line 732  class TestLoadError(LoadSessionTest): Line 738  class TestLoadError(LoadSessionTest):
738              # LoadError really was about the missing attribute              # LoadError really was about the missing attribute
739              self.assertEquals(str(value),              self.assertEquals(str(value),
740                "Element "                "Element "
741                "(u'http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd',"                "(u'http://thuban.intevation.org/dtds/thuban-0.9.dtd',"
742                " u'fileshapesource') requires an attribute 'filetype'")                " u'fileshapesource') requires an attribute 'filetype'")
743          else:          else:
744              self.fail("Missing filetype attribute doesn't raise LoadError")              self.fail("Missing filetype attribute doesn't raise LoadError")
745    
746  if __name__ == "__main__":  if __name__ == "__main__":
747      unittest.main()      support.run_tests()

Legend:
Removed from v.1646  
changed lines
  Added in v.1683

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26