-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
131 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
python/plugins/sextante/script/scripts/A_script_that_returns_a_number.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
##[Test scripts]=group | ||
##number=output number | ||
|
||
number = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
from sextante.core.Sextante import Sextante | ||
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm | ||
import sextante | ||
import unittest | ||
from sextante.tests.TestData import points, points2, polygons, polygons2, lines, union,\ | ||
table, polygonsGeoJson, raster | ||
from sextante.core.QGisLayers import QGisLayers | ||
|
||
def testAlg(algname, *args): | ||
class GeoAlgorithmTest(unittest.TestCase): | ||
pass | ||
|
||
#test simple execution | ||
alg = Sextante.runAlgorithm(algname, None, *args) | ||
assert alg is not None | ||
def suite(): | ||
suite = unittest.makeSuite(GeoAlgorithmTest, 'test') | ||
return suite | ||
|
||
out = alg.getOutputValuesAsDictionary() | ||
|
||
return out | ||
|
||
#test execution in a model | ||
|
||
#=========================================================================== | ||
# model = ModelerAlgorithm() | ||
# model.addAlgorithm(alg, parametersMap, valuesMap, outputsMap, dependencies) | ||
#=========================================================================== | ||
|
||
#test | ||
def runtests(): | ||
result = unittest.TestResult() | ||
testsuite = suite() | ||
testsuite.run(result) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'''Convenience module to create a test suite will all SEXTANTE tests''' | ||
import unittest | ||
from sextante.tests import QgisAlgsTest | ||
from sextante.tests import ParametersTest | ||
from sextante.tests import ModelerAlgorithmTest | ||
from sextante.tests import SextanteToolsTest | ||
from sextante.tests import ScriptTest | ||
from sextante.tests import SagaTest | ||
from sextante.tests import GeoAlgorithmTest | ||
|
||
def suite(): | ||
suite = unittest.TestSuite() | ||
suite.addTests(QgisAlgsTest.suite()) | ||
suite.addTests(ModelerAlgorithmTest.suite()) | ||
suite.addTests(SagaTest.suite()) | ||
suite.addTests(ScriptTest.suite()) | ||
suite.addTests(SextanteToolsTest.suite()) | ||
#suite.addTests(ParametersTest.suite()) | ||
suite.addTests(GeoAlgorithmTest.suite()) | ||
return suite | ||
|
||
def runtests(): | ||
result = unittest.TestResult() | ||
testsuite = suite() | ||
testsuite.run(result) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import sextante | ||
import unittest | ||
from sextante.tests.TestData import points, points2, polygons, polygons2, lines, union,\ | ||
table, polygonsGeoJson, raster | ||
from sextante.core import Sextante | ||
from sextante.tools.vector import getAttributeValues | ||
|
||
class SextanteToolsTest(unittest.TestCase): | ||
'''tests the method imported when doing an "import sextante", and also in sextante.tools. | ||
They are mostly convenience tools''' | ||
|
||
def test_getobject(self): | ||
layer = sextante.getobject(points()); | ||
self.assertIsNotNone(layer) | ||
layer = sextante.getobject("points"); | ||
self.assertIsNotNone(layer) | ||
|
||
def test_runandload(self): | ||
sextante.runandload("qgis:countpointsinpolygon",polygons(),points(),"NUMPOINTS", None) | ||
layer = Sextante.getObjectFromName("Result") | ||
self.assertIsNotNone(layer) | ||
|
||
def test_featuresWithoutSelection(self): | ||
layer = sextante.getobject(points()) | ||
features = sextante.getfeatures(layer) | ||
self.assertEqual(12, len(features)) | ||
|
||
def test_featuresWithSelection(self): | ||
layer = sextante.getobject(points()) | ||
feature = layer.getFeatures().next() | ||
selected = [feature.id()] | ||
layer.setSelectedFeatures(selected) | ||
features = sextante.getfeatures(layer) | ||
self.assertEqual(1, len(features)) | ||
layer.setSelectedFeatures([]) | ||
|
||
def test_attributeValues(self): | ||
layer = sextante.getobject(points()) | ||
values = getAttributeValues(layer, "ID") | ||
i = 1 | ||
for value in values['ID']: | ||
self.assertEqual(int(i), int(value)) | ||
i+=1 | ||
self.assertEquals(13,i) | ||
|
||
def test_extent(self): | ||
pass | ||
|
||
|
||
|
||
def suite(): | ||
suite = unittest.makeSuite(SextanteToolsTest, 'test') | ||
return suite | ||
|
||
def runtests(): | ||
result = unittest.TestResult() | ||
testsuite = suite() | ||
testsuite.run(result) | ||
return result |