|
2 | 2 | import unittest |
3 | 3 | from sextante.tests.TestData import points, points2, polygons, polygons2, lines, union,\ |
4 | 4 | table, polygonsGeoJson |
| 5 | + table, polygonsGeoJson, raster |
5 | 6 | from sextante.core.QGisLayers import QGisLayers |
6 | 7 | from sextante.core.SextanteUtils import SextanteUtils |
| 8 | +from osgeo.gdalconst import GA_ReadOnly |
| 9 | +import os |
| 10 | +from osgeo import gdal |
7 | 11 |
|
8 | 12 | class SagaTest(unittest.TestCase): |
9 | 13 | '''tests for saga algorithms''' |
10 | 14 |
|
| 15 | + def test_sagametricconversions(self): |
| 16 | + outputs=sextante.runalg("saga:metricconversions",raster(),0,None) |
| 17 | + output=outputs['CONV'] |
| 18 | + self.assertTrue(os.path.isfile(output)) |
| 19 | + dataset=gdal.Open(output, GA_ReadOnly) |
| 20 | + strhash=hash(str(dataset.ReadAsArray(0).tolist())) |
| 21 | + self.assertEqual(strhash,-2137931723) |
| 22 | + |
| 23 | + def test_sagasortgrid(self): |
| 24 | + outputs=sextante.runalg("saga:sortgrid",raster(),True,None) |
| 25 | + output=outputs['OUTPUT'] |
| 26 | + self.assertTrue(os.path.isfile(output)) |
| 27 | + dataset=gdal.Open(output, GA_ReadOnly) |
| 28 | + strhash=hash(str(dataset.ReadAsArray(0).tolist())) |
| 29 | + self.assertEqual(strhash,1320073153) |
11 | 30 |
|
12 | | - '''the following tests are not meant to test the algorithms themselves, |
13 | | - but the algorithm provider, testing things such as the file conversion, |
| 31 | + '''the following tests are not meant to test the algorithms themselves, |
| 32 | + but the algorithm provider, testing things such as the file conversion, |
14 | 33 | the selection awareness of SAGA process, etc''' |
15 | 34 |
|
16 | | - def test_SagaVvectorAlgorithmWithSelection(self): |
| 35 | + def test_SagaVectorAlgorithmWithSelection(self): |
17 | 36 | layer = sextante.getobject(polygons2()); |
18 | 37 | feature = layer.getFeatures().next() |
19 | 38 | selected = [feature.id()] |
@@ -63,7 +82,13 @@ def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self): |
63 | 82 | self.assertEqual(expectedvalues, values) |
64 | 83 | wkt='POINT(270787.49991451 4458955.46775295)' |
65 | 84 | self.assertEqual(wkt, str(feature.geometry().exportToWkt())) |
66 | | - |
| 85 | + def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self): |
| 86 | + outputs=sextante.runalg("saga:convergenceindex",raster(),0,0,None) |
| 87 | + output=outputs['RESULT'] |
| 88 | + self.assertTrue(os.path.isfile(output)) |
| 89 | + dataset=gdal.Open(output, GA_ReadOnly) |
| 90 | + strhash=hash(str(dataset.ReadAsArray(0).tolist())) |
| 91 | + self.assertEqual(strhash,485390137) |
67 | 92 |
|
68 | 93 |
|
69 | 94 |
|
|
0 commit comments