Skip to content
Permalink
Browse files

[CI] fix travis test for OtbAlgorithms

  • Loading branch information
rkanavath authored and nyalldawson committed Feb 22, 2019
1 parent e286d5b commit 471865afd17075e46b1984b8d118ca74cbc7c9a3
@@ -144,8 +144,9 @@ RUN locale-gen
RUN echo "alias python=python3" >> ~/.bash_aliases

# OTB: download and install otb packages for QGIS tests
RUN curl https://orfeo-toolbox.org/packages/qgis/OTB-Linux64.run -o /tmp/OTB-Linux64.run && sh /tmp/OTB-Linux64.run
ENV OTB_INSTALL_DIR=/tmp/OTB-Linux64
RUN curl -k https://orfeo-toolbox.org/qgis/OTB-Linux64.run -o /tmp/OTB-Linux64.run && sh /tmp/OTB-Linux64.run --target /opt/otb
ENV OTB_INSTALL_DIR=/opt/otb

ENV CC=/usr/lib/ccache/clang
ENV CXX=/usr/lib/ccache/clang++
ENV QT_SELECT=5
@@ -188,7 +188,7 @@ def preprocessParameters(self, parameters):

return valid_params

def get_value(self, v):
def otbParameterValue(self, v):
if isinstance(v, QgsMapLayer):
return v.source()
elif isinstance(v, QgsProcessingOutputLayerDefinition):
@@ -222,9 +222,9 @@ def processAlgorithm(self, parameters, context, feedback):
if isinstance(v, list):
value = ''
for i in list(filter(None, v)):
value += '"{}" '.format(self.get_value(i))
value += '"{}" '.format(self.otbParameterValue(i))
else:
value = '"{}"'.format(self.get_value(v))
value = '"{}"'.format(self.otbParameterValue(v))

if k == output_key and 'outputpixeltype' in parameters:
output_pixel_type = self.pixelTypes[int(parameters['outputpixeltype'])]
@@ -83,7 +83,6 @@ def geoidFile():

def executeOtb(command, feedback, addToLog=True):
loglines = []
feedback.setProgress(0)
with subprocess.Popen(
[command],
shell=True,
@@ -33,6 +33,7 @@
import nose2

from qgis.core import (QgsProcessingParameterNumber,
QgsApplication,
QgsProcessingParameterDefinition)
from qgis.testing import start_app, unittest
#from processing.algs.otb.OtbChoiceWidget import OtbParameterChoice
@@ -43,18 +44,11 @@
from processing.tools import dataobjects
import AlgorithmsTestBase

#export QGIS_DISABLE_MESSAGE_HOOKS=1
#sys.path.append('/home/rashad/projects/qgis/qgis/build/output/python')
#sys.path.append('/home/rashad/projects/qgis/qgis/build/output/python/plugins')
#sys.path.append('/home/rashad/projects/qgis/otb-plugin')

# /home/rashad/projects/otb/gitlab/build"
OTB_INSTALL_DIR = os.environ.get('OTB_INSTALL_DIR')


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

#algList = []
def test_init_algorithms(self):
algs_txt = os.path.join(self.descrFolder, 'algs.txt')
with open(algs_txt) as lines:
@@ -67,10 +61,11 @@ def test_init_algorithms(self):
data = line.split('|')
descriptionFile = os.path.join(self.descrFolder, str(data[1]) + '.txt')
alg = OtbAlgorithm(data[0], data[1], descriptionFile)
print("Loading Algorithm: '{}' - OK".format(alg.id()))
self.assertIsInstance(alg, OtbAlgorithm)
ret, msg = alg.canExecute()
line = lines.readline().strip('\n').strip()
print("canExecute '{}' - {}".format(alg.id(), ret))
self.assertEqual(ret, True)
line = lines.readline().strip('\n').strip()

def test_choice_parameter_smoothing(self):
alg_smoothing = OtbAlgorithm('Image Filtering', 'Smoothing', os.path.join(self.descrFolder, 'Smoothing.txt'))
@@ -88,10 +83,15 @@ def setUpClass(cls):
cls.descrFolder = os.path.join(OTB_INSTALL_DIR, 'share', 'otb', 'description')
from processing.core.Processing import Processing
Processing.initialize()
ProcessingConfig.setSettingValue("OTB_ACTIVATE", True)
ProcessingConfig.setSettingValue(OtbSettings.FOLDER, OTB_INSTALL_DIR)
ProcessingConfig.setSettingValue(OtbSettings.APP_FOLDER, os.path.join(OTB_INSTALL_DIR, 'lib', 'otb', 'applications'))
ProcessingConfig.setSettingValue("OTB_ACTIVATE", True)
ProcessingConfig.readSettings()
#refresh OTB Algorithms after settings are changed.
for p in QgsApplication.processingRegistry().providers():
if p.id() == "otb":
p.refreshAlgorithms()

cls.cleanup_paths = []

@classmethod
@@ -102,6 +102,7 @@ def tearDownClass(cls):
shutil.rmtree(path)

def test_definition_file(self):
print("OTB_INSTALL_DIR = '{}'".format(OTB_INSTALL_DIR))
return 'otb_algorithm_tests.yaml'


0 comments on commit 471865a

Please sign in to comment.
You can’t perform that action at this time.