mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
commit
8582f6126f
@ -11,6 +11,7 @@ sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \
|
||||
cmake-data \
|
||||
doxygen \
|
||||
flex \
|
||||
gdal-bin \
|
||||
git \
|
||||
graphviz \
|
||||
grass-dev \
|
||||
|
@ -102,7 +102,7 @@ def createTest(text):
|
||||
definition['name'] = 'Test ({})'.format(cmdname)
|
||||
definition['algorithm'] = cmdname
|
||||
|
||||
params = []
|
||||
params = {}
|
||||
results = {}
|
||||
|
||||
i = 0
|
||||
@ -123,7 +123,7 @@ def createTest(text):
|
||||
if not schema:
|
||||
p['location'] = '[The source data is not in the testdata directory. Please use data in the processing/tests/testdata folder.]'
|
||||
|
||||
params.append(p)
|
||||
params[param.name] = p
|
||||
elif isinstance(param, ParameterRaster):
|
||||
filename = token[1:-1]
|
||||
schema, filepath = extractSchemaPath(filename)
|
||||
@ -134,7 +134,7 @@ def createTest(text):
|
||||
if not schema:
|
||||
p['location'] = '[The source data is not in the testdata directory. Please use data in the processing/tests/testdata folder.]'
|
||||
|
||||
params.append(p)
|
||||
params[param.name] = p
|
||||
elif isinstance(param, ParameterMultipleInput):
|
||||
multiparams = token[1:-1].split(';')
|
||||
newparam = []
|
||||
@ -151,9 +151,9 @@ def createTest(text):
|
||||
if not schema:
|
||||
p['location'] = '[The source data is not in the testdata directory. Please use data in the processing/tests/testdata folder.]'
|
||||
|
||||
params.append(p)
|
||||
params[param.name] = p
|
||||
else:
|
||||
params.append(token)
|
||||
params[param.name] = token
|
||||
|
||||
definition['params'] = params
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
test_algorithms.py
|
||||
AlgorithmsTest.py
|
||||
---------------------
|
||||
Date : January 2016
|
||||
Copyright : (C) 2016 by Matthias Kuhn
|
||||
@ -27,12 +27,12 @@ __revision__ = ':%H$'
|
||||
|
||||
import qgis
|
||||
import os
|
||||
import shutil
|
||||
import yaml
|
||||
import nose2
|
||||
import gdal
|
||||
import hashlib
|
||||
import tempfile
|
||||
import re
|
||||
|
||||
from osgeo.gdalconst import GA_ReadOnly
|
||||
|
||||
@ -46,11 +46,6 @@ from qgis.core import (
|
||||
QgsMapLayerRegistry
|
||||
)
|
||||
|
||||
from qgis.testing import (
|
||||
start_app,
|
||||
unittest
|
||||
)
|
||||
|
||||
from utilities import (
|
||||
unitTestDataPath
|
||||
)
|
||||
@ -60,25 +55,13 @@ def processingTestDataPath():
|
||||
return os.path.join(os.path.dirname(__file__), 'testdata')
|
||||
|
||||
|
||||
class TestAlgorithms(unittest.TestCase):
|
||||
|
||||
@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)
|
||||
class AlgorithmsTest():
|
||||
|
||||
def test_algorithms(self):
|
||||
"""
|
||||
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
|
||||
"""
|
||||
with open(os.path.join(processingTestDataPath(), 'algorithm_tests.yaml'), 'r') as stream:
|
||||
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
|
||||
algorithm_tests = yaml.load(stream)
|
||||
|
||||
for algtest in algorithm_tests['tests']:
|
||||
@ -104,8 +87,8 @@ class TestAlgorithms(unittest.TestCase):
|
||||
for r, p in defs['results'].iteritems():
|
||||
alg.setOutputValue(r, self.load_result_param(p))
|
||||
|
||||
self.assertTrue(AlgorithmExecutor.runalg(alg))
|
||||
print(alg.getAsCommand())
|
||||
self.assertTrue(AlgorithmExecutor.runalg(alg))
|
||||
self.check_results(alg.getOutputValuesAsDictionary(), defs['results'])
|
||||
|
||||
def load_params(self, params):
|
||||
@ -133,21 +116,27 @@ class TestAlgorithms(unittest.TestCase):
|
||||
# No type specified, use whatever is there
|
||||
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):
|
||||
"""
|
||||
Loads a result parameter. Creates a temporary destination where the result should go to and returns this location
|
||||
so it can be sent to the algorithm as parameter.
|
||||
"""
|
||||
if param['type'] in ['vector', 'file']:
|
||||
if param['type'] in ['vector', 'file', 'regex']:
|
||||
outdir = tempfile.mkdtemp()
|
||||
self.cleanup_paths.append(outdir)
|
||||
basename = os.path.basename(param['name'])
|
||||
filepath = os.path.join(outdir, basename)
|
||||
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):
|
||||
"""
|
||||
@ -188,10 +177,7 @@ class TestAlgorithms(unittest.TestCase):
|
||||
|
||||
result_lyr = QgsVectorLayer(results[id], id, 'ogr')
|
||||
|
||||
try:
|
||||
compare = expected_result['compare']
|
||||
except KeyError:
|
||||
compare = {}
|
||||
compare = expected_result.get('compare', {})
|
||||
|
||||
self.assertLayersEqual(expected_lyr, result_lyr, compare=compare)
|
||||
|
||||
@ -205,6 +191,12 @@ class TestAlgorithms(unittest.TestCase):
|
||||
result_filepath = results[id]
|
||||
|
||||
self.assertFilesEqual(expected_filepath, result_filepath)
|
||||
elif 'regex' == expected_result['type']:
|
||||
with open(results[id], 'r') as file:
|
||||
data = file.read()
|
||||
|
||||
for rule in expected_result.get('rules', []):
|
||||
self.assertRegexpMatches(data, rule)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
@ -7,5 +7,6 @@ PLUGIN_INSTALL(processing tests/data ${TEST_DATA_FILES})
|
||||
IF(ENABLE_TESTS)
|
||||
INCLUDE(UsePythonTest)
|
||||
ADD_PYTHON_TEST(ProcessingParametersTest ParametersTest.py)
|
||||
ADD_PYTHON_TEST(ProcessingAlgorithmsTest AlgorithmsTest.py)
|
||||
ADD_PYTHON_TEST(ProcessingQgisAlgorithmsTest QgisAlgorithmsTest.py)
|
||||
ADD_PYTHON_TEST(ProcessingGdalAlgorithmsTest GdalAlgorithmsTest.py)
|
||||
ENDIF(ENABLE_TESTS)
|
||||
|
58
python/plugins/processing/tests/GdalAlgorithmsTest.py
Normal file
58
python/plugins/processing/tests/GdalAlgorithmsTest.py
Normal file
@ -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()
|
@ -1,180 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
GdalTest.py
|
||||
---------------------
|
||||
Date : April 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'April 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from osgeo import gdal
|
||||
from osgeo.gdalconst import GA_ReadOnly
|
||||
|
||||
import processing
|
||||
from processing.tools import dataobjects
|
||||
from processing.tools.system import getTempFilename
|
||||
|
||||
from processing.tests.TestData import raster, union
|
||||
|
||||
|
||||
class GdalTest(unittest.TestCase):
|
||||
|
||||
def test_gdalogrsieve(self):
|
||||
outputs = processing.runalg('gdalogr:sieve', raster(), 2, 0, None)
|
||||
output = outputs['dst_filename']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, -1353696889)
|
||||
|
||||
def test_gdalogrsieveWithUnsupportedOutputFormat(self):
|
||||
outputs = processing.runalg('gdalogr:sieve', raster(), 2, 0,
|
||||
getTempFilename('img'))
|
||||
output = outputs['dst_filename']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, -1353696889)
|
||||
|
||||
def test_gdalogrwarpreproject(self):
|
||||
outputs = processing.runalg(
|
||||
'gdalogr:warpreproject',
|
||||
raster(),
|
||||
'EPSG:23030',
|
||||
'EPSG:4326',
|
||||
0,
|
||||
0,
|
||||
'',
|
||||
None,
|
||||
)
|
||||
output = outputs['OUTPUT']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, -2021328784)
|
||||
|
||||
def test_gdalogrmerge(self):
|
||||
outputs = processing.runalg('gdalogr:merge', raster(), False, False,
|
||||
None)
|
||||
output = outputs['OUTPUT']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, -1353696889)
|
||||
|
||||
def test_gdalogrogr2ogr(self):
|
||||
outputs = processing.runalg('gdalogr:ogr2ogr', union(), 3, '', None)
|
||||
output = outputs['OUTPUT_LAYER']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = [
|
||||
'id',
|
||||
'poly_num_a',
|
||||
'poly_st_a',
|
||||
'id_2',
|
||||
'poly_num_b',
|
||||
'poly_st_b',
|
||||
]
|
||||
expectedtypes = [
|
||||
'Integer',
|
||||
'Real',
|
||||
'String',
|
||||
'Integer',
|
||||
'Real',
|
||||
'String',
|
||||
]
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(8, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = [
|
||||
'1',
|
||||
'1.1',
|
||||
'string a',
|
||||
'2',
|
||||
'1',
|
||||
'string a',
|
||||
]
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_gdalogrogr2ogrWrongExtension(self):
|
||||
outputs = processing.runalg('gdalogr:ogr2ogr', union(), 3, '',
|
||||
getTempFilename('wrongext'))
|
||||
output = outputs['OUTPUT_LAYER']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = [
|
||||
'id',
|
||||
'poly_num_a',
|
||||
'poly_st_a',
|
||||
'id_2',
|
||||
'poly_num_b',
|
||||
'poly_st_b',
|
||||
]
|
||||
expectedtypes = [
|
||||
'Integer',
|
||||
'Real',
|
||||
'String',
|
||||
'Integer',
|
||||
'Real',
|
||||
'String',
|
||||
]
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(8, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = [
|
||||
'1',
|
||||
'1.1',
|
||||
'string a',
|
||||
'2',
|
||||
'1',
|
||||
'string a',
|
||||
]
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.makeSuite(GdalTest, 'test')
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,71 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
GeoAlgorithmTest.py
|
||||
---------------------
|
||||
Date : March 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'March 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import unittest
|
||||
|
||||
import processing
|
||||
from processing.tools import dataobjects
|
||||
from processing.tools.system import getTempFilename
|
||||
|
||||
from processing.tests.TestData import points, polygons
|
||||
|
||||
|
||||
class GeoAlgorithmTest(unittest.TestCase):
|
||||
|
||||
def testWrongformat(self):
|
||||
outputs = processing.runalg('qgis:countpointsinpolygon', polygons(),
|
||||
points(), 'NUMPOINTS',
|
||||
getTempFilename('wrongext'))
|
||||
output = outputs['OUTPUT']
|
||||
self.assertTrue(output.endswith('shp'))
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['ID', 'POLY_NUM_A', 'POLY_ST_A', 'NUMPOINTS']
|
||||
expectedtypes = ['Integer', 'Real', 'String', 'Real']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(2, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['1', '1.1', 'string a', '6.0']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.makeSuite(GeoAlgorithmTest, 'test')
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,234 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
ModelerAlgorithmTest.py
|
||||
---------------------
|
||||
Date : March 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'March 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from osgeo import gdal
|
||||
from osgeo.gdalconst import GA_ReadOnly
|
||||
|
||||
import processing
|
||||
from processing.modeler import ModelerAlgorithmProvider
|
||||
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
|
||||
from processing.modeler.Providers import Providers
|
||||
from processing.tools import dataobjects
|
||||
|
||||
from processing.tests.TestData import points, polygons, union, raster
|
||||
|
||||
|
||||
class ModelerAlgorithmTest(unittest.TestCase):
|
||||
|
||||
def testCreateModel(self):
|
||||
pass
|
||||
|
||||
def testEditModelParameter(self):
|
||||
pass
|
||||
|
||||
def testEditModelAlgorithm(self):
|
||||
pass
|
||||
|
||||
def testRemoveAlgorithm(self):
|
||||
folder = \
|
||||
os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__),
|
||||
'models')
|
||||
modelfile = os.path.join(folder, 'noinputs.model')
|
||||
model = ModelerAlgorithm()
|
||||
model.openModel(modelfile)
|
||||
model.provider = Providers.providers['model']
|
||||
self.assertTrue(2, len(model.algs))
|
||||
self.assertFalse(model.removeAlgorithm(0))
|
||||
self.assertTrue(model.removeAlgorithm(len(model.algs) - 1))
|
||||
model.execute(None)
|
||||
outputs = model.outputs
|
||||
self.assertEquals(1, len(outputs))
|
||||
output = outputs[0].value
|
||||
self.assertTrue(os.path.exists(output))
|
||||
|
||||
def testRemoveParameter(self):
|
||||
folder = \
|
||||
os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__),
|
||||
'models')
|
||||
modelfile = os.path.join(folder, 'watersheds.model')
|
||||
model = ModelerAlgorithm()
|
||||
model.openModel(modelfile)
|
||||
self.assertTrue(2, len(model.parameters))
|
||||
self.assertFalse(model.removeParameter(0))
|
||||
self.assertTrue(2, len(model.parameters))
|
||||
|
||||
def testComputingDependecies(self):
|
||||
folder = \
|
||||
os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__),
|
||||
'models')
|
||||
modelfile = os.path.join(folder, 'watersheds.model')
|
||||
model = ModelerAlgorithm()
|
||||
model.openModel(modelfile)
|
||||
self.assertTrue(2, len(model.parameters))
|
||||
self.assertTrue(5, len(model.algs))
|
||||
dependent = model.getDependentAlgorithms(0)
|
||||
self.assertEquals([0, 1, 2, 3, 4], dependent)
|
||||
dependent = model.getDependentAlgorithms(1)
|
||||
self.assertEquals([1, 2, 3, 4], dependent)
|
||||
dependent = model.getDependentAlgorithms(2)
|
||||
self.assertEquals([2, 3, 4], dependent)
|
||||
dependent = model.getDependentAlgorithms(3)
|
||||
self.assertEquals([3, 4], dependent)
|
||||
dependent = model.getDependentAlgorithms(4)
|
||||
self.assertEquals([4], dependent)
|
||||
|
||||
depends = model.getDependsOnAlgorithms(0)
|
||||
self.assertEquals([], depends)
|
||||
depends = model.getDependsOnAlgorithms(1)
|
||||
self.assertEquals([0], depends)
|
||||
depends = model.getDependsOnAlgorithms(2)
|
||||
self.assertEquals([1, 0], depends)
|
||||
depends = model.getDependsOnAlgorithms(3)
|
||||
self.assertEquals([2, 1, 0], depends)
|
||||
depends = model.getDependsOnAlgorithms(4)
|
||||
self.assertEquals([3, 2, 1, 0], depends)
|
||||
|
||||
def test_modelersagagrass(self):
|
||||
outputs = processing.runalg('modeler:sagagrass', points(), None)
|
||||
output = outputs['CENTROIDS_ALG1']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['CAT']
|
||||
expectedtypes = ['Real']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(12, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['1']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POINT(270839.65586926 4458983.16267036)'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_modelersimplemodel(self):
|
||||
outputs = processing.runalg('modeler:simplemodel', raster(), None)
|
||||
output = outputs['SLOPE_ALG0']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, 1891122097)
|
||||
|
||||
def test_modelerfieldautoextent(self):
|
||||
outputs = processing.runalg('modeler:fieldautoextent', polygons(),
|
||||
'POLY_NUM_A', None)
|
||||
output = outputs['USER_GRID_ALG0']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, 2026100494)
|
||||
|
||||
def test_modelernotinorder(self):
|
||||
outputs = processing.runalg('modeler:notinorder', raster(), None)
|
||||
output = outputs['CAREA_ALG0']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, -1557050506)
|
||||
|
||||
def test_modeleroptionalfield(self):
|
||||
outputs = processing.runalg('modeler:optionalfield', points(), None)
|
||||
output = outputs['OUTPUT_ALG0']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['id', 'value', 'area', 'perim']
|
||||
expectedtypes = ['Integer', 'String', 'Real', 'Real']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(1, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['0', 'all', '3592.818848', '230.989919']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POLYGON((270839.46818665 4458921.97813894,270778.60197966 4458935.96883677,270786.54279065 4458980.04784113,270803.15756434 4458983.84880322,270839.65586926 4458983.16267036,270855.74530134 4458940.79948673,270839.46818665 4458921.97813894))'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_modeleremptystring(self):
|
||||
outputs = processing.runalg('modeler:emptystring', union(), None)
|
||||
output = outputs['OUTPUT_LAYER_ALG0']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = [
|
||||
'ID',
|
||||
'POLY_NUM_A',
|
||||
'POLY_ST_A',
|
||||
'ID_2',
|
||||
'POLY_NUM_B',
|
||||
'POLY_ST_B',
|
||||
'NewField',
|
||||
]
|
||||
expectedtypes = [
|
||||
'Integer',
|
||||
'Real',
|
||||
'String',
|
||||
'Integer',
|
||||
'Real',
|
||||
'String',
|
||||
'Integer',
|
||||
]
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(8, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = [
|
||||
'1',
|
||||
'1.1',
|
||||
'string a',
|
||||
'2',
|
||||
'1',
|
||||
'string a',
|
||||
'10',
|
||||
]
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.makeSuite(ModelerAlgorithmTest, 'test')
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,64 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
PackagingTests.py
|
||||
---------------------
|
||||
Date : May 2015
|
||||
Copyright : (C) 2015 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'May 2015'
|
||||
__copyright__ = '(C) 2015, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
|
||||
'''
|
||||
Tests to ensure that a QGIS installation contains Processing dependencies
|
||||
and they are correctly configured by default
|
||||
'''
|
||||
import unittest
|
||||
import sys
|
||||
from processing.algs.saga.SagaUtils import *
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
from processing.algs.grass.GrassUtils import GrassUtils
|
||||
from processing.algs.otb import OTBUtils
|
||||
|
||||
|
||||
class PackageTests(unittest.TestCase):
|
||||
|
||||
def testSaga(self):
|
||||
folder = ProcessingConfig.getSetting(SAGA_FOLDER)
|
||||
ProcessingConfig.removeSetting(SAGA_FOLDER)
|
||||
self.assertTrue(getSagaInstalledVersion(True) in ["2.1.2", "2.1.3", "2.1.4"])
|
||||
ProcessingConfig.setSettingValue(SAGA_FOLDER, folder)
|
||||
|
||||
def testGrass(self):
|
||||
folder = ProcessingConfig.getSetting(GrassUtils.GRASS_FOLDER)
|
||||
ProcessingConfig.removeSetting(GrassUtils.GRASS_FOLDER)
|
||||
msg = GrassUtils.checkGrassIsInstalled()
|
||||
self.assertIsNone(msg)
|
||||
ProcessingConfig.setSettingValue(GrassUtils.GRASS_FOLDER, folder)
|
||||
|
||||
def testOtb(self):
|
||||
folder = OTBUtils.findOtbPath()
|
||||
self.assertIsNotNone(folder)
|
||||
|
||||
|
||||
def runTests():
|
||||
t = unittest.TestLoader().loadTestsFromTestCase(PackageTests)
|
||||
unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(t)
|
@ -1,55 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
ProcessingTests.py
|
||||
---------------------
|
||||
Date : April 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'April 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import unittest
|
||||
from processing.tests import QgisAlgsTest
|
||||
from processing.tests import ModelerAlgorithmTest
|
||||
from processing.tests import ProcessingToolsTest
|
||||
from processing.tests import ScriptTest
|
||||
from processing.tests import SagaTest
|
||||
from processing.tests import GeoAlgorithmTest
|
||||
from processing.tests import GdalTest
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTests(QgisAlgsTest.suite())
|
||||
suite.addTests(ModelerAlgorithmTest.suite())
|
||||
suite.addTests(SagaTest.suite())
|
||||
suite.addTests(GdalTest.suite())
|
||||
suite.addTests(ScriptTest.suite())
|
||||
suite.addTests(ProcessingToolsTest.suite())
|
||||
#suite.addTests(ParametersTest.suite())
|
||||
suite.addTests(GeoAlgorithmTest.suite())
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,91 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
ProcessingToolsTest.py
|
||||
---------------------
|
||||
Date : April 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'April 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import unittest
|
||||
|
||||
import processing
|
||||
from processing.tools.vector import values
|
||||
from processing.tools.dataobjects import getObjectFromName
|
||||
|
||||
from processing.tests.TestData import points, polygons
|
||||
|
||||
|
||||
class ProcessingToolsTest(unittest.TestCase):
|
||||
|
||||
'''Tests the method imported when doing an "import processing", and
|
||||
also in processing.tools. They are mostly convenience tools.
|
||||
'''
|
||||
|
||||
def test_getobject(self):
|
||||
layer = processing.getObject(points())
|
||||
self.assertIsNotNone(layer)
|
||||
layer = processing.getObject('points')
|
||||
self.assertIsNotNone(layer)
|
||||
|
||||
def test_runandload(self):
|
||||
processing.runandload('qgis:countpointsinpolygon', polygons(),
|
||||
points(), 'NUMPOINTS', None)
|
||||
layer = getObjectFromName('Result')
|
||||
self.assertIsNotNone(layer)
|
||||
|
||||
def test_featuresWithoutSelection(self):
|
||||
layer = processing.getObject(points())
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(12, len(features))
|
||||
|
||||
def test_featuresWithSelection(self):
|
||||
layer = processing.getObject(points())
|
||||
feature = layer.getFeatures().next()
|
||||
selected = [feature.id()]
|
||||
layer.setSelectedFeatures(selected)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(1, len(features))
|
||||
layer.setSelectedFeatures([])
|
||||
|
||||
def test_attributeValues(self):
|
||||
layer = processing.getObject(points())
|
||||
attributeValues = values(layer, 'ID')
|
||||
i = 1
|
||||
for value in attributeValues['ID']:
|
||||
self.assertEqual(int(i), int(value))
|
||||
i += 1
|
||||
self.assertEquals(13, i)
|
||||
|
||||
def test_extent(self):
|
||||
pass
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.makeSuite(ProcessingToolsTest, 'test')
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
58
python/plugins/processing/tests/QgisAlgorithmsTest.py
Normal file
58
python/plugins/processing/tests/QgisAlgorithmsTest.py
Normal file
@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
QgisAlgorithmTests.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 TestQgisAlgorithms(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 'qgis_algorithm_tests.yaml'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
nose2.main()
|
File diff suppressed because one or more lines are too long
@ -1,101 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
RunAlgTest.py
|
||||
---------------------
|
||||
Date : March 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'March 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import unittest
|
||||
import processing
|
||||
from processing.tools import dataobjects
|
||||
from processing.tools.system import getTempFilename
|
||||
|
||||
from processing.tests.TestData import points, polygons
|
||||
|
||||
|
||||
class ParametrizedTestCase(unittest.TestCase):
|
||||
|
||||
def __init__(self, methodName='runTest', useTempFiles=False):
|
||||
super(ParametrizedTestCase, self).__init__(methodName)
|
||||
self.useTempFiles = useTempFiles
|
||||
|
||||
@staticmethod
|
||||
def parametrize(testcase_klass, useTempFiles):
|
||||
testloader = unittest.TestLoader()
|
||||
testnames = testloader.getTestCaseNames(testcase_klass)
|
||||
suite = unittest.TestSuite()
|
||||
for name in testnames:
|
||||
suite.addTest(testcase_klass(name, useTempFiles=useTempFiles))
|
||||
return suite
|
||||
|
||||
|
||||
class RunAlgTest(ParametrizedTestCase):
|
||||
|
||||
"""This test takes a reduced set of algorithms and executes them in
|
||||
different ways, changing parameters such as whether to use temp
|
||||
outputs, the output file format, etc.
|
||||
|
||||
Basically, it uses some algorithms to test other parts of the
|
||||
Processign framework, not the algorithms themselves
|
||||
"""
|
||||
|
||||
def getOutputFile(self):
|
||||
if self.useTempFiles:
|
||||
return None
|
||||
else:
|
||||
return getTempFilename('shp')
|
||||
|
||||
def test_qgiscountpointsinpolygon(self):
|
||||
outputs = processing.runalg('qgis:countpointsinpolygon', polygons(),
|
||||
points(), 'NUMPOINTS',
|
||||
self.getOutputFile())
|
||||
output = outputs['OUTPUT']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['ID', 'POLY_NUM_A', 'POLY_ST_A', 'NUMPOINTS']
|
||||
expectedtypes = ['Integer', 'Real', 'String', 'Real']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(2, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['1', '1.1', 'string a', '6']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(ParametrizedTestCase.parametrize(RunAlgTest, False))
|
||||
suite.addTest(ParametrizedTestCase.parametrize(RunAlgTest, True))
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,139 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
SagaTest.py
|
||||
---------------------
|
||||
Date : March 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'March 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from osgeo import gdal
|
||||
from osgeo.gdalconst import GA_ReadOnly
|
||||
|
||||
import processing
|
||||
from processing.tools import dataobjects
|
||||
from processing.tools.system import getTempFilename
|
||||
|
||||
from processing.tests.TestData import polygons2, polygonsGeoJson, raster
|
||||
|
||||
|
||||
class SagaTest(unittest.TestCase):
|
||||
|
||||
"""Tests for saga algorithms"""
|
||||
|
||||
def test_sagametricconversions(self):
|
||||
outputs = processing.runalg('saga:metricconversions', raster(), 0,
|
||||
None)
|
||||
output = outputs['CONV']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, -2137931723)
|
||||
|
||||
def test_sagasortgrid(self):
|
||||
outputs = processing.runalg('saga:sortgrid', raster(), True, None)
|
||||
output = outputs['OUTPUT']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, 1320073153)
|
||||
|
||||
def test_SagaVectorAlgorithmWithSelection(self):
|
||||
layer = processing.getObject(polygons2())
|
||||
feature = layer.getFeatures().next()
|
||||
selected = [feature.id()]
|
||||
layer.setSelectedFeatures(selected)
|
||||
outputs = processing.runalg('saga:polygoncentroids', polygons2(),
|
||||
True, None)
|
||||
layer.setSelectedFeatures([])
|
||||
output = outputs['CENTROIDS']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['ID', 'POLY_NUM_B', 'POLY_ST_B']
|
||||
expectedtypes = ['Real', 'Real', 'String']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(1, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['2', '1', 'string a']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POINT(270806.69221918 4458924.97720492)'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
|
||||
"""This tests both the exporting to shp and then the format
|
||||
change in the output layer.
|
||||
"""
|
||||
|
||||
layer = processing.getObject(polygonsGeoJson())
|
||||
feature = layer.getFeatures().next()
|
||||
selected = [feature.id()]
|
||||
layer.setSelectedFeatures(selected)
|
||||
outputs = processing.runalg('saga:polygoncentroids',
|
||||
polygonsGeoJson(), True,
|
||||
getTempFilename('geojson'))
|
||||
layer.setSelectedFeatures([])
|
||||
output = outputs['CENTROIDS']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['ID', 'POLY_NUM_A', 'POLY_ST_A']
|
||||
expectedtypes = ['Real', 'Real', 'String']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(1, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['0', '1.1', 'string a']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POINT(270787.49991451 4458955.46775295)'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self):
|
||||
outputs = processing.runalg('saga:convergenceindex', raster(), 0, 0,
|
||||
getTempFilename('img'))
|
||||
output = outputs['RESULT']
|
||||
self.assertTrue(os.path.isfile(output))
|
||||
dataset = gdal.Open(output, GA_ReadOnly)
|
||||
strhash = hash(unicode(dataset.ReadAsArray(0).tolist()))
|
||||
self.assertEqual(strhash, 485390137)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.makeSuite(SagaTest, 'test')
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,98 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
ScriptTest.py
|
||||
---------------------
|
||||
Date : March 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = 'Victor Olaya'
|
||||
__date__ = 'March 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import unittest
|
||||
import processing
|
||||
from processing.tools import dataobjects
|
||||
|
||||
from processing.tests.TestData import polygons, union
|
||||
|
||||
|
||||
class ScriptTest(unittest.TestCase):
|
||||
|
||||
"""Tests that use scripts."""
|
||||
|
||||
def test_scriptcreatetilingfromvectorlayer(self):
|
||||
outputs = processing.runalg('script:createtilingfromvectorlayer',
|
||||
union(), 10, None)
|
||||
output = outputs['polygons']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['longitude', 'latitude']
|
||||
expectedtypes = ['Real', 'Real']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(10, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['270761.415396242', '4458948.29588823']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POLYGON((270755.54427424 4458901.23378639,270755.54427424 4458995.35799007,270767.28651824 4458995.35799007,270767.28651824 4458901.23378639,270755.54427424 4458901.23378639))'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_scripthexgridfromlayerbounds(self):
|
||||
outputs = processing.runalg('script:hexgridfromlayerbounds',
|
||||
polygons(), 10, None)
|
||||
output = outputs['grid']
|
||||
layer = dataobjects.getObjectFromUri(output, True)
|
||||
fields = layer.pendingFields()
|
||||
expectednames = ['longitude', 'latitude']
|
||||
expectedtypes = ['Real', 'Real']
|
||||
names = [unicode(f.name()) for f in fields]
|
||||
types = [unicode(f.typeName()) for f in fields]
|
||||
self.assertEqual(expectednames, names)
|
||||
self.assertEqual(expectedtypes, types)
|
||||
features = processing.features(layer)
|
||||
self.assertEqual(117, len(features))
|
||||
feature = features.next()
|
||||
attrs = feature.attributes()
|
||||
expectedvalues = ['270765.621834001', '4458907.27146471']
|
||||
values = [unicode(attr) for attr in attrs]
|
||||
self.assertEqual(expectedvalues, values)
|
||||
wkt = 'POLYGON((270771.39533669 4458907.27146471,270768.50858535 4458902.27146471,270762.73508265 4458902.27146471,270759.84833131 4458907.27146471,270762.73508265 4458912.27146471,270768.50858535 4458912.27146471,270771.39533669 4458907.27146471))'
|
||||
self.assertEqual(wkt, unicode(feature.geometry().exportToWkt()))
|
||||
|
||||
def test_scriptascriptthatreturnsanumber(self):
|
||||
outputs = processing.runalg('script:ascriptthatreturnsanumber')
|
||||
output = outputs['number']
|
||||
self.assertTrue(10, output)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.makeSuite(ScriptTest, 'test')
|
||||
return suite
|
||||
|
||||
|
||||
def runtests():
|
||||
result = unittest.TestResult()
|
||||
testsuite = suite()
|
||||
testsuite.run(result)
|
||||
return result
|
@ -1,109 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
InaSAFE Disaster risk assessment tool developed by AusAid -
|
||||
**QGIS plugin implementation.**
|
||||
|
||||
Contact : ole.moller.nielsen@gmail.com
|
||||
|
||||
.. note:: 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.
|
||||
|
||||
.. note:: This source code was copied from the 'postgis viewer' application
|
||||
with original authors:
|
||||
Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk
|
||||
Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org
|
||||
|
||||
"""
|
||||
|
||||
__author__ = 'tim@linfiniti.com'
|
||||
__version__ = '0.3.0'
|
||||
__date__ = '10/01/2011'
|
||||
__copyright__ = 'Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk \
|
||||
and Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org'
|
||||
|
||||
from PyQt4.QtCore import QObject
|
||||
from qgis.core import QgsMapLayerRegistry
|
||||
from qgis.core import QgsRasterLayer, QgsVectorLayer
|
||||
|
||||
|
||||
class QgisInterface(QObject):
|
||||
|
||||
"""Class to expose qgis objects and functionalities to plugins.
|
||||
|
||||
This class is here for enabling us to run unit tests only,
|
||||
so most methods are simply stubs.
|
||||
"""
|
||||
|
||||
def __init__(self, canvas):
|
||||
"""Constructor"""
|
||||
QObject.__init__(self)
|
||||
self.canvas = canvas
|
||||
self.testRaster = QgsRasterLayer('data/raster', 'raster')
|
||||
self.testVector = QgsVectorLayer('data/vector', 'vector', 'ogr')
|
||||
QgsMapLayerRegistry.instance().addMapLayers([self.testRaster,
|
||||
self.testVector])
|
||||
|
||||
self.statusBar = type('FakeStatusBar', (), {'showMessage': lambda _,
|
||||
m: None})()
|
||||
|
||||
def zoomFull(self):
|
||||
"""Zoom to the map full extent"""
|
||||
pass
|
||||
|
||||
def zoomToPrevious(self):
|
||||
"""Zoom to previous view extent"""
|
||||
pass
|
||||
|
||||
def zoomToNext(self):
|
||||
"""Zoom to next view extent"""
|
||||
pass
|
||||
|
||||
def addVectorLayer(self, vectorLayerPath, baseName, providerKey):
|
||||
"""Add a vector layer"""
|
||||
pass
|
||||
|
||||
def addRasterLayer(self, rasterLayerPath, baseName):
|
||||
"""Add a raster layer given a raster layer file name"""
|
||||
pass
|
||||
|
||||
def activeLayer(self):
|
||||
"""Get pointer to the active layer (layer selected in the legend)"""
|
||||
myLayers = QgsMapLayerRegistry.instance().mapLayers()
|
||||
for myItem in myLayers:
|
||||
return myLayers[myItem]
|
||||
|
||||
def addToolBarIcon(self, qAction):
|
||||
"""Add an icon to the plugins toolbar"""
|
||||
pass
|
||||
|
||||
def removeToolBarIcon(self, qAction):
|
||||
"""Remove an action (icon) from the plugin toolbar"""
|
||||
pass
|
||||
|
||||
def addToolBar(self, name):
|
||||
"""Add toolbar with specified name"""
|
||||
pass
|
||||
|
||||
def mapCanvas(self):
|
||||
"""Return a pointer to the map canvas"""
|
||||
return self.canvas
|
||||
|
||||
def mainWindow(self):
|
||||
"""Return a pointer to the main window.
|
||||
|
||||
In case of QGIS it returns an instance of QgisApp
|
||||
"""
|
||||
|
||||
return type('FakeMainWindow', (), {'statusBar': lambda _:
|
||||
self.statusBar})()
|
||||
|
||||
def addDockWidget(self, area, dockwidget):
|
||||
"""Add a dock widget to the main window"""
|
||||
pass
|
||||
|
||||
def legendInterface(self):
|
||||
return type('FakeLInterface', (), {'layers': lambda _:
|
||||
[self.testRaster, self.testVector]})()
|
@ -1,262 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
InaSAFE Disaster risk assessment tool developed by AusAid -
|
||||
**QGIS plugin test suite.**
|
||||
|
||||
Contact : ole.moller.nielsen@gmail.com
|
||||
|
||||
.. note:: 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__ = 'tim@linfiniti.com'
|
||||
__version__ = '0.3.0'
|
||||
__date__ = '10/01/2011'
|
||||
__copyright__ = \
|
||||
'Copyright 2012, Australia Indonesia Facility for Disaster Reduction'
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import qgis
|
||||
|
||||
import processing
|
||||
from processing.ProcessingPlugin import ProcessingPlugin
|
||||
from processing.core.Processing import Processing
|
||||
from processing.gui.AlgorithmDialog import AlgorithmDialog
|
||||
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
|
||||
from processing.modeler.Providers import Providers
|
||||
from processing.parameters.ParameterRaster import ParameterRaster
|
||||
from processing.parameters.ParameterVector import ParameterVector
|
||||
from processing.parameters.ParameterNumber import ParameterNumber
|
||||
from processing.parameters.ParameterString import ParameterString
|
||||
from processing.parameters.ParameterBoolean import ParameterBoolean
|
||||
from processing.core.outputs import OutputRaster
|
||||
from processing.core.outputs import OutputVector
|
||||
|
||||
from utilities_test import getQgisTestApp
|
||||
|
||||
# Add parent directory to path to make test aware of other modules
|
||||
|
||||
pardir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
sys.path.append(pardir)
|
||||
|
||||
sys.path.append(qgis.utils.sys_plugin_path)
|
||||
|
||||
(QGISAPP, CANVAS, IFACE, PARENT) = getQgisTestApp()
|
||||
|
||||
|
||||
class bcolors:
|
||||
|
||||
INFO = '\033[94m'
|
||||
WARNING = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
|
||||
|
||||
class ProcessingPluginTest(unittest.TestCase):
|
||||
|
||||
"""Test suite for Processing QGis plugin."""
|
||||
|
||||
def test_createplugin(self):
|
||||
"""Initialize plugin."""
|
||||
|
||||
self.processingplugin = ProcessingPlugin(IFACE)
|
||||
self.assertIsNotNone(self.processingplugin)
|
||||
|
||||
def test_processing_alglist(self):
|
||||
"""Test alglist"""
|
||||
|
||||
self.processingplugin = ProcessingPlugin(IFACE)
|
||||
self.providerToAlgs = Processing.algs
|
||||
self.assertTrue(self.providerToAlgs, 'Alg list')
|
||||
|
||||
|
||||
class ProcessingProviderTestCase(unittest.TestCase):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
algId,
|
||||
alg,
|
||||
threaded,
|
||||
dialog='none',
|
||||
):
|
||||
self.algId = algId
|
||||
self.alg = alg
|
||||
self.threaded = threaded
|
||||
self.msg = 'ALG %s (%s %s)' % (self.algId, {True: 'threaded',
|
||||
False: 'unthreaded'}[threaded], dialog)
|
||||
unittest.TestCase.__init__(self, 'runalg_%s' % dialog)
|
||||
|
||||
def gen_test_parameters(self, alg, doSet=False):
|
||||
b = False
|
||||
for p in alg.parameters:
|
||||
if isinstance(p, ParameterRaster):
|
||||
l = IFACE.testRaster
|
||||
if doSet:
|
||||
p.setValue(l)
|
||||
yield l
|
||||
elif isinstance(p, ParameterVector):
|
||||
l = IFACE.testVector
|
||||
if doSet:
|
||||
p.setValue(l)
|
||||
yield l
|
||||
elif isinstance(p, ParameterNumber):
|
||||
n = 42
|
||||
if p.max:
|
||||
n = p.max
|
||||
elif p.min:
|
||||
n = p.min
|
||||
if doSet:
|
||||
p.setValue(n)
|
||||
yield n
|
||||
elif isinstance(p, ParameterString):
|
||||
s = 'Test string'
|
||||
if doSet:
|
||||
p.setValue(s)
|
||||
yield s
|
||||
elif isinstance(p, ParameterBoolean):
|
||||
b = not b
|
||||
if doSet:
|
||||
p.setValue(b)
|
||||
yield b
|
||||
else:
|
||||
if doSet:
|
||||
p.setValue(None)
|
||||
yield None
|
||||
i = 0
|
||||
for o in alg.outputs:
|
||||
if o.hidden:
|
||||
continue
|
||||
i = i + 1
|
||||
outbasename = self.msg.replace('/', '-')
|
||||
if isinstance(o, OutputRaster):
|
||||
fn = 'outputs/%s - %i.tif' % (outbasename, i)
|
||||
if doSet:
|
||||
o.setValue(fn)
|
||||
yield fn
|
||||
elif isinstance(o, OutputVector):
|
||||
fn = 'outputs/%s - %i.shp' % (outbasename, i)
|
||||
if doSet:
|
||||
o.setValue(fn)
|
||||
yield fn
|
||||
else:
|
||||
if doSet:
|
||||
o.setValue(None)
|
||||
yield None
|
||||
|
||||
def setUp(self):
|
||||
print
|
||||
print bcolors.INFO, self.msg, bcolors.ENDC,
|
||||
print 'Parameters: ', self.alg.parameters,
|
||||
print 'Outputs: ', [out for out in self.alg.outputs
|
||||
if not out.hidden],
|
||||
self.args = list(self.gen_test_parameters(self.alg, True))
|
||||
print ' => ', self.args, bcolors.WARNING,
|
||||
|
||||
def runalg_none(self):
|
||||
result = processing.runalg(self.alg, *self.args)
|
||||
print bcolors.ENDC
|
||||
self.assertIsNotNone(result, self.msg)
|
||||
if not result:
|
||||
return
|
||||
for p in result.values():
|
||||
if isinstance(p, str):
|
||||
self.assertTrue(os.path.exists(p), 'Output %s exists' % p)
|
||||
|
||||
def runalg_parameters(self):
|
||||
dlg = self.alg.getCustomParametersDialog()
|
||||
if not dlg:
|
||||
dlg = AlgorithmDialog(self.alg)
|
||||
|
||||
# Hack to handle that hacky code...
|
||||
dlg.setParamValues = lambda: True
|
||||
dlg.show()
|
||||
dlg.accept()
|
||||
while not dlg.executed:
|
||||
time.sleep(.5)
|
||||
|
||||
def tearDown(self):
|
||||
print bcolors.ENDC
|
||||
|
||||
|
||||
def algSuite(dialog='none', threaded=True, unthreaded=True,
|
||||
provider=None, algName=None):
|
||||
s = unittest.TestSuite()
|
||||
for (provider, algs) in Processing.algs.items():
|
||||
if not algs.items():
|
||||
print bcolors.WARNING, 'WARNING: %s seems to provide no algs!' \
|
||||
% provider,
|
||||
print bcolors.ENDC
|
||||
continue
|
||||
(algId, alg) = algs.items()[-1]
|
||||
if threaded:
|
||||
s.addTest(ProcessingProviderTestCase(algId, alg, True, dialog))
|
||||
if unthreaded:
|
||||
s.addTest(ProcessingProviderTestCase(algId, alg, False, dialog))
|
||||
return s
|
||||
|
||||
|
||||
def modelSuite(modelFile, dialog='none', threaded=True, unthreaded=True):
|
||||
s = unittest.TestSuite()
|
||||
model = ModelerAlgorithm()
|
||||
model.openModel(modelFile)
|
||||
if model.provider is None:
|
||||
# Might happen if model is opened from modeler dialog
|
||||
model.provider = Providers.providers['model']
|
||||
if threaded:
|
||||
s.addTest(ProcessingProviderTestCase(modelFile, model, True, dialog))
|
||||
if unthreaded:
|
||||
s.addTest(ProcessingProviderTestCase(modelFile, model, False, dialog))
|
||||
return s
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Processing test suite.')
|
||||
parser.add_argument('-l', action='store_true',
|
||||
help='Test processing loading only. Ignore further arguments.')
|
||||
parser.add_argument('-m', dest='model', help='Test a particular model.',
|
||||
default=None)
|
||||
parser.add_argument('-d', dest='dialog', help='Test a particular dialog.',
|
||||
default='none')
|
||||
parser.add_argument('-t', dest='tOnly', action='store_true',
|
||||
help='Enable threaded execution only.')
|
||||
parser.add_argument('-u', dest='uOnly', action='store_true',
|
||||
help='Enable unthreaded execution only.')
|
||||
parser.add_argument('-r', dest='raster',
|
||||
help='Use specified raster as input.',
|
||||
default='data/raster')
|
||||
parser.add_argument('-v', dest='vector',
|
||||
help='Use specified vectro as input.',
|
||||
default='data/vector')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
threaded = not args.uOnly or args.tOnly
|
||||
unthreaded = not args.tOnly or args.uOnly
|
||||
|
||||
try:
|
||||
loadSuite = \
|
||||
unittest.TestLoader().loadTestsFromTestCase(ProcessingPluginTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(loadSuite)
|
||||
if args.l:
|
||||
exit(0)
|
||||
if not os.path.exists(args.raster) or not os.path.exists(args.vector):
|
||||
print 'No data under %s or %s. Run with -h argument for help' \
|
||||
% (args.raster, args.vector)
|
||||
exit(1)
|
||||
if args.model:
|
||||
unittest.TextTestRunner(verbosity=2).run(modelSuite(args.model
|
||||
or 'data/model', args.dialog, threaded, unthreaded))
|
||||
exit(0)
|
||||
unittest.TextTestRunner(verbosity=2).run(algSuite(args.dialog,
|
||||
threaded, unthreaded, args.dialog))
|
||||
except KeyboardInterrupt:
|
||||
print bcolors.ENDC, 'Test interrupted.'
|
21
python/plugins/processing/tests/testdata/expected/gdal/layer_info.html
vendored
Normal file
21
python/plugins/processing/tests/testdata/expected/gdal/layer_info.html
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<pre>Had to open data source read-only.
|
||||
INFO: Open of `/home/mku/dev/cpp/qgis/QGIS/python/plugins/processing/tests/testdata/lines.gml'
|
||||
using driver `GML' successful.
|
||||
|
||||
Layer name: lines
|
||||
Geometry: Line String
|
||||
Feature Count: 6
|
||||
Extent: (-1.000000, -3.000000) - (11.000000, 5.000000)
|
||||
Layer SRS WKT:
|
||||
GEOGCS["WGS 84",
|
||||
DATUM["WGS_1984",
|
||||
SPHEROID["WGS 84",6378137,298.257223563,
|
||||
AUTHORITY["EPSG","7030"]],
|
||||
AUTHORITY["EPSG","6326"]],
|
||||
PRIMEM["Greenwich",0,
|
||||
AUTHORITY["EPSG","8901"]],
|
||||
UNIT["degree",0.0174532925199433,
|
||||
AUTHORITY["EPSG","9122"]],
|
||||
AUTHORITY["EPSG","4326"]]
|
||||
fid: String (0.0) NOT NULL
|
||||
</pre>
|
43
python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml
vendored
Normal file
43
python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# See ../README.md for a description of the file format
|
||||
|
||||
tests:
|
||||
# MK: 23.2.2016 / Fails on travis:OSX
|
||||
# - 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
|
||||
- algorithm: gdalogr:information
|
||||
name: GDAL ogrinfo
|
||||
params:
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
SUMMARY_ONLY: 'True'
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/layer_info.html
|
||||
type: regex
|
||||
rules:
|
||||
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
|
||||
- 'Geometry: Line String'
|
||||
- 'Feature Count: 6'
|
@ -195,7 +195,7 @@ def load(fileName, name=None, crs=None, style=None):
|
||||
if prjSetting:
|
||||
settings.setValue('/Projections/defaultBehaviour', prjSetting)
|
||||
raise RuntimeError('Could not load layer: ' + unicode(fileName)
|
||||
+ '\nCheck the procesing framework log to look for errors')
|
||||
+ '\nCheck the processing framework log to look for errors')
|
||||
if prjSetting:
|
||||
settings.setValue('/Projections/defaultBehaviour', prjSetting)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user