Skip to content

Commit

Permalink
Processing - Tests - Add Ogr2Ogr test with GeoPackage support
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont authored and mdouchin committed Oct 24, 2018
1 parent b267182 commit 781d0e1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion python/plugins/processing/tests/GdalAlgorithmsTest.py
Expand Up @@ -27,15 +27,18 @@

import AlgorithmsTestBase
from processing.algs.gdal.ogr2ogrtopostgis import Ogr2OgrToPostGis
from processing.algs.gdal.ogr2ogr import Ogr2Ogr

import nose2
import shutil

import os
from qgis.testing import (
start_app,
unittest
)

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


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

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

def testOgr2Ogr(self):
source = os.path.join(testDataPath, 'polys.gml')

alg = Ogr2Ogr()
alg.setParameterValue('INPUT_LAYER', source)
alg.setParameterValue('FORMAT', 0)
alg.setOutputValue('OUTPUT_LAYER', 'd:/temp/check.shp')
self.assertEqual(
alg.getConsoleCommands(),
['ogr2ogr',
'-f "ESRI Shapefile" "d:/temp/check.shp" ' +
source + ' polys2'])

alg = Ogr2Ogr()
alg.setParameterValue('INPUT_LAYER', source)
alg.setParameterValue('FORMAT', 22)
alg.setOutputValue('OUTPUT_LAYER', 'd:/temp/check.gpkg')
self.assertEqual(
alg.getConsoleCommands(),
['ogr2ogr',
'-f GPKG "d:/temp/check.gpkg" ' +
source + ' polys2'])


class TestGdalOgr2OgrToPostgis(unittest.TestCase):

Expand Down

0 comments on commit 781d0e1

Please sign in to comment.