Skip to content

Commit

Permalink
Syntax highlighting for processing tests readme
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 1, 2016
1 parent e695fbb commit 9b9c692
Showing 1 changed file with 78 additions and 58 deletions.
136 changes: 78 additions & 58 deletions python/plugins/processing/tests/README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ This file is structured with [yaml syntax](http://www.yaml.org/start.html).


A basic test appears under the toplevel key `tests` and looks like this: A basic test appears under the toplevel key `tests` and looks like this:


- name: centroid ```yaml
algorithm: qgis:polygoncentroids - name: centroid
params: algorithm: qgis:polygoncentroids
- type: vector params:
name: polys.gml - type: vector
results: name: polys.gml
OUTPUT_LAYER: results:
type: vector OUTPUT_LAYER:
name: expected/polys_centroid.gml type: vector
name: expected/polys_centroid.gml
```
How To How To
------ ------
Expand All @@ -39,16 +41,18 @@ ones to params and the last one(s) to results.


The above translates to The above translates to


- name: densify ```yaml
algorithm: qgis:densifygeometriesgivenaninterval - name: densify
params: algorithm: qgis:densifygeometriesgivenaninterval
- type: vector params:
name: polys.gml - type: vector
- 2 # Interval name: polys.gml
results: - 2 # Interval
OUTPUT: results:
type: vector OUTPUT:
name: expected/polys_densify.gml type: vector
name: expected/polys_densify.gml
```


Params and results Params and results
------------------ ------------------
Expand All @@ -57,17 +61,21 @@ Params and results


Params and results are specified as lists or dictionaries: Params and results are specified as lists or dictionaries:


params: ```yaml
INTERVAL: 5 params:
INTERPOLATE: True INTERVAL: 5
NAME: A processing test INTERPOLATE: True
NAME: A processing test
```

or or


params: ```yaml
- 2 params:
- string - 2
- another param - string
- another param
```


### Layer type parameters ### Layer type parameters


Expand All @@ -80,13 +88,15 @@ You will often need to specify layers as parameters. To specify a layer you will


This is what it looks like in action: This is what it looks like in action:


params: ```yaml
PAR: 2 params:
STR: string PAR: 2
LAYER: STR: string
type: vector LAYER:
name: polys.gml type: vector
OTHER: another param name: polys.gml
OTHER: another param
```


### Results ### Results


Expand All @@ -96,9 +106,11 @@ Results are specified very similar.


It couldn't be more trivial It couldn't be more trivial


```yaml
OUTPUT: OUTPUT:
name: expected/qgis_intersection.gml name: expected/qgis_intersection.gml
type: vector type: vector
```


#### Vector with tolerance #### Vector with tolerance


Expand All @@ -114,41 +126,49 @@ field name `__all__` which will apply a certain tolerance to all fields.
There is another property `geometry` which also accepts a `precision` which is There is another property `geometry` which also accepts a `precision` which is
applied to each vertex. applied to each vertex.


OUTPUT: ```yaml
type: vector OUTPUT:
name: expected/abcd.gml type: vector
compare: name: expected/abcd.gml
fields: compare:
__all__: fields:
precision: 5 # compare to a precision of .00001 on all fields __all__:
A: skip # skip field A precision: 5 # compare to a precision of .00001 on all fields
geometry: A: skip # skip field A
precision: 5 # compare coordinates with a precision of 5 digits geometry:
precision: 5 # compare coordinates with a precision of 5 digits
```


#### Raster files #### Raster files


Raster files are compared with a hash checksum. This is calculated when you create Raster files are compared with a hash checksum. This is calculated when you create
a test from the processing history. a test from the processing history.


OUTPUT: ```yaml
type: rasterhash OUTPUT:
hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6 type: rasterhash
hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6
```


#### Files #### Files


You can compare the content of an ouptut file by an expected result reference file You can compare the content of an ouptut file by an expected result reference file


OUTPUT_HTML_FILE: ```yaml
name: expected/basic_statistics_string.html OUTPUT_HTML_FILE:
type: file name: expected/basic_statistics_string.html
type: file
```


Or you can use one or more regular expressions that will be [matched](https://docs.python.org/2/library/re.html#re.search) against the file Or you can use one or more regular expressions that will be [matched](https://docs.python.org/2/library/re.html#re.search) against the file
content content


OUTPUT: ```yaml
name: layer_info.html OUTPUT:
type: regex name: layer_info.html
rules: type: regex
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)' rules:
- 'Geometry: Line String' - 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
- 'Feature Count: 6' - 'Geometry: Line String'
- 'Feature Count: 6'
```

0 comments on commit 9b9c692

Please sign in to comment.