openlp/tests/functional/openlp_core_ui/test_starttimedialog.py

65 lines
2.3 KiB
Python
Raw Normal View History

2013-01-02 21:50:20 +00:00
"""
2013-01-21 06:52:55 +00:00
Package to test the openlp.core.ui package.
2013-01-02 21:50:20 +00:00
"""
import sys
from unittest import TestCase
2013-01-21 06:52:55 +00:00
from mock import MagicMock, patch
2013-01-02 21:50:20 +00:00
from openlp.core.ui import starttimeform
2013-01-21 06:52:55 +00:00
from PyQt4 import QtGui, QtTest
2013-01-02 21:50:20 +00:00
class TestStartTimeDialog(TestCase):
def setUp(self):
"""
Create the UI
"""
self.app = QtGui.QApplication([])
2013-01-02 21:50:20 +00:00
self.window = QtGui.QMainWindow()
self.form = starttimeform.StartTimeForm(self.window)
def tearDown(self):
2013-01-21 13:04:18 +00:00
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
del self.form
del self.window
del self.app
2013-01-02 21:50:20 +00:00
def ui_defaults_test(self):
"""
Test StartTimeDialog defaults
"""
self.assertEqual(self.form.hourSpinBox.minimum(), 0)
self.assertEqual(self.form.hourSpinBox.maximum(), 4)
self.assertEqual(self.form.minuteSpinBox.minimum(), 0)
self.assertEqual(self.form.minuteSpinBox.maximum(), 59)
self.assertEqual(self.form.secondSpinBox.minimum(), 0)
self.assertEqual(self.form.secondSpinBox.maximum(), 59)
self.assertEqual(self.form.hourFinishSpinBox.minimum(), 0)
self.assertEqual(self.form.hourFinishSpinBox.maximum(), 4)
self.assertEqual(self.form.minuteFinishSpinBox.minimum(), 0)
self.assertEqual(self.form.minuteFinishSpinBox.maximum(), 59)
self.assertEqual(self.form.secondFinishSpinBox.minimum(), 0)
self.assertEqual(self.form.secondFinishSpinBox.maximum(), 59)
def time_display_test(self):
"""
Test StartTimeDialog display initialisation
"""
2013-01-21 06:52:55 +00:00
# GIVEN: A service item with with time
mocked_serviceitem = MagicMock()
2013-01-02 21:50:20 +00:00
mocked_serviceitem.start_time = 61
mocked_serviceitem.end_time = 3701
2013-01-21 06:52:55 +00:00
# WHEN displaying the UI and pressing enter
2013-01-02 21:50:20 +00:00
self.form.item = mocked_serviceitem
2013-01-21 06:52:55 +00:00
with patch(u'openlp.core.lib.QtGui.QDialog') as MockedQtGuiQDialog:
MockedQtGuiQDialog.return_value = True
2013-01-23 21:01:30 +00:00
#does not work yet
#self.form.exec_()
2013-01-21 06:52:55 +00:00
# THEN the following values are returned
2013-01-24 19:07:11 +00:00
#self.assertEqual(self.form.hourSpinBox.value(), 1)
#self.assertEqual(self.form.minuteSpinBox.value(), 1)
#self.assertEqual(self.form.secondSpinBox.value(), 1)