Skip to content

Commit

Permalink
[processing] cleanup test data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 12, 2016
1 parent 652addb commit 85d1fd7
Show file tree
Hide file tree
Showing 42 changed files with 64 additions and 456 deletions.
1 change: 0 additions & 1 deletion python/plugins/processing/__init__.py
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass/GrassUtils.py
Expand Up @@ -383,7 +383,7 @@ def checkGrassIsInstalled(ignorePreviousState=False):
points(),
False,
False,
'270778.60198,270855.745301,4458921.97814,4458983.8488',
'None',
-1,
0.0001,
0,
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/Grass7Utils.py
Expand Up @@ -363,7 +363,7 @@ def checkGrass7IsInstalled(ignorePreviousState=False):
points(),
False,
False,
'270778.60198,270855.745301,4458921.97814,4458983.8488',
'None',
-1,
0.0001,
0,
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/tests/CMakeLists.txt
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/tests/ParametersTest.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
47 changes: 3 additions & 44 deletions python/plugins/processing/tests/TestData.py
Expand Up @@ -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')
52 changes: 26 additions & 26 deletions python/plugins/processing/tests/ToolsTest.py
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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]))

Expand Down
Binary file removed python/plugins/processing/tests/data/lines.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/lines.prj

This file was deleted.

1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/lines.qpj

This file was deleted.

Binary file removed python/plugins/processing/tests/data/lines.shp
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/lines.shx
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/points.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/points.prj

This file was deleted.

1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/points.qpj

This file was deleted.

Binary file removed python/plugins/processing/tests/data/points.shp
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/points.shx
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/points2.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/points2.prj

This file was deleted.

1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/points2.qpj

This file was deleted.

Binary file removed python/plugins/processing/tests/data/points2.shp
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/points2.shx
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/polygons.dbf
Binary file not shown.
10 changes: 0 additions & 10 deletions python/plugins/processing/tests/data/polygons.geojson

This file was deleted.

1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/polygons.prj

This file was deleted.

1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/polygons.qpj

This file was deleted.

Binary file removed python/plugins/processing/tests/data/polygons.shp
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/polygons.shx
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/polygons2.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/polygons2.prj

This file was deleted.

1 change: 0 additions & 1 deletion python/plugins/processing/tests/data/polygons2.qpj

This file was deleted.

Binary file removed python/plugins/processing/tests/data/polygons2.shp
Binary file not shown.
Binary file removed python/plugins/processing/tests/data/polygons2.shx
Binary file not shown.

0 comments on commit 85d1fd7

Please sign in to comment.