jschuengel: thuban/Extensions/umn_mapserver/test test_mapserver.py, 1.3, 1.4
cvs@intevation.de
cvs at intevation.de
Wed Jul 14 12:32:31 CEST 2004
Author: jschuengel
Update of /thubanrepository/thuban/Extensions/umn_mapserver/test
In directory doto:/tmp/cvs-serv9151/test
Modified Files:
test_mapserver.py
Log Message:
Moved the testMap definition from global to the setUp function. Now the testMap will initialize new on each test.
Index: test_mapserver.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/test/test_mapserver.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test_mapserver.py 8 Jul 2004 14:29:49 -0000 1.3
+++ test_mapserver.py 14 Jul 2004 10:32:29 -0000 1.4
@@ -34,17 +34,15 @@
from Extensions.umn_mapserver.mapfile import shp_type
-# using the sample map
-testMapfile = 'test.map'
-testMap = mapObj(testMapfile)
-
-
class mapserver_generalClasses(unittest.TestCase):
def setUp(self):
"""
Running this funktion befor each test
"""
+ # using the sample map
+ testMapfile = 'test.map'
+ self.testMap = mapObj(testMapfile)
self.eq = self.assertEquals
@@ -53,7 +51,7 @@
Testing Color Objects from MapServer.
"""
# IMAGECOLOR 255 255 255
- testcolor = MF_Color(testMap.imagecolor)
+ testcolor = MF_Color(self.testMap.imagecolor)
self.eq(testcolor.get_red(), 255)
self.eq(testcolor.get_green(), 255)
self.eq(testcolor.get_blue(), 255)
@@ -78,7 +76,7 @@
the mapfile parameter extent.
"""
# EXTENT 622877.17 7019306.94 1095667.78 7447709.31
- testrect = MF_Rectangle(testMap.extent)
+ testrect = MF_Rectangle(self.testMap.extent)
self.eq(testrect.get_minx(), 622877.17)
self.eq(testrect.get_miny(), 7019306.94)
self.eq(testrect.get_maxx(), 1095667.78)
@@ -99,12 +97,12 @@
"""
# set up to keys to test
testmetadata = MF_Metadata()
- self.eq(testMap.getMetaData("titel"), "Iceland Test")
+ self.eq(self.testMap.getMetaData("titel"), "Iceland Test")
testmetadata.add_metadata("test", "test eintrag")
self.eq(testmetadata.get_metadatabykey("test"),"test eintrag")
# generate the MetaData from the testMap
- testMap2 = MF_Map(testMap)
+ testMap2 = MF_Map(self.testMap)
testmetadata = testMap2.get_metadata()
self.eq(testmetadata.get_metadatabykey("titel"),"Iceland Test")
@@ -115,6 +113,9 @@
"""
Running this funktion befor each test
"""
+ # using the sample map
+ testMapfile = 'test.map'
+ self.testMap = mapObj(testMapfile)
self.eq = self.assertEquals
@@ -122,7 +123,7 @@
"""
Testing the outputformat object
"""
- testoutputformat = MF_Outputformat(testMap.getOutputFormatByName("png"))
+ testoutputformat = MF_Outputformat(self.testMap.getOutputFormatByName("png"))
self.eq(testoutputformat.get_name(),"png")
@@ -130,7 +131,7 @@
"""
Testing the symbolset
"""
- testsymbolset = MF_SymbolSet(testMap.symbolset)
+ testsymbolset = MF_SymbolSet(self.testMap.symbolset)
self.eq(testsymbolset.get_symbol(1).get_name(), "circle")
@@ -138,9 +139,9 @@
"""
Testing the symbol object
"""
- testsymbol = MF_Symbol(testMap.symbolset.getSymbolByName("circle"))
+ testsymbol = MF_Symbol(self.testMap.symbolset.getSymbolByName("circle"))
self.eq(testsymbol.get_name(), "circle")
- assert(testsymbol.get_symbolObj(), testMap.symbolset.getSymbolByName("circle"))
+ assert(testsymbol.get_symbolObj(), self.testMap.symbolset.getSymbolByName("circle"))
testsymbol.set_filled(True)
self.eq(testsymbol.get_filled(), True)
@@ -154,8 +155,8 @@
Testing the class object.
"""
# only test the number of styles at the moment
- testclass = MF_Class(testMap.getLayer(0).getClass(0))
- self.eq (len(testclass.get_styles()), testMap.getLayer(0).getClass(0).numstyles)
+ testclass = MF_Class(self.testMap.getLayer(0).getClass(0))
+ self.eq (len(testclass.get_styles()), self.testMap.getLayer(0).getClass(0).numstyles)
# check the name
self.eq(testclass.get_name(), "testclass")
@@ -163,7 +164,7 @@
self.eq(testclass.get_name(), "checkout")
# check the expressionstring
- testclass = MF_Class(testMap.getLayer(2).getClass(0))
+ testclass = MF_Class(self.testMap.getLayer(2).getClass(0))
self.eq(testclass.get_expressionstring(), '"9"')
testclass.set_expressionstring("3")
self.eq(testclass.get_expressionstring(), '"3"')
@@ -174,13 +175,13 @@
Testing the layer object with some
sample data and classes.
"""
- testlayer = MF_Layer(testMap.getLayer(2))
+ testlayer = MF_Layer(self.testMap.getLayer(2))
# NAME 'political' only from layer 1
self.eq(testlayer.get_name(), 'cultural')
testlayer.set_name('checkout')
self.eq(testlayer.get_name(), 'checkout')
# check number of classes
- self.eq(len(testlayer.get_classes()), testMap.getLayer(2).numclasses)
+ self.eq(len(testlayer.get_classes()), self.testMap.getLayer(2).numclasses)
# check classitem
self.eq(testlayer.get_classitem(), "CLPOINT_")
testlayer.set_classitem("CLCHECK")
@@ -208,33 +209,26 @@
"""
Testing the mapfile object with samples.
"""
- testmap = MF_Map(testMap)
+ testMapp = MF_Map(self.testMap)
# NAME 'ISLAND'
- self.eq(testmap.get_name(), 'ISLAND')
- self.eq(len(testmap.get_layers()), testMap.numlayers)
+ self.eq(testMapp.get_name(), 'ISLAND')
+ self.eq(len(testMapp.get_layers()), self.testMap.numlayers)
- testmapfile = mapObj("")
- newtestmap = MF_Map(testmapfile)
- # proj=utm
- # ellps=clrk66
- # zone=26
- # north
# test see in test_MF_Projection
testproj = Projection(['proj=utm', 'ellps=clrk66', 'zone=26', 'north'])
- newtestmap.set_projection(testproj)
- self.eq(testmapfile.getProjection(), "+proj=utm+ellps=clrk66+zone=26+north")
- self.eq(newtestmap.get_projection().get_params(), ['proj=utm', 'ellps=clrk66', 'zone=26', 'north'])
+ testMapp.set_projection(testproj)
+ self.eq(testMapp.get_projection().get_params(), ['proj=utm', 'ellps=clrk66', 'zone=26', 'north'])
- self.eq(testmap.get_size(), (600,450))
- testmap.set_size(500,600)
- self.eq(testmap.get_size(), (500,600))
+ self.eq(testMapp.get_size(), (600,450))
+ testMapp.set_size(500,600)
+ self.eq(testMapp.get_size(), (500,600))
def test_MF_Scalebar(self):
"""
Test the Scalebarobj from the testfile
"""
- testscalebar = MF_Scalebar(testMap.scalebar)
+ testscalebar = MF_Scalebar(self.testMap.scalebar)
self.eq(testscalebar.get_position(mode="string"),"ll")
self.eq(testscalebar.get_position(), 3)
self.eq(testscalebar.get_intervals(), 4)
@@ -246,7 +240,7 @@
Test a Label object. In this test use the Label from
from the Scalebarobj in the testfile
"""
- testlabel = MF_Label(testMap.scalebar.label)
+ testlabel = MF_Label(self.testMap.scalebar.label)
self.eq(testlabel.get_force(), False)
self.eq(testlabel.get_buffer(),0)
self.eq(testlabel.get_type(), "bitmap")
@@ -256,7 +250,7 @@
"""
test the legend object from the testfile
"""
- testlegend = MF_Legend(testMap.legend)
+ testlegend = MF_Legend(self.testMap.legend)
self.eq(testlegend.get_status(), False)
testlegend.set_status(True)
self.eq(testlegend.get_status(), True)
@@ -277,7 +271,7 @@
# ellps=clrk66
# zone=26
# north
- testproj = MF_Projection(testMap.getProjection())
+ testproj = MF_Projection(self.testMap.getProjection())
if testproj.get_params():
self.eq(testproj.get_params(), ['proj=utm','ellps=WGS84','zone=26','north'])
@@ -290,7 +284,7 @@
"""
Tests a style object with all parameters.
"""
- teststyle = MF_Style(testMap.getLayer(0).getClass(0).getStyle(0))
+ teststyle = MF_Style(self.testMap.getLayer(0).getClass(0).getStyle(0))
# OUTLINECOLOR 0 0 0
self.eq(teststyle.get_outlinecolor().get_red(), 0)
# COLOR 100 200 100
@@ -305,7 +299,7 @@
"""
Tests a web object
"""
- testweb = MF_Web(testMap.web)
+ testweb = MF_Web(self.testMap.web)
self.eq(testweb.get_imagepath(), "/tmpimg/")
testweb.set_imagepath("/tmppathset/")
self.eq(testweb.get_imagepath(), "/tmppathset/")
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)