[Qgis-developer] Processing tests for gdal:extractprojection -> no output file

Matthias Kuhn matthias at opengis.ch
Thu Jan 12 04:54:10 PST 2017


Hi Matteo,

A quick look at the algorithm code shows, that there is no output with
the name OUTPUT defined in the algorithm. The name of the output file is
determined based on the input file.

There is no logic in place to handle such a case without writing custom
test logic (i.e. no yaml based test).

I wonder if it wouldn't be better to effectively "fix" the algorithm so
it will write the result to a defined location (configurable with an
output parameter). As far as I can tell, it's impossible to use the
output of this algorithm as input in another algorithm in a model the
way it currently stands.

Best regards
Matthias

On 01/11/2017 12:06 PM, matteo wrote:
> Hi Matthias (again),
> I'm facing some troubles with some gdal test in Processing when the
> output of the algorithm is a file and is not an html file (e.g. extract
> projection alg).
> 
> The output of the test is:
> 
>   - algorithm: gdal:extractprojection
>     name: Test (gdal:extractprojection)
>     params:
>       INPUT:
>         name: dem.tif
>         type: raster
>       PRJ_FILE: true
>     results: {}
> 
> 
> so i changed the result row in order to match (as regex) the single line
> of the prj file
> 
>     results:
>       OUTPUT:
>         name: expected/gdal/dem.html
>         type: regex
>         rules:
>          -
> 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
> 
> 
> but when I run the test, I always get this error:
> 
> : Traceback (most recent call last):
> 5:   File
> "/home/matteo/lavori/QGIS/QGIS/python/plugins/processing/tests/AlgorithmsTestBase.py",
> line 124, in check_algorithm
> 5:     self.check_results(alg.getOutputValuesAsDictionary(),
> defs['params'], defs['results'])
> 5:   File
> "/home/matteo/lavori/QGIS/QGIS/python/plugins/processing/tests/AlgorithmsTestBase.py",
> line 255, in check_results
> 5:     with open(results[id], 'r') as file:
> 5: KeyError: 'OUTPUT'
> 
> 
> 
> do ypu have any idea on how to solve this?
> 
> 
> Thanks again for your time!
> 
> Cheers
> 
> Matteo
> 


More information about the Qgis-developer mailing list