Skip to content
Permalink
Browse files

Add new test type "regex" to processing tests

  • Loading branch information
m-kuhn committed Feb 23, 2016
1 parent e0ffd92 commit 3f105530696cc5b12f45740ff122bf98a465bf94
@@ -27,12 +27,12 @@

import qgis
import os
import shutil
import yaml
import nose2
import gdal
import hashlib
import tempfile
import re

from osgeo.gdalconst import GA_ReadOnly

@@ -123,7 +123,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']:
if param['type'] in ['vector', 'file', 'regex']:
outdir = tempfile.mkdtemp()
self.cleanup_paths.append(outdir)
basename = os.path.basename(param['name'])
@@ -191,6 +191,12 @@ def check_results(self, results, expected):
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__':
@@ -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>
@@ -1,27 +1,43 @@
# See ../README.md for a description of the file format

tests:
- algorithm: gdalogr:rasterize
name: Test (gdalogr:rasterize)
# 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:
BIGTIFF: 0
COMPRESS: 4
DIMENSIONS: 0
EXTRA: ""
FIELD: "Bfloatval"
HEIGHT: 100
INPUT:
name: multipolys.gml
name: lines.gml
type: vector
JPEGCOMPRESSION: 75
NO_DATA: -9999
PREDICTOR: 1
RTYPE: 5
TFW: False
TILED: False
WIDTH: 100
ZLEVEL: 6
SUMMARY_ONLY: 'True'
results:
OUTPUT:
hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6
type: rasterhash
name: expected/gdal/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 3f10553

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