mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Add test to ensure style has not been initialized when running
qgis_process
This commit is contained in:
parent
976c86d03d
commit
2f490ec750
@ -340,6 +340,16 @@ class TestQgsProcessExecutablePt2(unittest.TestCase):
|
|||||||
self.assertEqual(res['algorithm_details']['id'], 'native:buffer')
|
self.assertEqual(res['algorithm_details']['id'], 'native:buffer')
|
||||||
self.assertEqual(res['inputs']['DISTANCE'], {'field': 'fid', 'type': 'data_defined'})
|
self.assertEqual(res['inputs']['DISTANCE'], {'field': 'fid', 'type': 'data_defined'})
|
||||||
|
|
||||||
|
def testStartupOptimisationsStyleLazyInitialized(self):
|
||||||
|
"""
|
||||||
|
Ensure that the costly QgsStyle.defaultStyle() initialization is NOT
|
||||||
|
performed by default when running qgis_process commands
|
||||||
|
"""
|
||||||
|
rc, output, err = self.run_process(['run', TEST_DATA_DIR + '/report_style_initialization_status.py'])
|
||||||
|
self.assertFalse(self._strip_ignorable_errors(err))
|
||||||
|
self.assertEqual(rc, 0)
|
||||||
|
self.assertIn('IS_INITIALIZED: false', output)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# look for qgis bin path
|
# look for qgis bin path
|
||||||
|
43
tests/testdata/report_style_initialization_status.py
vendored
Normal file
43
tests/testdata/report_style_initialization_status.py
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
"""
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
"""
|
||||||
|
|
||||||
|
from qgis.core import (
|
||||||
|
QgsStyle,
|
||||||
|
QgsProcessingAlgorithm,
|
||||||
|
QgsProcessingOutputBoolean,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CheckStyleInitializationStatus(QgsProcessingAlgorithm):
|
||||||
|
IS_INITIALIZED = 'IS_INITIALIZED'
|
||||||
|
|
||||||
|
def createInstance(self):
|
||||||
|
return CheckStyleInitializationStatus()
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return 'checkstyleinitstatus'
|
||||||
|
|
||||||
|
def displayName(self):
|
||||||
|
return 'Check style initialization status'
|
||||||
|
|
||||||
|
def shortDescription(self):
|
||||||
|
return 'Checks style initialization status'
|
||||||
|
|
||||||
|
def initAlgorithm(self, config=None):
|
||||||
|
self.addOutput(
|
||||||
|
QgsProcessingOutputBoolean(
|
||||||
|
self.IS_INITIALIZED,
|
||||||
|
'Style is initialized'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def processAlgorithm(self, parameters, context, feedback):
|
||||||
|
return {self.IS_INITIALIZED: QgsStyle.defaultStyle(False).isInitialized()}
|
Loading…
x
Reference in New Issue
Block a user