/[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 2552 by jonathan, Fri Jan 28 15:54:00 2005 UTC revision 2621 by jonathan, Fri May 6 14:19:40 2005 UTC
# Line 234  class SaveSessionTest(unittest.TestCase, Line 234  class SaveSessionTest(unittest.TestCase,
234          self.validate_data(written_contents)          self.validate_data(written_contents)
235    
236      def testRasterLayer(self):      def testRasterLayer(self):
         # deliberately put an apersand in the title :)  
         session = Session("single map&layer")  
         map = Map("Test Map")  
         session.AddMap(map)  
         # use shapefile from the example data  
         imgfile = os.path.join(os.path.dirname(__file__),  
                                os.pardir, "Data", "iceland", "island.tif")  
         layer = RasterLayer("My RasterLayer", imgfile)  
         map.AddLayer(layer)  
   
         filename = self.temp_file_name("%s.thuban" % self.id())  
         save_session(session, filename)  
         session.Destroy()  
   
         file = open(filename)  
         written_contents = file.read()  
         file.close()  
         expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>  
         <!DOCTYPE session SYSTEM "thuban-1.1.dtd">  
         <session title="single map&amp;layer"  
            xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd">  
             <map title="Test Map">  
                 <rasterlayer title="My RasterLayer"  
                         filename="../../Data/iceland/island.tif"  
                         visible="true">  
                 </rasterlayer>  
             </map>  
         </session>'''  
         #print written_contents  
         #print "********************************************"  
         #print expected_contents  
         self.compare_xml(written_contents, expected_contents)  
237    
238          self.validate_data(written_contents)          MASK_NONE = RasterLayer.MASK_NONE
239            MASK_BIT = RasterLayer.MASK_BIT
240            MASK_ALPHA = RasterLayer.MASK_ALPHA
241    
242            for opacity, masktype, opname, maskname in \
243                [(1,  MASK_BIT,   '', ''),
244                 (.2, MASK_BIT,   'opacity="0.2"', ''),
245                 (1,  MASK_ALPHA, '',              'masktype="alpha"'),
246                 (.5, MASK_ALPHA, 'opacity="0.5"', 'masktype="alpha"'),
247                 (1,  MASK_NONE,  '',              'masktype="none"'),
248                 (0,  MASK_NONE,  'opacity="0"',   'masktype="none"') ]:
249    
250    
251                # deliberately put an apersand in the title :)
252                session = Session("single map&layer")
253                map = Map("Test Map")
254                session.AddMap(map)
255                # use shapefile from the example data
256                imgfile = os.path.join(os.path.dirname(__file__),
257                                       os.pardir, "Data", "iceland", "island.tif")
258                layer = RasterLayer("My RasterLayer", imgfile)
259    
260                layer.SetOpacity(opacity)
261                layer.SetMaskType(masktype)
262    
263                map.AddLayer(layer)
264    
265                filename = self.temp_file_name("%s.thuban" % self.id())
266                save_session(session, filename)
267                session.Destroy()
268    
269                file = open(filename)
270                written_contents = file.read()
271                file.close()
272                expected_contents = '''<?xml version="1.0" encoding="UTF-8"?>
273                <!DOCTYPE session SYSTEM "thuban-1.1.dtd">
274                <session title="single map&amp;layer"
275                   xmlns="http://thuban.intevation.org/dtds/thuban-1.1-dev.dtd">
276                    <map title="Test Map">
277                        <rasterlayer title="My RasterLayer"
278                                filename="../../Data/iceland/island.tif"
279                                visible="true" %s %s>
280                        </rasterlayer>
281                    </map>
282                </session>''' % (opname, maskname)
283                #print written_contents
284                #print "********************************************"
285                #print expected_contents
286                self.compare_xml(written_contents, expected_contents)
287    
288                self.validate_data(written_contents)
289    
290      def testClassifiedLayer(self):      def testClassifiedLayer(self):
291          """Save a session with a single map with classifications"""          """Save a session with a single map with classifications"""

Legend:
Removed from v.2552  
changed lines
  Added in v.2621

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26