Skip to content
Permalink
Browse files

[processing] Allow alg tests to use ParameterTable inputs

  • Loading branch information
nyalldawson committed Nov 23, 2016
1 parent 7726205 commit 69e8e4a3c237bd7a240912ccd54c93a4a166e167
@@ -56,7 +56,8 @@
ParameterFile,
ParameterString,
ParameterNumber,
ParameterBoolean
ParameterBoolean,
ParameterTable
)


@@ -172,6 +173,16 @@ 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[param.name] = p
if isinstance(param, ParameterTable):
schema, filepath = extractSchemaPath(token)
p = {
'type': 'table',
'name': filepath
}
if not schema:
p['location'] = '[The source data is not in the testdata directory. Please use data in the processing/tests/testdata folder.]'

params[param.name] = p
elif isinstance(param, ParameterMultipleInput):
multiparams = token.split(';')
@@ -137,7 +137,7 @@ def load_param(self, param):
parameter based on its key `type` and return the appropriate parameter to pass to the algorithm.
"""
try:
if param['type'] == 'vector' or param['type'] == 'raster':
if param['type'] in ('vector', 'raster', 'table'):
return self.load_layer(param)
elif param['type'] == 'multi':
return [self.load_param(p) for p in param['params']]
@@ -154,7 +154,7 @@ 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', 'regex']:
if param['type'] in ['vector', 'file', 'table', 'regex']:
outdir = tempfile.mkdtemp()
self.cleanup_paths.append(outdir)
basename = os.path.basename(param['name'])
@@ -175,7 +175,7 @@ def load_layer(self, param):
"""
filepath = self.filepath_from_param(param)

if param['type'] == 'vector':
if param['type'] in ('vector', 'table'):
lyr = QgsVectorLayer(filepath, param['name'], 'ogr')
elif param['type'] == 'raster':
lyr = QgsRasterLayer(filepath, param['name'], 'gdal')
@@ -199,7 +199,7 @@ def check_results(self, results, expected):
Checks if result produced by an algorithm matches with the expected specification.
"""
for id, expected_result in list(expected.items()):
if 'vector' == expected_result['type']:
if expected_result['type'] in ('vector', 'table'):
expected_lyr = self.load_layer(expected_result)
try:
results[id]

0 comments on commit 69e8e4a

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