Skip to content

Commit

Permalink
[processing] Add gdal test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Feb 23, 2016
1 parent 9111968 commit 781c10b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -116,7 +116,7 @@ def load_param(self, param):
# No type specified, use whatever is there # No type specified, use whatever is there
return param return param


raise KeyError("Unknown type '{}' specified for parameter '{}'".format(param['type'], param['name'])) raise KeyError("Unknown type '{}' specified for parameter".format(param['type']))


def load_result_param(self, param): def load_result_param(self, param):
""" """
Expand All @@ -129,8 +129,14 @@ def load_result_param(self, param):
basename = os.path.basename(param['name']) basename = os.path.basename(param['name'])
filepath = os.path.join(outdir, basename) filepath = os.path.join(outdir, basename)
return filepath return filepath
elif param['type'] == 'rasterhash':
outdir = tempfile.mkdtemp()
self.cleanup_paths.append(outdir)
basename = 'raster.tif'
filepath = os.path.join(outdir, basename)
return filepath


raise KeyError("Unknown type '{}' specified for parameter '{}'".format(param['type'], param['name'])) raise KeyError("Unknown type '{}' specified for parameter".format(param['type']))


def load_layer(self, param): def load_layer(self, param):
""" """
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/tests/CMakeLists.txt
Expand Up @@ -8,4 +8,5 @@ IF(ENABLE_TESTS)
INCLUDE(UsePythonTest) INCLUDE(UsePythonTest)
ADD_PYTHON_TEST(ProcessingParametersTest ParametersTest.py) ADD_PYTHON_TEST(ProcessingParametersTest ParametersTest.py)
ADD_PYTHON_TEST(ProcessingQgisAlgorithmsTest QgisAlgorithmsTest.py) ADD_PYTHON_TEST(ProcessingQgisAlgorithmsTest QgisAlgorithmsTest.py)
ADD_PYTHON_TEST(ProcessingGdalAlgorithmsTest GdalAlgorithmsTest.py)
ENDIF(ENABLE_TESTS) ENDIF(ENABLE_TESTS)
58 changes: 58 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
GdalAlgorithmTests.py
---------------------
Date : January 2016
Copyright : (C) 2016 by Matthias Kuhn
Email : matthias@opengis.ch
***************************************************************************
* *
* 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__ = 'Matthias Kuhn'
__date__ = 'January 2016'
__copyright__ = '(C) 2016, Matthias Kuhn'

# 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 TestGdalAlgorithms(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 'gdal_algorithm_tests.yaml'


if __name__ == '__main__':
nose2.main()
27 changes: 27 additions & 0 deletions python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml
@@ -0,0 +1,27 @@
# See ../README.md for a description of the file format

tests:
- algorithm: gdalogr:rasterize
name: Test (gdalogr:rasterize)
params:
BIGTIFF: 0
COMPRESS: 4
DIMENSIONS: 0
EXTRA: ""
FIELD: "Bfloatval"
HEIGHT: 100
INPUT:
name: multipolys.gml
type: vector
JPEGCOMPRESSION: 75
NO_DATA: -9999
PREDICTOR: 1
RTYPE: 5
TFW: False
TILED: False
WIDTH: 100
ZLEVEL: 6
results:
OUTPUT:
hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6
type: rasterhash

0 comments on commit 781c10b

Please sign in to comment.