Skip to content

Commit

Permalink
TEST: add test of OTB BandMath application in processing
Browse files Browse the repository at this point in the history
(cherry picked from commit 1e7018f)
  • Loading branch information
grizonnetm authored and alexbruy committed May 24, 2017
1 parent 2c78c54 commit b1c3ca8
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/plugins/processing/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ IF(ENABLE_TESTS)
ADD_PYTHON_TEST(ProcessingGdalAlgorithmsTest GdalAlgorithmsTest.py)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsImageryTest Grass7AlgorithmsImageryTest.py)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTest Grass7AlgorithmsRasterTest.py)
#TODO uncomment when OTB is installed on Travis CI instance
#ADD_PYTHON_TEST(ProcessingOTBAlgorithmsTest OTBAlgorithmsTest.py)
ENDIF(ENABLE_TESTS)
58 changes: 58 additions & 0 deletions python/plugins/processing/tests/OTBAlgorithmsTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
OTBAlgorithmTests.py
---------------------
Date : August 2016
Copyright : (C) 2016 by Manuel Grizonnet
Email : manuel.grizonnet@cnes.fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Manuel Grizonnet'
__date__ = 'August 2016'
__copyright__ = '(C) 2016, Manuel Grizonnet'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = ':%H$'

import AlgorithmsTestBase

import nose2
import shutil

from qgis.testing import (
start_app,
unittest
)


class TestOTBAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):

@classmethod
def setUpClass(cls):
start_app()
from processing.core.Processing import Processing
Processing.initialize()
cls.cleanup_paths = []

@classmethod
def tearDownClass(cls):
for path in cls.cleanup_paths:
shutil.rmtree(path)

def test_definition_file(self):
return 'otb_algorithm_tests.yaml'


if __name__ == '__main__':
nose2.main()
20 changes: 20 additions & 0 deletions python/plugins/processing/tests/data/raster.tif.aux.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<PAMDataset>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>825.8245192307693</HistMin>
<HistMax>899.1754807692307</HistMax>
<BucketCount>208</BucketCount>
<IncludeOutOfRange>0</IncludeOutOfRange>
<Approximate>0</Approximate>
<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>
</HistItem>
</Histograms>
<Metadata>
<MDI key="STATISTICS_MAXIMUM">899</MDI>
<MDI key="STATISTICS_MEAN">865.86666666667</MDI>
<MDI key="STATISTICS_MINIMUM">826</MDI>
<MDI key="STATISTICS_STDDEV">17.808206597584</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">255</MDI>
<MDI key="STATISTICS_MEAN">4.5535714285714</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">33.770189539453</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
18 changes: 18 additions & 0 deletions python/plugins/processing/tests/testdata/otb_algorithm_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See ../README.md for a description of the file format

tests:
- algorithm: otb:bandmath
name: Test (otb:bandmath)
params:
!!python/unicode '-exp': im1b1==826?255:0
!!python/unicode '-il':
params:
- name: raster.tif
type: raster
type: multi
!!python/unicode '-ram': 128
results:
!!python/unicode '-out':
hash: a8acb8da3cf40a156fe26f815588a7cbf8f3c8f6b3c226968b1eab1e
type: rasterhash

0 comments on commit b1c3ca8

Please sign in to comment.