27
27
28
28
import AlgorithmsTestBase
29
29
from processing .algs .gdal .ogr2ogrtopostgis import Ogr2OgrToPostGis
30
+ from processing .algs .gdal .ogr2ogr import Ogr2Ogr
30
31
31
32
import nose2
32
33
import shutil
33
-
34
+ import os
34
35
from qgis .testing import (
35
36
start_app ,
36
37
unittest
37
38
)
38
39
40
+ testDataPath = os .path .join (os .path .dirname (__file__ ), 'testdata' )
41
+
39
42
40
43
class TestGdalAlgorithms (unittest .TestCase , AlgorithmsTestBase .AlgorithmsTest ):
41
44
@@ -54,6 +57,29 @@ def tearDownClass(cls):
54
57
def test_definition_file (self ):
55
58
return 'gdal_algorithm_tests.yaml'
56
59
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
+
57
83
58
84
class TestGdalOgr2OgrToPostgis (unittest .TestCase ):
59
85
0 commit comments