openlp/tests/functional/openlp_core_lib/test_settings.py

50 lines
1.4 KiB
Python
Raw Normal View History

2013-02-11 18:08:32 +00:00
"""
Package to test the openlp.core.lib package.
"""
import os
from unittest import TestCase
from mock import MagicMock
from openlp.core.lib import Settings
2013-02-11 19:20:08 +00:00
from PyQt4 import QtGui, QtTest
2013-02-11 18:08:32 +00:00
TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
class TestSettings(TestCase):
2013-02-11 19:20:08 +00:00
def setUp(self):
"""
Create the UI
"""
self.application = QtGui.QApplication([])
self.application.setOrganizationName(u'OpenLP-tests')
self.application.setOrganizationDomain(u'openlp.org')
Settings()
def tearDown(self):
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
del self.application
os.remove(Settings().fileName())
2013-02-11 18:08:32 +00:00
def settings_basic_test(self):
"""
2013-02-11 19:20:08 +00:00
Test the Settings creation and its default usage
2013-02-11 18:08:32 +00:00
"""
2013-02-11 19:20:08 +00:00
# GIVEN: A new Settings setup
# WHEN reading a setting for the first time
default_value = Settings().value(u'general/has run wizard')
# THEN the default value is returned
assert default_value is False, u'The default value defined is returned'
# WHEN a new value is saved into config
Settings().setValue(u'general/has run wizard', True)
# THEN the new value is returned when re-read
assert Settings().value(u'general/has run wizard') is True, u'The saved value is returned'