From 3681ef911c12223f71ae1dbc1c2eddb66997f02d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 20 Jan 2013 17:12:33 +0000 Subject: [PATCH] Updates --- openlp/core/lib/__init__.py | 3 +- openlp/core/lib/serviceitem.py | 2 +- .../resources/serviceitem_image1.osd | 79 +++++++++++++++++++ .../openlp_core_lib/test_serviceitem.py | 31 +++++++- .../openlp_core_ui/starttimedialog.py | 48 ----------- 5 files changed, 109 insertions(+), 54 deletions(-) create mode 100644 tests/functional/openlp_core_lib/resources/serviceitem_image1.osd delete mode 100644 tests/functional/openlp_core_ui/starttimedialog.py diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d0a5e9880..dfafcd641 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -468,8 +468,7 @@ from plugin import PluginStatus, StringContent, Plugin from pluginmanager import PluginManager from settingstab import SettingsTab from serviceitem import ServiceItem, ServiceItemType, ItemCapabilities -from htmlbuilder import build_html, build_lyrics_format_css, \ - build_lyrics_outline_css +from htmlbuilder import build_html, build_lyrics_format_css, build_lyrics_outline_css from toolbar import OpenLPToolbar from dockwidget import OpenLPDockWidget from imagemanager import ImageManager diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 85aa840a6..dd2c722ad 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -37,7 +37,7 @@ import logging import os import uuid -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, ImageSource, Settings diff --git a/tests/functional/openlp_core_lib/resources/serviceitem_image1.osd b/tests/functional/openlp_core_lib/resources/serviceitem_image1.osd new file mode 100644 index 000000000..7dfeda2d8 --- /dev/null +++ b/tests/functional/openlp_core_lib/resources/serviceitem_image1.osd @@ -0,0 +1,79 @@ +(lp1 +(dp2 +Vserviceitem +p3 +(dp4 +Vheader +p5 +(dp6 +Vfooter +p7 +(lp8 +sVaudit +p9 +V +sVsearch +p10 +V +sVwill_auto_start +p11 +I00 +sVname +p12 +Vimages +p13 +sVplugin +p14 +g13 +sVdata +p15 +V +sVnotes +p16 +V +sVtitle +p17 +VImages +p18 +sVfrom_plugin +p19 +I00 +sVcapabilities +p20 +(lp21 +I3 +aI1 +aI5 +aI6 +asVmedia_length +p22 +I0 +sVtheme_overwritten +p23 +I00 +sVtheme +p24 +I-1 +sVxml_version +p25 +NsVend_time +p26 +I0 +sVbackground_audio +p27 +(lp28 +sVtype +p29 +I2 +sVstart_time +p30 +I0 +sVicon +p31 +V:/plugins/plugin_images.png +p32 +ssg15 +(lp33 +VIMG_7453.JPG +p34 +assa. \ No newline at end of file diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index 05eab7ef5..677ba5b35 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -5,8 +5,11 @@ import os import cPickle from unittest import TestCase -from mock import MagicMock -from openlp.core.lib import ServiceItem +from mock import MagicMock, patch + +from PyQt4 import QtGui + +from openlp.core.lib import ServiceItem, Settings VERSE = u'The Lord said to {r}Noah{/r}: \n'\ 'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n'\ @@ -166,7 +169,7 @@ class TestServiceItem(TestCase): def serviceitem_load_custom_from_service_test(self): """ - Test the Service Item - adding from a saved service + Test the Service Item - adding a custom slide from a saved service """ # GIVEN: A new service item and a mocked add icon function service_item = ServiceItem(None) @@ -186,6 +189,28 @@ class TestServiceItem(TestCase): service_item.render(True) assert (service_item.get_display_title()) == u'Test Custom', u'The custom title is correct' + def serviceitem_load_image_from_service_test(self): + """ + Test the Service Item - adding an image from a saved service + """ + # GIVEN: A new service item and a mocked add icon function + service_item = ServiceItem(None) + mocked_add_icon = MagicMock() + service_item.add_icon = mocked_add_icon + mocked_renderer = MagicMock() + service_item.renderer = mocked_renderer + + # WHEN: adding a custom from a saved Service + #with patch(u'openlp_core_lib_settings') as mocked_settings: + # line = self.convert_file_service_item(u'serviceitem_image1.osd') + # service_item.set_from_service(line) + + # THEN: We should get back a valid service item + #assert service_item.is_valid is True, u'The new service item should be valid' + #assert len(service_item._display_frames) == 0, u'The service item has no display frames' + #assert len(service_item.capabilities) == 5, u'There are 5 default custom item capabilities' + #assert (service_item.get_display_title()) == u'Test Custom', u'The custom title is correct' + def convert_file_service_item(self, name): service_file = os.path.join(TESTPATH, name) try: diff --git a/tests/functional/openlp_core_ui/starttimedialog.py b/tests/functional/openlp_core_ui/starttimedialog.py deleted file mode 100644 index 8b9d3193c..000000000 --- a/tests/functional/openlp_core_ui/starttimedialog.py +++ /dev/null @@ -1,48 +0,0 @@ -""" - Package to test the openlp.core.ui package. -""" -import sys - -from unittest import TestCase -from mock import MagicMock -from openlp.core.ui import starttimeform -from PyQt4 import QtCore, QtGui, QtTest - -class TestStartTimeDialog(TestCase): - - def setUp(self): - """ - Create the UI - """ - self.app = QtGui.QApplication(sys.argv) - self.window = QtGui.QMainWindow() - self.form = starttimeform.StartTimeForm(self.window) - - 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 - """ - #GIVEN: A service item with with time - mocked_serviceitem = MagicMock() - mocked_serviceitem.start_time = 61 - mocked_serviceitem.end_time = 3701 - - self.form.item = mocked_serviceitem - #self.form.exec_() \ No newline at end of file