From 126873ddaa15f2a6fe727b7fd4f322f4dab8a85d Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Fri, 13 Feb 2015 20:41:34 +0000 Subject: [PATCH] fixes bug1416703 by implementing a function to do the conversion Fixes: https://launchpad.net/bugs/1416703 --- openlp/core/common/settings.py | 2 +- .../openlp_core_common/test_settings.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 4c9fd767a..3bc506a11 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -360,7 +360,7 @@ class Settings(QtCore.QSettings): :param default_values: A dict with setting keys and their default values. """ - Settings.__default_settings__ = dict(list(default_values.items()) + list(Settings.__default_settings__.items())) + Settings.__default_settings__.update(default_values) @staticmethod def set_filename(ini_file): diff --git a/tests/functional/openlp_core_common/test_settings.py b/tests/functional/openlp_core_common/test_settings.py index 6fb5aa658..ee305c600 100644 --- a/tests/functional/openlp_core_common/test_settings.py +++ b/tests/functional/openlp_core_common/test_settings.py @@ -123,9 +123,17 @@ class TestSettings(TestCase, TestMixin): self.assertEqual(str(cm.exception), "'core/does not exists'", 'We should get an exception') def extend_default_settings_test(self): - with patch.dict(Settings() .__default_settings__, {1: 2, 3: 4}, clear=True): - Settings().extend_default_settings({'a': 'b', 'c': 'd'}) + """ + Test that the extend_default_settings method extends the default settings + """ + # GIVEN: A patched __default_settings__ dictionary + with patch.dict(Settings.__default_settings__, + {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 3}, True): - ds = Settings().__default_settings__ + # WHEN: Calling extend_default_settings + Settings.extend_default_settings({'test/setting 3': 4, 'test/extended 1': 1, 'test/extended 2': 2}) - self.assertDictEqual(ds, {1: 2, 3: 4, 'a': 'b', 'c': 'd'}) + # THEN: The _default_settings__ dictionary_ should have the new keys + self.assertEqual( + Settings.__default_settings__, {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4, + 'test/extended 1': 1, 'test/extended 2': 2})