Skip to content
Permalink
Browse files

[processing] cleanup test data

  • Loading branch information
alexbruy committed Nov 12, 2016
1 parent 652addb commit 85d1fd720b08e782d31b7b0625ba603cb9c39a8f
Showing with 64 additions and 456 deletions.
  1. +0 −1 python/plugins/processing/__init__.py
  2. +1 −1 python/plugins/processing/algs/grass/GrassUtils.py
  3. +1 −1 python/plugins/processing/algs/grass7/Grass7Utils.py
  4. +2 −2 python/plugins/processing/tests/CMakeLists.txt
  5. +2 −2 python/plugins/processing/tests/ParametersTest.py
  6. +3 −44 python/plugins/processing/tests/TestData.py
  7. +26 −26 python/plugins/processing/tests/ToolsTest.py
  8. BIN python/plugins/processing/tests/data/lines.dbf
  9. +0 −1 python/plugins/processing/tests/data/lines.prj
  10. +0 −1 python/plugins/processing/tests/data/lines.qpj
  11. BIN python/plugins/processing/tests/data/lines.shp
  12. BIN python/plugins/processing/tests/data/lines.shx
  13. BIN python/plugins/processing/tests/data/points.dbf
  14. +0 −1 python/plugins/processing/tests/data/points.prj
  15. +0 −1 python/plugins/processing/tests/data/points.qpj
  16. BIN python/plugins/processing/tests/data/points.shp
  17. BIN python/plugins/processing/tests/data/points.shx
  18. BIN python/plugins/processing/tests/data/points2.dbf
  19. +0 −1 python/plugins/processing/tests/data/points2.prj
  20. +0 −1 python/plugins/processing/tests/data/points2.qpj
  21. BIN python/plugins/processing/tests/data/points2.shp
  22. BIN python/plugins/processing/tests/data/points2.shx
  23. BIN python/plugins/processing/tests/data/polygons.dbf
  24. +0 −10 python/plugins/processing/tests/data/polygons.geojson
  25. +0 −1 python/plugins/processing/tests/data/polygons.prj
  26. +0 −1 python/plugins/processing/tests/data/polygons.qpj
  27. BIN python/plugins/processing/tests/data/polygons.shp
  28. BIN python/plugins/processing/tests/data/polygons.shx
  29. BIN python/plugins/processing/tests/data/polygons2.dbf
  30. +0 −1 python/plugins/processing/tests/data/polygons2.prj
  31. +0 −1 python/plugins/processing/tests/data/polygons2.qpj
  32. BIN python/plugins/processing/tests/data/polygons2.shp
  33. BIN python/plugins/processing/tests/data/polygons2.shx
  34. +0 −356 python/plugins/processing/tests/data/project.qgs
  35. BIN python/plugins/processing/tests/data/union.dbf
  36. +0 −1 python/plugins/processing/tests/data/union.prj
  37. +0 −1 python/plugins/processing/tests/data/union.qpj
  38. BIN python/plugins/processing/tests/data/union.shp
  39. BIN python/plugins/processing/tests/data/union.shx
  40. +10 −0 python/plugins/processing/tests/testdata/points.gfs
  41. +19 −1 python/plugins/processing/tests/testdata/points.gml
  42. BIN python/plugins/processing/tests/{data → testdata}/table.dbf
@@ -30,7 +30,6 @@
from processing.tools.vector import * # NOQA
from processing.tools.raster import * # NOQA
from processing.tools.system import * # NOQA
from processing.tests.TestData import loadTestData # NOQA


