mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Make models available in processing tests
This commit is contained in:
parent
dbced352b8
commit
ef676cffc8
@ -29,6 +29,7 @@ import AlgorithmsTestBase
|
||||
|
||||
import nose2
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from qgis.core import (QgsApplication,
|
||||
QgsProcessingAlgorithm,
|
||||
@ -37,6 +38,8 @@ from qgis.core import (QgsApplication,
|
||||
from qgis.analysis import (QgsNativeAlgorithms)
|
||||
from qgis.testing import start_app, unittest
|
||||
from processing.tools.dataobjects import createContext
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
from processing.modeler.ModelerUtils import ModelerUtils
|
||||
|
||||
|
||||
class TestAlg(QgsProcessingAlgorithm):
|
||||
@ -66,12 +69,14 @@ class TestQgisAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
start_app()
|
||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||
from processing.core.Processing import Processing
|
||||
Processing.initialize()
|
||||
ProcessingConfig.setSettingValue(ModelerUtils.MODELS_FOLDER, os.path.join(os.path.dirname(__file__), 'models'))
|
||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||
cls.cleanup_paths = []
|
||||
cls.in_place_layers = {}
|
||||
cls.vector_layer_params = {}
|
||||
cls._original_models_folder = ProcessingConfig.getSetting(ModelerUtils.MODELS_FOLDER)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@ -79,6 +84,7 @@ class TestQgisAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
Processing.deinitialize()
|
||||
for path in cls.cleanup_paths:
|
||||
shutil.rmtree(path)
|
||||
ProcessingConfig.setSettingValue(ModelerUtils.MODELS_FOLDER, cls._original_models_folder)
|
||||
|
||||
def test_definition_file(self):
|
||||
return 'qgis_algorithm_tests.yaml'
|
||||
|
102
python/plugins/processing/tests/models/filtertest.model3
Normal file
102
python/plugins/processing/tests/models/filtertest.model3
Normal file
@ -0,0 +1,102 @@
|
||||
<!DOCTYPE model>
|
||||
<Option type="Map">
|
||||
<Option type="Map" name="children">
|
||||
<Option type="Map" name="native:filter_1">
|
||||
<Option value="true" type="bool" name="active"/>
|
||||
<Option type="Map" name="alg_config">
|
||||
<Option type="List" name="outputs">
|
||||
<Option type="Map">
|
||||
<Option value="1" type="QString" name="expression"/>
|
||||
<Option value="true" type="bool" name="isModelOutput"/>
|
||||
<Option value="all" type="QString" name="name"/>
|
||||
</Option>
|
||||
<Option type="Map">
|
||||
<Option value="0" type="QString" name="expression"/>
|
||||
<Option value="true" type="bool" name="isModelOutput"/>
|
||||
<Option value="nothing" type="QString" name="name"/>
|
||||
</Option>
|
||||
</Option>
|
||||
</Option>
|
||||
<Option value="native:filter" type="QString" name="alg_id"/>
|
||||
<Option value="Filter" type="QString" name="component_description"/>
|
||||
<Option value="623" type="double" name="component_pos_x"/>
|
||||
<Option value="347" type="double" name="component_pos_y"/>
|
||||
<Option name="dependencies"/>
|
||||
<Option value="native:filter_1" type="QString" name="id"/>
|
||||
<Option type="Map" name="outputs">
|
||||
<Option type="Map" name="OUTPUT_all">
|
||||
<Option value="native:filter_1" type="QString" name="child_id"/>
|
||||
<Option value="OUTPUT_all" type="QString" name="component_description"/>
|
||||
<Option value="823" type="double" name="component_pos_x"/>
|
||||
<Option value="392" type="double" name="component_pos_y"/>
|
||||
<Option value="OUTPUT_all" type="QString" name="name"/>
|
||||
<Option value="OUTPUT_all" type="QString" name="output_name"/>
|
||||
</Option>
|
||||
<Option type="Map" name="OUTPUT_nothing">
|
||||
<Option value="native:filter_1" type="QString" name="child_id"/>
|
||||
<Option value="OUTPUT_nothing" type="QString" name="component_description"/>
|
||||
<Option value="823" type="double" name="component_pos_x"/>
|
||||
<Option value="422" type="double" name="component_pos_y"/>
|
||||
<Option value="OUTPUT_nothing" type="QString" name="name"/>
|
||||
<Option value="OUTPUT_nothing" type="QString" name="output_name"/>
|
||||
</Option>
|
||||
</Option>
|
||||
<Option value="false" type="bool" name="outputs_collapsed"/>
|
||||
<Option value="false" type="bool" name="parameters_collapsed"/>
|
||||
<Option type="Map" name="params">
|
||||
<Option type="List" name="INPUT">
|
||||
<Option type="Map">
|
||||
<Option value="layer" type="QString" name="parameter_name"/>
|
||||
<Option value="0" type="int" name="source"/>
|
||||
</Option>
|
||||
</Option>
|
||||
</Option>
|
||||
</Option>
|
||||
</Option>
|
||||
<Option name="help"/>
|
||||
<Option value="filter" type="QString" name="model_group"/>
|
||||
<Option value="filtertest" type="QString" name="model_name"/>
|
||||
<Option type="Map" name="parameterDefinitions">
|
||||
<Option type="Map" name="layer">
|
||||
<Option type="List" name="data_types">
|
||||
<Option value="5" type="int"/>
|
||||
</Option>
|
||||
<Option value="" type="Unknown" name="default"/>
|
||||
<Option value="layer" type="QString" name="description"/>
|
||||
<Option value="0" type="int" name="flags"/>
|
||||
<Option name="metadata"/>
|
||||
<Option value="layer" type="QString" name="name"/>
|
||||
<Option value="vector" type="QString" name="parameter_type"/>
|
||||
</Option>
|
||||
<Option type="Map" name="native:filter_1:OUTPUT_all">
|
||||
<Option value="true" type="bool" name="create_by_default"/>
|
||||
<Option value="-1" type="int" name="data_type"/>
|
||||
<Option value="" type="Unknown" name="default"/>
|
||||
<Option value="OUTPUT_all" type="QString" name="description"/>
|
||||
<Option value="20" type="int" name="flags"/>
|
||||
<Option name="metadata"/>
|
||||
<Option value="native:filter_1:OUTPUT_all" type="QString" name="name"/>
|
||||
<Option value="sink" type="QString" name="parameter_type"/>
|
||||
<Option value="true" type="bool" name="supports_non_file_outputs"/>
|
||||
</Option>
|
||||
<Option type="Map" name="native:filter_1:OUTPUT_nothing">
|
||||
<Option value="true" type="bool" name="create_by_default"/>
|
||||
<Option value="-1" type="int" name="data_type"/>
|
||||
<Option value="" type="Unknown" name="default"/>
|
||||
<Option value="OUTPUT_nothing" type="QString" name="description"/>
|
||||
<Option value="20" type="int" name="flags"/>
|
||||
<Option name="metadata"/>
|
||||
<Option value="native:filter_1:OUTPUT_nothing" type="QString" name="name"/>
|
||||
<Option value="sink" type="QString" name="parameter_type"/>
|
||||
<Option value="true" type="bool" name="supports_non_file_outputs"/>
|
||||
</Option>
|
||||
</Option>
|
||||
<Option type="Map" name="parameters">
|
||||
<Option type="Map" name="layer">
|
||||
<Option value="layer" type="QString" name="component_description"/>
|
||||
<Option value="208" type="double" name="component_pos_x"/>
|
||||
<Option value="291" type="double" name="component_pos_y"/>
|
||||
<Option value="layer" type="QString" name="name"/>
|
||||
</Option>
|
||||
</Option>
|
||||
</Option>
|
Loading…
x
Reference in New Issue
Block a user