Skip to content
Permalink
Browse files

[sextante] modeler tests

  • Loading branch information
volaya committed Mar 28, 2013
1 parent 1c0f6c6 commit bfada31fd3309cb001b72fa9237028c6b1d502ec
@@ -212,6 +212,7 @@ def updateAlgorithm(self, algIndex, parametersMap, valuesMap, outputsMap, depend


def removeAlgorithm(self, index):
'''returns true if the algorithm could be removed, false if others depend on it and could not be removed'''
if self.hasDependencies(self.algs[index], index):
return False
for out in self.algs[index].outputs:
@@ -241,6 +242,7 @@ def removeAlgorithm(self, index):
return True

def removeParameter(self, index):
'''returns true if the parameter could be removed, false if others depend on it and could not be removed'''
if self.hasDependencies(self.parameters[index], index):
return False
del self.parameters[index]
@@ -0,0 +1,25 @@
NAME:A model with no parameters
GROUP:[Test models]
VALUE:HARDCODEDPARAMVALUE_HSPACING_0===10
VALUE:HARDCODEDPARAMVALUE_CENTERY_0===0
VALUE:HARDCODEDPARAMVALUE_WIDTH_0===30
VALUE:HARDCODEDPARAMVALUE_GRIDTYPE_0===1
VALUE:HARDCODEDPARAMVALUE_CENTERX_0===0
VALUE:HARDCODEDPARAMVALUE_HEIGHT_0===30
VALUE:HARDCODEDPARAMVALUE_VSPACING_0===10
ALGORITHM:qgis:creategrid
112.0,53.0
None
-1|HARDCODEDPARAMVALUE_HSPACING_0
-1|HARDCODEDPARAMVALUE_VSPACING_0
-1|HARDCODEDPARAMVALUE_WIDTH_0
-1|HARDCODEDPARAMVALUE_HEIGHT_0
-1|HARDCODEDPARAMVALUE_CENTERX_0
-1|HARDCODEDPARAMVALUE_CENTERY_0
-1|HARDCODEDPARAMVALUE_GRIDTYPE_0
grid
ALGORITHM:qgis:polygoncentroids
109.0,195.0
None
0|SAVENAME
centroids
@@ -0,0 +1,3 @@
##[Example scripts]=group

sextante.loadTestData()
@@ -6,18 +6,36 @@
import os
from osgeo import gdal
from osgeo.gdalconst import GA_ReadOnly
from sextante.modeler import ModelerAlgorithmProvider
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm


class ModelerAlgorithmTest(unittest.TestCase):

def testCreateModel(self):
pass

def testRemoveParameter(self):
pass

def testRemoveAlgorithm(self):
pass
'''NOTE:this is not passing, since the algCopy method reload from file'''
folder = os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__), "models")
modelfile = os.path.join(folder, "noinputs.model")
model = ModelerAlgorithm()
model.openModel(modelfile)
self.assertTrue(2, len(model.algs))
self.assertFalse(model.removeAlgorithm(0))
self.assertTrue(model.removeAlgorithm(len(model.algs) - 1));
outputs = sextante.runalg(model, None)
self.assertEquals(2, len(outputs))
output=outputs['SAVENAME_ALG0']
layer=QGisLayers.getObjectFromUri(output, True)
self.assertIsNone(layer)

def testRemoveParameter(self):
pass



'''The following tests correspond to example models'''

def test_modelersagagrass(self):
outputs=sextante.runalg("modeler:sagagrass",points(),None)

0 comments on commit bfada31

Please sign in to comment.
You can’t perform that action at this time.