def classFactory(iface):
@@ -383,7 +383,7 @@ def checkGrassIsInstalled(ignorePreviousState=False):
points(),
False,
False,
'270778.60198,270855.745301,4458921.97814,4458983.8488',
'None',
-1,
0.0001,
0,
@@ -363,7 +363,7 @@ def checkGrass7IsInstalled(ignorePreviousState=False):
points(),
False,
False,
'270778.60198,270855.745301,4458921.97814,4458983.8488',
'None',
-1,
0.0001,
0,
@@ -1,8 +1,8 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB TEST_DATA_FILES data/*)
FILE(GLOB TEST_DATA_FILES testdata/points.* testdata/table.dbf)

PLUGIN_INSTALL(processing tests ${PY_FILES})
PLUGIN_INSTALL(processing tests/data ${TEST_DATA_FILES})
PLUGIN_INSTALL(processing tests/testdata ${TEST_DATA_FILES})

IF(ENABLE_TESTS)
INCLUDE(UsePythonTest)
@@ -43,7 +43,7 @@
ParameterSelection,
ParameterExpression)
from processing.tools import dataobjects
from processing.tests.TestData import points2
from processing.tests.TestData import points

from qgis.core import (QgsRasterLayer,
QgsVectorLayer)
@@ -498,7 +498,7 @@ class ParameterTableFieldTest(unittest.TestCase):

def testOptional(self):
parent_name = 'test_parent_layer'
test_data = points2()
test_data = points()
test_layer = QgsVectorLayer(test_data, parent_name, 'ogr')
parent = ParameterVector(parent_name, parent_name)
parent.setValue(test_layer)
@@ -26,54 +26,13 @@
__revision__ = '$Format:%H$'

import os.path
from processing.tools import dataobjects

dataFolder = os.path.join(os.path.dirname(__file__), 'data')
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')


def table():
return os.path.join(dataFolder, 'table.dbf')
return os.path.join(testDataPath, 'table.dbf')


def points():
return os.path.join(dataFolder, 'points.shp')


def points2():
return os.path.join(dataFolder, 'points2.shp')


def raster():
return os.path.join(dataFolder, 'raster.tif')


def lines():
return os.path.join(dataFolder, 'lines.shp')


def polygons():
return os.path.join(dataFolder, 'polygons.shp')


def polygons2():
return os.path.join(dataFolder, 'polygons2.shp')


def polygonsGeoJson():
return os.path.join(dataFolder, 'polygons.geojson')


def union():
return os.path.join(dataFolder, 'union.shp')


def loadTestData():
dataobjects.load(points(), 'points')
dataobjects.load(points2(), 'points2')
dataobjects.load(polygons(), 'polygons')
dataobjects.load(polygons2(), 'polygons2')
dataobjects.load(polygonsGeoJson(), 'polygonsGeoJson')
dataobjects.load(lines(), 'lines')
dataobjects.load(raster(), 'raster')
dataobjects.load(table(), 'table')
dataobjects.load(union(), 'union')
return os.path.join(testDataPath, 'points.gml')
@@ -26,7 +26,7 @@
__revision__ = '$Format:%H$'

from qgis.testing import start_app, unittest
from processing.tests.TestData import points2
from processing.tests.TestData import points
from processing.tools import vector
from qgis.core import (QgsVectorLayer, QgsFeatureRequest)
from processing.core.ProcessingConfig import ProcessingConfig
@@ -39,13 +39,13 @@ class VectorTest(unittest.TestCase):
def testFeatures(self):
ProcessingConfig.initialize()

test_data = points2()
test_data = points()
test_layer = QgsVectorLayer(test_data, 'test', 'ogr')

# test with all features
features = vector.features(test_layer)
self.assertEqual(len(features), 8)
self.assertEqual(set([f.id() for f in features]), set([0, 1, 2, 3, 4, 5, 6, 7]))
self.assertEqual(len(features), 9)
self.assertEqual(set([f.id() for f in features]), set([0, 1, 2, 3, 4, 5, 6, 7, 8]))

# test with selected features
previous_value = ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED)
@@ -59,15 +59,15 @@ def testFeatures(self):
ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, False)
test_layer.selectByIds([2, 4, 6])
features = vector.features(test_layer)
self.assertEqual(len(features), 8)
self.assertEqual(set([f.id() for f in features]), set([0, 1, 2, 3, 4, 5, 6, 7]))
self.assertEqual(len(features), 9)
self.assertEqual(set([f.id() for f in features]), set([0, 1, 2, 3, 4, 5, 6, 7, 8]))

# using selected features, but no selection
ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, True)
test_layer.removeSelection()
features = vector.features(test_layer)
self.assertEqual(len(features), 8)
self.assertEqual(set([f.id() for f in features]), set([0, 1, 2, 3, 4, 5, 6, 7]))
self.assertEqual(len(features), 9)
self.assertEqual(set([f.id() for f in features]), set([0, 1, 2, 3, 4, 5, 6, 7, 8]))

# test that feature request is honored
ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, False)
@@ -87,54 +87,54 @@ def testFeatures(self):
def testValues(self):
ProcessingConfig.initialize()

test_data = points2()
test_data = points()
test_layer = QgsVectorLayer(test_data, 'test', 'ogr')

# field by index
res = vector.values(test_layer, 0)
self.assertEqual(res[0], [1, 2, 3, 4, 5, 6, 7, 8])
res = vector.values(test_layer, 1)
self.assertEqual(res[1], [1, 2, 3, 4, 5, 6, 7, 8, 9])

# field by name
res = vector.values(test_layer, 'id')
self.assertEqual(res['id'], [1, 2, 3, 4, 5, 6, 7, 8])
self.assertEqual(res['id'], [1, 2, 3, 4, 5, 6, 7, 8, 9])

# two fields
res = vector.values(test_layer, 0, 3)
self.assertEqual(res[0], [1, 2, 3, 4, 5, 6, 7, 8])
self.assertEqual(res[3], [2, 1, 0, 2, 1, 0, 0, 0])
res = vector.values(test_layer, 1, 2)
self.assertEqual(res[1], [1, 2, 3, 4, 5, 6, 7, 8, 9])
self.assertEqual(res[2], [2, 1, 0, 2, 1, 0, 0, 0, 0])

# two fields by name
res = vector.values(test_layer, 'id', 'id_2')
self.assertEqual(res['id'], [1, 2, 3, 4, 5, 6, 7, 8])
self.assertEqual(res['id_2'], [2, 1, 0, 2, 1, 0, 0, 0])
res = vector.values(test_layer, 'id', 'id2')
self.assertEqual(res['id'], [1, 2, 3, 4, 5, 6, 7, 8, 9])
self.assertEqual(res['id2'], [2, 1, 0, 2, 1, 0, 0, 0, 0])

# two fields by name and index
res = vector.values(test_layer, 'id', 3)
self.assertEqual(res['id'], [1, 2, 3, 4, 5, 6, 7, 8])
self.assertEqual(res[3], [2, 1, 0, 2, 1, 0, 0, 0])
res = vector.values(test_layer, 'id', 2)
self.assertEqual(res['id'], [1, 2, 3, 4, 5, 6, 7, 8, 9])
self.assertEqual(res[2], [2, 1, 0, 2, 1, 0, 0, 0, 0])

# test with selected features
previous_value = ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED)
ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, True)
test_layer.selectByIds([2, 4, 6])
res = vector.values(test_layer, 0)
self.assertEqual(set(res[0]), set([5, 7, 3]))
res = vector.values(test_layer, 1)
self.assertEqual(set(res[1]), set([5, 7, 3]))

ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, previous_value)

def testUniqueValues(self):
ProcessingConfig.initialize()

test_data = points2()
test_data = points()
test_layer = QgsVectorLayer(test_data, 'test', 'ogr')

# field by index
v = vector.uniqueValues(test_layer, 3)
v = vector.uniqueValues(test_layer, 2)
self.assertEqual(len(v), len(set(v)))
self.assertEqual(set(v), set([2, 1, 0]))

# field by name
v = vector.uniqueValues(test_layer, 'id_2')
v = vector.uniqueValues(test_layer, 'id2')
self.assertEqual(len(v), len(set(v)))
self.assertEqual(set(v), set([2, 1, 0]))

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

0 comments on commit 85d1fd7

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