/[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 1200 by jonathan, Fri Jun 13 15:04:44 2003 UTC revision 1245 by bh, Thu Jun 19 19:29:23 2003 UTC
# Line 21  import xml.sax Line 21  import xml.sax
21  import xml.sax.handler  import xml.sax.handler
22  from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException  from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException
23    
24    import xmlsupport
25    
26  import support  import support
27  support.initthuban()  support.initthuban()
28    
# Line 94  class XMLWriterTest(unittest.TestCase): Line 96  class XMLWriterTest(unittest.TestCase):
96          eq(writer.encode('&"\'<>'), "&amp;&quot;&apos;&lt;&gt;")          eq(writer.encode('&"\'<>'), "&amp;&quot;&apos;&lt;&gt;")
97          eq(writer.encode(unicode('&"\'<>')), "&amp;&quot;&apos;&lt;&gt;")          eq(writer.encode(unicode('&"\'<>')), "&amp;&quot;&apos;&lt;&gt;")
98    
99  class SaveSessionTest(unittest.TestCase, support.FileTestMixin):  class SaveSessionTest(unittest.TestCase, support.FileTestMixin,
100                          xmlsupport.ValidationTest):
101    
102      def compare_xml(self, xml1, xml2):      def compare_xml(self, xml1, xml2):
103          self.assertEquals(sax_eventlist(xml1), sax_eventlist(xml2))          self.assertEquals(sax_eventlist(xml1), sax_eventlist(xml2))
# Line 114  class SaveSessionTest(unittest.TestCase, Line 117  class SaveSessionTest(unittest.TestCase,
117                           '<!DOCTYPE session SYSTEM "thuban.dtd">\n'                           '<!DOCTYPE session SYSTEM "thuban.dtd">\n'
118                           '<session title="empty session">\n</session>\n')                           '<session title="empty session">\n</session>\n')
119    
120            self.validate_data(written_contents)
121    
122      def testSingleLayer(self):      def testSingleLayer(self):
123          """Save a session with a single map with a single layer"""          """Save a session with a single map with a single layer"""
124          # deliberately put an apersand in the title :)          # deliberately put an apersand in the title :)
# Line 156  class SaveSessionTest(unittest.TestCase, Line 161  class SaveSessionTest(unittest.TestCase,
161          #print expected_contents          #print expected_contents
162          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
163    
164            self.validate_data(written_contents)
165    
166          layer.SetVisible(False)          layer.SetVisible(False)
167          save_session(session, filename)          save_session(session, filename)
168    
# Line 170  class SaveSessionTest(unittest.TestCase, Line 177  class SaveSessionTest(unittest.TestCase,
177          #print "********************************************"          #print "********************************************"
178          #print expected_contents          #print expected_contents
179          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
180            self.validate_data(written_contents)
181    
182          session.Destroy()          session.Destroy()
183    
# Line 218  class SaveSessionTest(unittest.TestCase, Line 226  class SaveSessionTest(unittest.TestCase,
226          #print expected_contents          #print expected_contents
227          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
228    
229                    self.validate_data(written_contents)
230    
231      def testRasterLayer(self):      def testRasterLayer(self):
232          # deliberately put an apersand in the title :)          # deliberately put an apersand in the title :)
233          session = Session("single map&layer")          session = Session("single map&layer")
# Line 229  class SaveSessionTest(unittest.TestCase, Line 238  class SaveSessionTest(unittest.TestCase,
238                                 os.pardir, "Data", "iceland", "island.tif")                                 os.pardir, "Data", "iceland", "island.tif")
239          layer = RasterLayer("My RasterLayer", imgfile)          layer = RasterLayer("My RasterLayer", imgfile)
240          map.AddLayer(layer)          map.AddLayer(layer)
241                                                                                    
242          filename = self.temp_file_name("save_singlemap.thuban")          filename = self.temp_file_name("save_singlemap.thuban")
243          save_session(session, filename)          save_session(session, filename)
244          session.Destroy()          session.Destroy()
245                                                                                    
246          file = open(filename)          file = open(filename)
247          written_contents = file.read()          written_contents = file.read()
248          file.close()          file.close()
# Line 253  class SaveSessionTest(unittest.TestCase, Line 262  class SaveSessionTest(unittest.TestCase,
262          #print expected_contents          #print expected_contents
263          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
264    
265            self.validate_data(written_contents)
266    
267      def testClassifiedLayer(self):      def testClassifiedLayer(self):
268          """Save a session with a single map with a single layer          """Save a session with a single map with a single layer
269             with a classificaton.             with a classificaton.
# Line 324  class SaveSessionTest(unittest.TestCase, Line 335  class SaveSessionTest(unittest.TestCase,
335                      </classification>                      </classification>
336                  </layer>                  </layer>
337              </map>              </map>
338          </session>'''          </session>'''
339            
340          expected_contents = expected_template % \          expected_contents = expected_template % \
341              (os.path.join("..", "..", "Data", "iceland", "political.shp"),              (os.path.join("..", "..", "Data", "iceland", "political.shp"),
342               "true")               "true")
# Line 335  class SaveSessionTest(unittest.TestCase, Line 346  class SaveSessionTest(unittest.TestCase,
346          #print expected_contents          #print expected_contents
347          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
348    
349            self.validate_data(written_contents)
350    
351          session.Destroy()          session.Destroy()
352    
353    

Legend:
Removed from v.1200  
changed lines
  Added in v.1245

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26