Skip to content

Commit 781d0e1

Browse files
rldhontmdouchin
authored andcommittedOct 24, 2018
Processing - Tests - Add Ogr2Ogr test with GeoPackage support
1 parent b267182 commit 781d0e1

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed
 

‎python/plugins/processing/tests/GdalAlgorithmsTest.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@
2727

2828
import AlgorithmsTestBase
2929
from processing.algs.gdal.ogr2ogrtopostgis import Ogr2OgrToPostGis
30+
from processing.algs.gdal.ogr2ogr import Ogr2Ogr
3031

3132
import nose2
3233
import shutil
33-
34+
import os
3435
from qgis.testing import (
3536
start_app,
3637
unittest
3738
)
3839

40+
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
41+
3942

4043
class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
4144

@@ -54,6 +57,29 @@ def tearDownClass(cls):
5457
def test_definition_file(self):
5558
return 'gdal_algorithm_tests.yaml'
5659

60+
def testOgr2Ogr(self):
61+
source = os.path.join(testDataPath, 'polys.gml')
62+
63+
alg = Ogr2Ogr()
64+
alg.setParameterValue('INPUT_LAYER', source)
65+
alg.setParameterValue('FORMAT', 0)
66+
alg.setOutputValue('OUTPUT_LAYER', 'd:/temp/check.shp')
67+
self.assertEqual(
68+
alg.getConsoleCommands(),
69+
['ogr2ogr',
70+
'-f "ESRI Shapefile" "d:/temp/check.shp" ' +
71+
source + ' polys2'])
72+
73+
alg = Ogr2Ogr()
74+
alg.setParameterValue('INPUT_LAYER', source)
75+
alg.setParameterValue('FORMAT', 22)
76+
alg.setOutputValue('OUTPUT_LAYER', 'd:/temp/check.gpkg')
77+
self.assertEqual(
78+
alg.getConsoleCommands(),
79+
['ogr2ogr',
80+
'-f GPKG "d:/temp/check.gpkg" ' +
81+
source + ' polys2'])
82+
5783

5884
class TestGdalOgr2OgrToPostgis(unittest.TestCase):
5985

0 commit comments

Comments
 (0)
Please sign in to comment.