/[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 1357 by jonathan, Wed Jul 2 09:38:27 2003 UTC revision 1375 by bh, Tue Jul 8 10:53:05 2003 UTC
# Line 66  class XMLWriterTest(unittest.TestCase): Line 66  class XMLWriterTest(unittest.TestCase):
66  class SaveSessionTest(unittest.TestCase, support.FileTestMixin,  class SaveSessionTest(unittest.TestCase, support.FileTestMixin,
67                        xmlsupport.ValidationTest):                        xmlsupport.ValidationTest):
68    
69      dtd = "http://thuban.intevation.org/dtds/thuban-0.8.dtd"      dtd = "http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"
70      thubanids = [((dtd, n), (None, "id")) for n in      thubanids = [((dtd, n), (None, "id")) for n in
71                   ["fileshapesource", "filetable", "jointable",                   ["fileshapesource", "filetable", "jointable",
72                    "derivedshapesource"]]                    "derivedshapesource"]]
# Line 79  class SaveSessionTest(unittest.TestCase, Line 79  class SaveSessionTest(unittest.TestCase,
79      del n, m, dtd      del n, m, dtd
80    
81      def compare_xml(self, xml1, xml2):      def compare_xml(self, xml1, xml2):
82          if 0:          list1 = xmlsupport.sax_eventlist(xml1, ids = self.thubanids,
83              for a, b in zip(sax_eventlist(xml1, self.thubanids,                                           idrefs = self.thubanidrefs)
84                                          self.thubanidrefs),          list2 = xmlsupport.sax_eventlist(xml2, ids = self.thubanids,
85                            sax_eventlist(xml2, self.thubanids,                                           idrefs = self.thubanidrefs)
86                                          self.thubanidrefs)):          if list1 != list2:
87                print a == b and ' ' or '*****'              for a, b in zip(list1, list2):
88                print a                  if a != b:
89                print b                      self.fail("%r != %r" % (a, b))
90          self.assertEquals(xmlsupport.sax_eventlist(xml1, ids = self.thubanids,  
                                                    idrefs = self.thubanidrefs),  
                           xmlsupport.sax_eventlist(xml2, ids = self.thubanids,  
                                                    idrefs = self.thubanidrefs))  
91    
92      def testEmptySession(self):      def testEmptySession(self):
93          """Save an empty session"""          """Save an empty session"""
# Line 104  class SaveSessionTest(unittest.TestCase, Line 101  class SaveSessionTest(unittest.TestCase,
101          file.close()          file.close()
102          self.compare_xml(written_contents,          self.compare_xml(written_contents,
103                           '<?xml version="1.0" encoding="UTF-8"?>\n'                           '<?xml version="1.0" encoding="UTF-8"?>\n'
104                           '<!DOCTYPE session SYSTEM "thuban-0.8.dtd">\n'                           '<!DOCTYPE session SYSTEM "thuban-0.9.dtd">\n'
105                           '<session title="empty session" '                           '<session title="empty session" '
106           'xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">'           'xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">'
107                           '\n</session>\n')                           '\n</session>\n')
108    
109          self.validate_data(written_contents)          self.validate_data(written_contents)
# Line 131  class SaveSessionTest(unittest.TestCase, Line 128  class SaveSessionTest(unittest.TestCase,
128          written_contents = file.read()          written_contents = file.read()
129          file.close()          file.close()
130          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>
131          <!DOCTYPE session SYSTEM "thuban-0.8.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
132          <session title="single map&amp;layer"          <session title="single map&amp;layer"
133             xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
134              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>
135              <map title="Test Map">              <map title="Test Map">
136                  <projection name="Unknown">                  <projection name="Unknown">
# Line 191  class SaveSessionTest(unittest.TestCase, Line 188  class SaveSessionTest(unittest.TestCase,
188          written_contents = file.read()          written_contents = file.read()
189          file.close()          file.close()
190          expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>          expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>
191          <!DOCTYPE session SYSTEM "thuban-0.8.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
192          <session title="single map&amp;layer"          <session title="single map&amp;layer"
193             xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
194              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>
195              <map title="Test Map">              <map title="Test Map">
196                  <projection name="Unknown">                  <projection name="Unknown">
# Line 237  class SaveSessionTest(unittest.TestCase, Line 234  class SaveSessionTest(unittest.TestCase,
234          written_contents = file.read()          written_contents = file.read()
235          file.close()          file.close()
236          expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>          expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>
237          <!DOCTYPE session SYSTEM "thuban-0.8.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
238          <session title="single map&amp;layer"          <session title="single map&amp;layer"
239             xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
240              <map title="Test Map">              <map title="Test Map">
241                  <rasterlayer title="My RasterLayer" filename="%s"                  <rasterlayer title="My RasterLayer" filename="%s"
242                               visible="true">                               visible="true">
# Line 297  class SaveSessionTest(unittest.TestCase, Line 294  class SaveSessionTest(unittest.TestCase,
294          written_contents = file.read()          written_contents = file.read()
295          file.close()          file.close()
296          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>
297          <!DOCTYPE session SYSTEM "thuban-0.8.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
298          <session title="single map&amp;layer"          <session title="single map&amp;layer"
299             xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
300              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>              <fileshapesource id="D1" filename="%s" filetype="shapefile"/>
301              <map title="Test Map">              <map title="Test Map">
302                  <projection name="Unknown">                  <projection name="Unknown">
# Line 358  class SaveSessionTest(unittest.TestCase, Line 355  class SaveSessionTest(unittest.TestCase,
355          written_contents = file.read()          written_contents = file.read()
356          file.close()          file.close()
357          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>          expected_template = '''<?xml version="1.0" encoding="UTF-8"?>
358          <!DOCTYPE session SYSTEM "thuban-0.8.dtd">          <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
359          <session title="a DBF Table session"          <session title="a DBF Table session"
360             xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">             xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
361              <filetable id="D1" filename="%s" filetype="DBF" title="political"/>              <filetable id="D1" filename="%s" filetype="DBF" title="political"/>
362          </session>'''          </session>'''
363    
# Line 401  class SaveSessionTest(unittest.TestCase, Line 398  class SaveSessionTest(unittest.TestCase,
398              #    print col.name              #    print col.name
399              joined = TransientJoinedTable(session.TransientDB(),              joined = TransientJoinedTable(session.TransientDB(),
400                                            store.Table(), "RDLNTYPE",                                            store.Table(), "RDLNTYPE",
401                                            dbftable, "RDTYPE")                                            dbftable, "RDTYPE",
402                                              outer_join = True)
403              store = session.AddShapeStore(DerivedShapeStore(store, joined))              store = session.AddShapeStore(DerivedShapeStore(store, joined))
404              layer.SetShapeStore(store)              layer.SetShapeStore(store)
405    
# Line 414  class SaveSessionTest(unittest.TestCase, Line 412  class SaveSessionTest(unittest.TestCase,
412              written_contents = file.read()              written_contents = file.read()
413              file.close()              file.close()
414              expected_template = '''<?xml version="1.0" encoding="UTF-8"?>              expected_template = '''<?xml version="1.0" encoding="UTF-8"?>
415              <!DOCTYPE session SYSTEM "thuban-0.8.dtd">              <!DOCTYPE session SYSTEM "thuban-0.9.dtd">
416              <session title="A Joined Table session"              <session title="A Joined Table session"
417               xmlns="http://thuban.intevation.org/dtds/thuban-0.8.dtd">               xmlns="http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd">
418                  <fileshapesource filename="%(shpfile)s"                  <fileshapesource filename="%(shpfile)s"
419                                   filetype="shapefile" id="D142197204"/>                                   filetype="shapefile" id="D142197204"/>
420                  <filetable filename="%(dbffile)s"                  <filetable filename="%(dbffile)s"
# Line 425  class SaveSessionTest(unittest.TestCase, Line 423  class SaveSessionTest(unittest.TestCase,
423                  <jointable id="D142180284"                  <jointable id="D142180284"
424                             title="Join of roads-line and save_joinedtable"                             title="Join of roads-line and save_joinedtable"
425                             leftcolumn="RDLNTYPE" left="D142197204"                             leftcolumn="RDLNTYPE" left="D142197204"
426                             rightcolumn="RDTYPE" right="D141881756"/>                             rightcolumn="RDTYPE" right="D141881756"
427                               jointype="LEFT OUTER" />
428                  <derivedshapesource id="D141915644"                  <derivedshapesource id="D141915644"
429                                      table="D142180284"                                      table="D142180284"
430                                      shapesource="D142197204"/>                                      shapesource="D142197204"/>

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26