Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added api to add child settings registries to settings registry
- Loading branch information
Showing
7 changed files
with
175 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Test the PyQgsSettingsRegistry classes | ||
Run with: ctest -V -R PyQgsSettingsRegistry | ||
.. note:: 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 QgsSettingsRegistry, QgsSettingsEntryBase, QgsSettingsEntryInteger, QgsApplication | ||
from qgis.testing import start_app, unittest | ||
|
||
__author__ = 'Damiano Lombardi' | ||
__date__ = '18/04/2021' | ||
__copyright__ = 'Copyright 2021, The QGIS Project' | ||
|
||
|
||
start_app() | ||
|
||
|
||
class PyQgsSettingsRegistry(unittest.TestCase): | ||
|
||
cnt = 0 | ||
|
||
def setUp(self): | ||
self.pluginName = "UnitTestSettingsRegistry" | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_settings_registry(self): | ||
|
||
settingsEntryKey = "settingsRegistry/integerValue" | ||
settingsEntry = QgsSettingsEntryInteger(settingsEntryKey, self.pluginName, 123) | ||
|
||
settingsRegistry = QgsSettingsRegistry() | ||
settingsRegistry.addSettingsEntry(settingsEntry) | ||
|
||
# check get settings entry | ||
self.assertEqual(settingsRegistry.getSettingsEntry(settingsEntry.key(), False), settingsEntry) | ||
|
||
# add registry to core registry | ||
QgsApplication.settingsRegistryCore().addChildSettingsRegistry(settingsRegistry) | ||
|
||
self.assertEqual(QgsApplication.settingsRegistryCore().getSettingsEntry(settingsEntry.key(), True), settingsEntry) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |