Skip to content
Permalink
Browse files

Syntax highlighting for processing tests readme

  • Loading branch information
m-kuhn committed Mar 1, 2016
1 parent e695fbb commit 9b9c692be2ee80c19b49d65a58cc658ee27d22c3
Showing with 78 additions and 58 deletions.
  1. +78 −58 python/plugins/processing/tests/README.md
@@ -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:

- name: centroid
algorithm: qgis:polygoncentroids
params:
- type: vector
name: polys.gml
results:
OUTPUT_LAYER:
type: vector
name: expected/polys_centroid.gml
```yaml
- name: centroid
algorithm: qgis:polygoncentroids
params:
- type: vector
name: polys.gml
results:
OUTPUT_LAYER:
type: vector
name: expected/polys_centroid.gml
```

How To
------
@@ -39,16 +41,18 @@ ones to params and the last one(s) to results.

The above translates to

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

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

Params and results are specified as lists or dictionaries:

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

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

or

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

### Layer type parameters

@@ -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:

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

### Results

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

It couldn't be more trivial

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

#### Vector with tolerance

@@ -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
applied to each vertex.

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

#### Raster files

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

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

#### Files

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

OUTPUT_HTML_FILE:
name: expected/basic_statistics_string.html
type: file
```yaml
OUTPUT_HTML_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
content

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

0 comments on commit 9b9c692

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