jonathan: thuban/test test_save.py,1.35,1.36
cvs@intevation.de
cvs at intevation.de
Fri May 6 16:19:42 CEST 2005
Author: jonathan
Update of /thubanrepository/thuban/test
In directory doto:/tmp/cvs-serv30260/test
Modified Files:
test_save.py
Log Message:
(SaveSessionTest.testRasterLayer): Restructure test to cover a variety of
combinations of masktype and opacity settings.
Index: test_save.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_save.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- test_save.py 28 Jan 2005 15:54:00 -0000 1.35
+++ test_save.py 6 May 2005 14:19:40 -0000 1.36
@@ -234,40 +234,58 @@
self.validate_data(written_contents)
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()
+ MASK_NONE = RasterLayer.MASK_NONE
+ MASK_BIT = RasterLayer.MASK_BIT
+ MASK_ALPHA = RasterLayer.MASK_ALPHA
- 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&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)
+ for opacity, masktype, opname, maskname in \
+ [(1, MASK_BIT, '', ''),
+ (.2, MASK_BIT, 'opacity="0.2"', ''),
+ (1, MASK_ALPHA, '', 'masktype="alpha"'),
+ (.5, MASK_ALPHA, 'opacity="0.5"', 'masktype="alpha"'),
+ (1, MASK_NONE, '', 'masktype="none"'),
+ (0, MASK_NONE, 'opacity="0"', 'masktype="none"') ]:
- self.validate_data(written_contents)
+
+ # 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)
+
+ layer.SetOpacity(opacity)
+ layer.SetMaskType(masktype)
+
+ 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&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" %s %s>
+ </rasterlayer>
+ </map>
+ </session>''' % (opname, maskname)
+ #print written_contents
+ #print "********************************************"
+ #print expected_contents
+ self.compare_xml(written_contents, expected_contents)
+
+ self.validate_data(written_contents)
def testClassifiedLayer(self):
"""Save a session with a single map with classifications"""
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)