Skip to content

Commit b1c3ca8

Browse files
grizonnetmalexbruy
authored andcommittedMay 24, 2017
TEST: add test of OTB BandMath application in processing
(cherry picked from commit 1e7018f)
1 parent 2c78c54 commit b1c3ca8

File tree

6 files changed

+108
-0
lines changed

6 files changed

+108
-0
lines changed
 

‎python/plugins/processing/tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ IF(ENABLE_TESTS)
1212
ADD_PYTHON_TEST(ProcessingGdalAlgorithmsTest GdalAlgorithmsTest.py)
1313
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsImageryTest Grass7AlgorithmsImageryTest.py)
1414
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTest Grass7AlgorithmsRasterTest.py)
15+
#TODO uncomment when OTB is installed on Travis CI instance
16+
#ADD_PYTHON_TEST(ProcessingOTBAlgorithmsTest OTBAlgorithmsTest.py)
1517
ENDIF(ENABLE_TESTS)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
OTBAlgorithmTests.py
6+
---------------------
7+
Date : August 2016
8+
Copyright : (C) 2016 by Manuel Grizonnet
9+
Email : manuel.grizonnet@cnes.fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Manuel Grizonnet'
21+
__date__ = 'August 2016'
22+
__copyright__ = '(C) 2016, Manuel Grizonnet'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = ':%H$'
27+
28+
import AlgorithmsTestBase
29+
30+
import nose2
31+
import shutil
32+
33+
from qgis.testing import (
34+
start_app,
35+
unittest
36+
)
37+
38+
39+
class TestOTBAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
40+
41+
@classmethod
42+
def setUpClass(cls):
43+
start_app()
44+
from processing.core.Processing import Processing
45+
Processing.initialize()
46+
cls.cleanup_paths = []
47+
48+
@classmethod
49+
def tearDownClass(cls):
50+
for path in cls.cleanup_paths:
51+
shutil.rmtree(path)
52+
53+
def test_definition_file(self):
54+
return 'otb_algorithm_tests.yaml'
55+
56+
57+
if __name__ == '__main__':
58+
nose2.main()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<PAMDataset>
2+
<PAMRasterBand band="1">
3+
<Histograms>
4+
<HistItem>
5+
<HistMin>825.8245192307693</HistMin>
6+
<HistMax>899.1754807692307</HistMax>
7+
<BucketCount>208</BucketCount>
8+
<IncludeOutOfRange>0</IncludeOutOfRange>
9+
<Approximate>0</Approximate>
10+
<HistCounts>4|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6|0|0|0|0|0|4|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|9|0|0|0|0|0|6|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|10|0|0|0|0|4|0|0|0|0|0|0|0|0|6|0|0|0|0|9|0|0|0|0|0|6|0|0|0|0|0|0|0|0|0|0|4|0|0|9|0|0|0|0|0|0|0|0|0|0|0|0|0|6|0|0|0|0|0|6|0|0|6|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|13|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6</HistCounts>
11+
</HistItem>
12+
</Histograms>
13+
<Metadata>
14+
<MDI key="STATISTICS_MAXIMUM">899</MDI>
15+
<MDI key="STATISTICS_MEAN">865.86666666667</MDI>
16+
<MDI key="STATISTICS_MINIMUM">826</MDI>
17+
<MDI key="STATISTICS_STDDEV">17.808206597584</MDI>
18+
</Metadata>
19+
</PAMRasterBand>
20+
</PAMDataset>
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<PAMDataset>
2+
<PAMRasterBand band="1">
3+
<Metadata>
4+
<MDI key="STATISTICS_MAXIMUM">255</MDI>
5+
<MDI key="STATISTICS_MEAN">4.5535714285714</MDI>
6+
<MDI key="STATISTICS_MINIMUM">0</MDI>
7+
<MDI key="STATISTICS_STDDEV">33.770189539453</MDI>
8+
</Metadata>
9+
</PAMRasterBand>
10+
</PAMDataset>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See ../README.md for a description of the file format
2+
3+
tests:
4+
- algorithm: otb:bandmath
5+
name: Test (otb:bandmath)
6+
params:
7+
!!python/unicode '-exp': im1b1==826?255:0
8+
!!python/unicode '-il':
9+
params:
10+
- name: raster.tif
11+
type: raster
12+
type: multi
13+
!!python/unicode '-ram': 128
14+
results:
15+
!!python/unicode '-out':
16+
hash: a8acb8da3cf40a156fe26f815588a7cbf8f3c8f6b3c226968b1eab1e
17+
type: rasterhash
18+

0 commit comments

Comments
 (0)
Please sign in to comment.