Skip to content
Permalink
Browse files

Fix unit test

  • Loading branch information
nyalldawson committed Nov 23, 2018
1 parent 0e928e8 commit 2c425c7bf08a53a4c5239431357f8a97dccd08c6
Showing with 15 additions and 12 deletions.
  1. +1 −1 python/plugins/processing/gui/AlgorithmDialog.py
  2. +14 −11 python/plugins/processing/tests/GuiTest.py
@@ -97,7 +97,7 @@ def getParametersPanel(self, alg, parent):

def runAsBatch(self):
self.close()
dlg = BatchAlgorithmDialog(self.algorithm())
dlg = BatchAlgorithmDialog(self.algorithm(), parent=iface.mainWindow())
dlg.show()
dlg.exec_()

@@ -55,7 +55,7 @@
class AlgorithmDialogTest(unittest.TestCase):

def testCreation(self):
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
a = AlgorithmDialog(alg)
self.assertEqual(a.mainWidget().alg, alg)

@@ -67,7 +67,7 @@ def setUpClass(cls):
ProcessingConfig.initialize()

def checkConstructWrapper(self, param, expected_wrapper_class):
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')

# algorithm dialog
dlg = AlgorithmDialog(alg)
@@ -77,6 +77,7 @@ def checkConstructWrapper(self, param, expected_wrapper_class):
self.assertEqual(wrapper.dialog, dlg)
self.assertIsNotNone(wrapper.widget)

alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
# batch dialog
dlg = BatchAlgorithmDialog(alg)
wrapper = WidgetWrapperFactory.create_wrapper_from_class(param, dlg)
@@ -85,6 +86,8 @@ def checkConstructWrapper(self, param, expected_wrapper_class):
self.assertEqual(wrapper.dialog, dlg)
self.assertIsNotNone(wrapper.widget)

alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')

# modeler dialog
model = QgsProcessingModelAlgorithm()
dlg = ModelerParametersDialog(alg, model)
@@ -138,7 +141,7 @@ def testSource(self):
self.assertTrue(layer.isValid())
QgsProject.instance().addMapLayer(layer)

alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
dlg = AlgorithmDialog(alg)
param = QgsProcessingParameterFeatureSource('test')
wrapper = FeatureSourceWidgetWrapper(param, dlg)
@@ -175,7 +178,7 @@ def testRange(self):
# minimal test to check if wrapper generate GUI for each processign context
self.checkConstructWrapper(QgsProcessingParameterRange('test'), RangeWidgetWrapper)

alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
dlg = AlgorithmDialog(alg)
param = QgsProcessingParameterRange(
name='test',
@@ -237,7 +240,7 @@ def testMapLayer(self):
def testDistance(self):
self.checkConstructWrapper(QgsProcessingParameterDistance('test'), DistanceWidgetWrapper)

alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
dlg = AlgorithmDialog(alg)
param = QgsProcessingParameterDistance('test')
wrapper = DistanceWidgetWrapper(param, dlg)
@@ -322,7 +325,7 @@ def testDistance(self):
def testMatrix(self):
self.checkConstructWrapper(QgsProcessingParameterMatrix('test'), FixedTableWidgetWrapper)

alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
dlg = AlgorithmDialog(alg)
param = QgsProcessingParameterMatrix('test', 'test', 2, True, ['x', 'y'], [['a', 'b'], ['c', 'd']])
wrapper = FixedTableWidgetWrapper(param, dlg)
@@ -346,7 +349,7 @@ def testBand(self):

def testFeatureSink(self):
param = QgsProcessingParameterFeatureSink('test')
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)

panel.setValue('memory:')
@@ -382,7 +385,7 @@ def testFeatureSink(self):

def testVectorDestination(self):
param = QgsProcessingParameterVectorDestination('test')
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)

panel.setValue('''ogr:dbname='/me/a.gpkg' table="d" (geom) sql=''')
@@ -412,7 +415,7 @@ def testVectorDestination(self):

def testRasterDestination(self):
param = QgsProcessingParameterRasterDestination('test')
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)

panel.setValue('/home/me/test.tif')
@@ -430,7 +433,7 @@ def testRasterDestination(self):

def testFolderDestination(self):
param = QgsProcessingParameterFolderDestination('test')
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)

panel.setValue('/home/me/test.tif')
@@ -444,7 +447,7 @@ def testFolderDestination(self):

def testFileDestination(self):
param = QgsProcessingParameterFileDestination('test')
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)

panel.setValue('/home/me/test.tif')

0 comments on commit 2c425c7

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