Skip to content
Permalink
Browse files

Load real provider.

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@297 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Jul 11, 2012
1 parent 3497758 commit 53a48eca031ce712d383b85defacf513c36f5cf2
Showing with 16 additions and 11 deletions.
  1. +12 −2 src/sextante/tests/qgis_interface.py
  2. +4 −9 src/sextante/tests/test.py
@@ -26,7 +26,7 @@

from PyQt4.QtCore import QObject
from qgis.core import QgsMapLayerRegistry

from qgis.core import *

class QgisInterface(QObject):
"""Class to expose qgis objects and functionalities to plugins.
@@ -39,6 +39,11 @@ def __init__(self, canvas):
"""Constructor"""
QObject.__init__(self)
self.canvas = canvas
QgsProviderRegistry.instance()
self.testRaster = QgsRasterLayer('data/raster', "test raster")
self.testVector = QgsVectorLayer('data/vector', "test vector")
self.testRaster.dataProvider = lambda: QgsProviderRegistry.instance().provider('ogr','data/raster')
self.testVector.dataProvider = lambda: QgsProviderRegistry.instance().provider('gdal','data/vector')

def zoomFull(self):
"""Zoom to the map full extent"""
@@ -94,4 +99,9 @@ def addDockWidget(self, area, dockwidget):
pass

def legendInterface(self):
return type('FakeLInterface', (), {'layers' : list})()
return type('FakeLInterface', (),
{'layers' :
lambda _: [
self.testRaster,
self.testVector]
})()
@@ -37,6 +37,7 @@
#from gui.is_plugin import ISPlugin
from sextante.SextantePlugin import SextantePlugin
from sextante.core.Sextante import Sextante
from sextante.core.SextanteLog import SextanteLog
from sextante.gui.ParametersDialog import ParametersDialog
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterVector import ParameterVector
@@ -50,10 +51,6 @@
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

class DataProviderStub:
def __init__(self, uri):
self.dataSourceUri = lambda: uri

class bcolors:
INFO = '\033[94m'
WARNING = '\033[91m'
@@ -86,13 +83,11 @@ def gen_test_parameters(self, alg, doSet = False):
b = False
for p in alg.parameters:
if isinstance(p, ParameterRaster):
l = QgsRasterLayer('data/raster', "test raster")
l.dataProvider = lambda: DataProviderStub('data/raster')
l = IFACE.testRaster
if doSet: p.setValue(l)
yield l
elif isinstance(p, ParameterVector):
l = QgsVectorLayer('data/vector', "test vector")
#~ l.dataProvider = lambda: DataProviderStub('data/vector')
l = IFACE.testVector
if doSet: p.setValue(l)
yield l
elif isinstance(p, ParameterNumber):
@@ -134,11 +129,11 @@ def gen_test_parameters(self, alg, doSet = False):

def setUp(self):
SextanteConfig.setSettingValue(SextanteConfig.USE_THREADS, self.threaded)
self.args = list(self.gen_test_parameters(self.alg, True))
print
print bcolors.INFO, self.msg, bcolors.ENDC,
print "Parameters: ", self.alg.parameters,
print "Outputs: ", [out for out in self.alg.outputs if not out.hidden],
self.args = list(self.gen_test_parameters(self.alg, True))
print ' => ', self.args, bcolors.WARNING,

def runalg_none(self):

0 comments on commit 53a48ec

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