forked from openlp/openlp
Fix up tests - initial
This commit is contained in:
parent
b119783a2c
commit
b4a3833858
@ -343,7 +343,7 @@ class Settings(QtCore.QSettings):
|
|||||||
"""
|
"""
|
||||||
# On OS X (and probably on other platforms too) empty value from QSettings is represented as type
|
# On OS X (and probably on other platforms too) empty value from QSettings is represented as type
|
||||||
# PyQt4.QtCore.QPyNullVariant. This type has to be converted to proper 'None' Python type.
|
# PyQt4.QtCore.QPyNullVariant. This type has to be converted to proper 'None' Python type.
|
||||||
if isinstance(setting, QtCore.QPyNullVariant) and setting.isNull():
|
if setting.isNull() and isinstance(setting, QtCore.QPyNullVariant):
|
||||||
setting = None
|
setting = None
|
||||||
# Handle 'None' type (empty value) properly.
|
# Handle 'None' type (empty value) properly.
|
||||||
if setting is None:
|
if setting is None:
|
||||||
|
@ -7,13 +7,43 @@ from unittest import TestCase
|
|||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
from openlp.core.lib import Settings
|
from openlp.core.lib import Settings
|
||||||
|
|
||||||
|
from PyQt4 import QtGui, QtTest
|
||||||
|
|
||||||
TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources'))
|
||||||
|
|
||||||
class TestSettings(TestCase):
|
class TestSettings(TestCase):
|
||||||
|
|
||||||
|
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())
|
||||||
|
|
||||||
def settings_basic_test(self):
|
def settings_basic_test(self):
|
||||||
"""
|
"""
|
||||||
Test the Settings creation and its usage
|
Test the Settings creation and its default usage
|
||||||
"""
|
"""
|
||||||
# GIVEN: A new Settings
|
# GIVEN: A new Settings setup
|
||||||
settings = Settings()
|
|
||||||
|
# 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'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user