forked from openlp/openlp
buttons and app
This commit is contained in:
parent
1b603e177f
commit
2ccec6088d
@ -289,9 +289,9 @@ class TestOpenLP(TestCase):
|
||||
result = self.openlp.event(event)
|
||||
|
||||
# THEN: The path should be inserted.
|
||||
self.assertTrue(result, "The method should have returned True.")
|
||||
assert result is True, "The method should have returned True."
|
||||
mocked_file_method.assert_called_once_with()
|
||||
self.assertEqual(self.openlp.args[0], file_path, "The path should be in args.")
|
||||
assert self.openlp.args[0] == file_path, "The path should be in args."
|
||||
|
||||
@patch('openlp.core.app.is_macosx')
|
||||
def test_application_activate_event(self, mocked_is_macosx):
|
||||
@ -309,7 +309,7 @@ class TestOpenLP(TestCase):
|
||||
result = self.openlp.event(event)
|
||||
|
||||
# THEN:
|
||||
self.assertTrue(result, "The method should have returned True.")
|
||||
assert result is True, "The method should have returned True."
|
||||
# self.assertFalse(self.openlp.main_window.isMinimized())
|
||||
|
||||
@patch('openlp.core.app.get_version')
|
||||
@ -321,11 +321,11 @@ class TestOpenLP(TestCase):
|
||||
# GIVEN: Mocked data version and OpenLP version which are the same
|
||||
old_install = False
|
||||
MOCKED_VERSION = {
|
||||
'full': '2.2.0-bzr000',
|
||||
'version': '2.2.0',
|
||||
'full': '2.4.0-bzr000',
|
||||
'version': '2.4.0',
|
||||
'build': 'bzr000'
|
||||
}
|
||||
Settings().setValue('core/application version', '2.2.0')
|
||||
Settings().setValue('core/application version', '2.4.0')
|
||||
mocked_get_version.return_value = MOCKED_VERSION
|
||||
mocked_question.return_value = QtWidgets.QMessageBox.No
|
||||
|
||||
@ -333,8 +333,8 @@ class TestOpenLP(TestCase):
|
||||
self.openlp.backup_on_upgrade(old_install, False)
|
||||
|
||||
# THEN: It should not ask if we want to create a backup
|
||||
self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be the same!')
|
||||
self.assertEqual(mocked_question.call_count, 0, 'No question should have been asked!')
|
||||
assert Settings().value('core/application version') == '2.4.0', 'Version should be the same!'
|
||||
assert mocked_question.call_count == 0, 'No question should have been asked!'
|
||||
|
||||
@patch('openlp.core.app.get_version')
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
|
||||
@ -345,8 +345,8 @@ class TestOpenLP(TestCase):
|
||||
# GIVEN: Mocked data version and OpenLP version which are different
|
||||
old_install = True
|
||||
MOCKED_VERSION = {
|
||||
'full': '2.2.0-bzr000',
|
||||
'version': '2.2.0',
|
||||
'full': '2.4.0-bzr000',
|
||||
'version': '2.4.0',
|
||||
'build': 'bzr000'
|
||||
}
|
||||
Settings().setValue('core/application version', '2.0.5')
|
||||
@ -359,7 +359,7 @@ class TestOpenLP(TestCase):
|
||||
self.openlp.backup_on_upgrade(old_install, True)
|
||||
|
||||
# THEN: It should ask if we want to create a backup
|
||||
self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be upgraded!')
|
||||
self.assertEqual(mocked_question.call_count, 1, 'A question should have been asked!')
|
||||
assert Settings().value('core/application version') == '2.4.0', 'Version should be upgraded!'
|
||||
assert mocked_question.call_count == 1, 'A question should have been asked!'
|
||||
self.openlp.splash.hide.assert_called_once_with()
|
||||
self.openlp.splash.show.assert_called_once_with()
|
||||
|
@ -60,8 +60,7 @@ class TestColorDialog(TestCase):
|
||||
widget = ColorButton()
|
||||
|
||||
# THEN: The widget __init__ method should have the correct properties and methods called
|
||||
self.assertEqual(widget.parent, None,
|
||||
'The parent should be the same as the one that the class was instianted with')
|
||||
assert widget.parent is None, 'The parent should be the same as the one that the class was instianted with'
|
||||
self.mocked_change_color.assert_called_once_with('#ffffff')
|
||||
mocked_set_tool_tip.assert_called_once_with('Tool Tip Text')
|
||||
self.mocked_clicked.connect.assert_called_once_with(widget.on_clicked)
|
||||
@ -80,7 +79,7 @@ class TestColorDialog(TestCase):
|
||||
widget.change_color('#000000')
|
||||
|
||||
# THEN: The _color attribute should be set to #000000 and setStyleSheet should have been called twice
|
||||
self.assertEqual(widget._color, '#000000', '_color should have been set to #000000')
|
||||
assert widget._color == '#000000', '_color should have been set to #000000'
|
||||
mocked_set_style_sheet.assert_has_calls(
|
||||
[call('background-color: #ffffff'), call('background-color: #000000')])
|
||||
|
||||
@ -98,7 +97,7 @@ class TestColorDialog(TestCase):
|
||||
value = widget.color
|
||||
|
||||
# THEN: The value set in _color should be returned
|
||||
self.assertEqual(value, '#000000', 'The value returned should be equal to the one we set')
|
||||
assert value == '#000000', 'The value returned should be equal to the one we set'
|
||||
|
||||
# @patch('openlp.core.widgets.buttons.ColorButton.__init__', **{'return_value': None})
|
||||
def test_color_setter(self):
|
||||
@ -130,10 +129,10 @@ class TestColorDialog(TestCase):
|
||||
widget.on_clicked()
|
||||
|
||||
# THEN: change_color should not have been called and the colorChanged signal should not have been emitted
|
||||
self.assertFalse(self.mocked_change_color.called,
|
||||
'change_color should not have been called with an invalid color')
|
||||
self.assertFalse(self.mocked_color_changed.emit.called,
|
||||
'colorChange signal should not have been emitted with an invalid color')
|
||||
assert self.mocked_change_color.called is False, \
|
||||
'change_color should not have been called with an invalid color'
|
||||
assert self.mocked_color_changed.emit.called is False, \
|
||||
'colorChange signal should not have been emitted with an invalid color'
|
||||
|
||||
def test_on_clicked_same_color(self):
|
||||
"""
|
||||
@ -152,10 +151,10 @@ class TestColorDialog(TestCase):
|
||||
widget.on_clicked()
|
||||
|
||||
# THEN: change_color should not have been called and the colorChanged signal should not have been emitted
|
||||
self.assertFalse(self.mocked_change_color.called,
|
||||
'change_color should not have been called when the color has not changed')
|
||||
self.assertFalse(self.mocked_color_changed.emit.called,
|
||||
'colorChange signal should not have been emitted when the color has not changed')
|
||||
assert self.mocked_change_color.called is False, \
|
||||
'change_color should not have been called when the color has not changed'
|
||||
assert self.mocked_color_changed.emit.called is False, \
|
||||
'colorChange signal should not have been emitted when the color has not changed'
|
||||
|
||||
def test_on_clicked_new_color(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user