Skip to content
Permalink
Browse files
tests for OTB provider
  • Loading branch information
alexbruy committed Jun 21, 2021
1 parent 82ad205 commit 6e93efe842a70982e2e226f4337d37303300d2d2
@@ -1,4 +1,6 @@
file(GLOB PY_FILES *.py)
file(GLOB OTHER_FILES metadata.txt)

add_subdirectory(tests)

PLUGIN_INSTALL(otbprovider . ${PY_FILES} ${OTHER_FILES})
@@ -152,7 +152,7 @@ def __init__(self, name='', description='', options=[], default=None, isSource=F

self.setMetadata({
'widget_wrapper': {
'class': 'processing.algs.otb.OtbChoiceWidget.OtbChoiceWidgetWrapper'}})
'class': 'otbprovider.OtbChoiceWidget.OtbChoiceWidgetWrapper'}})
self.options = options

if default is not None:

Large diffs are not rendered by default.

@@ -0,0 +1,8 @@
file(GLOB PY_FILES *.py)

PLUGIN_INSTALL(otbprovider tests ${PY_FILES})

if(ENABLE_TESTS)
include(UsePythonTest)
ADD_PYTHON_TEST(ProcessingOtbAlgorithmsTest OtbAlgorithmsTest.py)
endif()
@@ -45,10 +45,10 @@
from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
from processing.gui.wrappers import WidgetWrapperFactory
from processing.modeler.ModelerParametersDialog import ModelerParametersDialog
from processing.algs.otb.OtbAlgorithm import OtbAlgorithm
from processing.algs.otb.OtbAlgorithmProvider import OtbAlgorithmProvider
from processing.algs.otb.OtbUtils import OtbUtils
from processing.algs.otb.OtbChoiceWidget import OtbParameterChoice, OtbChoiceWidgetWrapper
from otbprovider.OtbAlgorithm import OtbAlgorithm
from otbprovider.OtbAlgorithmProvider import OtbAlgorithmProvider
from otbprovider.OtbUtils import OtbUtils
from otbprovider.OtbChoiceWidget import OtbParameterChoice, OtbChoiceWidgetWrapper
import AlgorithmsTestBase

import processing
@@ -226,7 +226,8 @@ def setUpClass(cls):
start_app()
from processing.core.Processing import Processing
Processing.initialize()
ProcessingConfig.setSettingValue("OTB_ACTIVATE", True)
cls.provider = OtbAlgorithmProvider()
QgsApplication.processingRegistry().addProvider(cls.provider)
ProcessingConfig.setSettingValue(OtbUtils.FOLDER, OTB_INSTALL_DIR)
ProcessingConfig.setSettingValue(OtbUtils.APP_FOLDER, os.path.join(OTB_INSTALL_DIR, 'lib', 'otb', 'applications'))
ProcessingConfig.readSettings()
@@ -241,6 +242,7 @@ def setUpClass(cls):
def tearDownClass(cls):
from processing.core.Processing import Processing
Processing.deinitialize()
QgsApplication.processingRegistry().removeProvider(cls.provider)
for path in cls.cleanup_paths:
shutil.rmtree(path)

@@ -0,0 +1,31 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>polys2</Name>
<ElementPath>polys2</ElementPath>
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-1.00000</ExtentXMin>
<ExtentXMax>10.00000</ExtentXMax>
<ExtentYMin>-3.00000</ExtentYMin>
<ExtentYMax>6.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>
<Type>String</Type>
<Width>5</Width>
</PropertyDefn>
<PropertyDefn>
<Name>intval</Name>
<ElementPath>intval</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>floatval</Name>
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:polys2 fid="polys.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-1,-1 -1,3 3,3 3,2 2,2 2,-1 -1,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>aaaaa</ogr:name>
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.123456</ogr:floatval>
</ogr:polys2>
</gml:featureMember>
<gml:featureMember>
<ogr:polys2 fid="polys.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 6,4 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>Aaaaa</ogr:name>
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
</ogr:polys2>
</gml:featureMember>
<gml:featureMember>
<ogr:polys2 fid="polys.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,5 2,6 3,6 3,5 2,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>bbaaa</ogr:name>
<ogr:floatval>0.123</ogr:floatval>
</ogr:polys2>
</gml:featureMember>
<gml:featureMember>
<ogr:polys2 fid="polys.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,1 10,1 10,-3 6,-3 6,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>7,0 7,-2 9,-2 9,0 7,0</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>ASDF</ogr:name>
<ogr:intval>0</ogr:intval>
</ogr:polys2>
</gml:featureMember>
<gml:featureMember>
<ogr:polys2 fid="polys.4">
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
</ogr:polys2>
</gml:featureMember>
<gml:featureMember>
<ogr:polys2 fid="polys.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,2 6,1 6,-3 2,-1 2,2 3,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>elim</ogr:name>
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
</ogr:polys2>
</gml:featureMember>
</ogr:FeatureCollection>
Binary file not shown.
@@ -0,0 +1,11 @@
<PAMDataset>
<PAMRasterBand band="1">
<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>
<MDI key="STATISTICS_VALID_PERCENT">53.57</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
Binary file not shown.
@@ -0,0 +1,11 @@
<PAMDataset>
<PAMRasterBand band="1">
<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>
<MDI key="STATISTICS_VALID_PERCENT">53.57</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
@@ -31,7 +31,6 @@ if(ENABLE_TESTS)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTestPt1 Grass7AlgorithmsRasterTestPt1.py)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTestPt2 Grass7AlgorithmsRasterTestPt2.py)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsVectorTest Grass7AlgorithmsVectorTest.py)
ADD_PYTHON_TEST(ProcessingOtbAlgorithmsTest OtbAlgorithmsTest.py)
ADD_PYTHON_TEST(ProcessingCheckValidityAlgorithmTest CheckValidityAlgorithm.py)
ADD_PYTHON_TEST(ProcessingScriptUtilsTest ScriptUtilsTest.py)
if(ENABLE_SAGA_TESTS)

0 comments on commit 6e93efe

Please sign in to comment.