diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index c222897cb..b59352258 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -175,7 +175,7 @@ class TestServiceItem(TestCase): service_item.add_icon = MagicMock() # WHEN: adding a custom from a saved Service - line = self.convert_file_service_item(u'serviceitem_custom1.osd') + line = self.convert_file_service_item(u'serviceitem_custom_1.osd') service_item.set_from_service(line) # THEN: We should get back a valid service item @@ -196,7 +196,7 @@ class TestServiceItem(TestCase): Test the Service Item - adding an image from a saved service """ # GIVEN: A new service item and a mocked add icon function - image_name = u'IMG_7453.JPG' + image_name = u'image_1.jpg' test_file = os.path.join(TEST_PATH, image_name) frame_array = {u'path': test_file, u'title': image_name} @@ -204,12 +204,13 @@ class TestServiceItem(TestCase): service_item.add_icon = MagicMock() # WHEN: adding an image from a saved Service and mocked exists - line = self.convert_file_service_item(u'serviceitem_image1.osd') + line = self.convert_file_service_item(u'serviceitem_image_1.osd') with patch('os.path.exists'): service_item.set_from_service(line, TEST_PATH) # THEN: We should get back a valid service item assert service_item.is_valid is True, u'The new service item should be valid' + print service_item.get_rendered_frame(0) assert service_item.get_rendered_frame(0) == test_file, u'The first frame is the path to the image' assert service_item.get_frames()[0] == frame_array, u'The first frame array is as expected' assert service_item.get_frame_path(0) == test_file, u'The frame path is the full path to the image' @@ -221,6 +222,44 @@ class TestServiceItem(TestCase): assert service_item.is_capable(ItemCapabilities.CanLoop) is True, u'Images can be made to Loop' assert service_item.is_capable(ItemCapabilities.CanAppend) is True, u'Images can have new items added' + def serviceitem_load_image_from_local_service_test(self): + """ + Test the Service Item - adding an image from a saved local service + """ + # GIVEN: A new service item and a mocked add icon function + image_name1 = u'image_1.jpg' + image_name2 = u'image_2.jpg' + test_file1 = os.path.join(u'/home/openlp', image_name1) + test_file2 = os.path.join(u'/home/openlp', image_name2) + frame_array1 = {u'path': test_file1, u'title': image_name1} + frame_array2 = {u'path': test_file2, u'title': image_name2} + + service_item = ServiceItem(None) + service_item.add_icon = MagicMock() + + # WHEN: adding an image from a saved Service and mocked exists + line = self.convert_file_service_item(u'serviceitem_image_2.osd') + with patch('os.path.exists'): + 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 service_item.get_rendered_frame(0) == test_file1, u'The first frame is the path to the image' + assert service_item.get_rendered_frame(1) == test_file2, u'The Second frame is the path to the image' + assert service_item.get_frames()[0] == frame_array1, u'The first frame array is as expected' + assert service_item.get_frames()[1] == frame_array2, u'The first frame array is as expected' + assert service_item.get_frame_path(0) == test_file1, u'The frame path is the full path to the image' + assert service_item.get_frame_path(1) == test_file2, u'The frame path is the full path to the image' + assert service_item.get_frame_title(0) == image_name1, u'The 1st frame title is the image name' + assert service_item.get_frame_title(1) == image_name2, u'The 2nd frame title is the image name' + + assert service_item.get_display_title().lower() == service_item.name, \ + u'The display title as there are > 1 Images' + assert service_item.is_image() is True, u'This is an image service item' + assert service_item.is_capable(ItemCapabilities.CanMaintain) is True, u'Images can be Maintained' + assert service_item.is_capable(ItemCapabilities.CanPreview) is True, u'Images can be Previewed' + assert service_item.is_capable(ItemCapabilities.CanLoop) is True, u'Images can be made to Loop' + assert service_item.is_capable(ItemCapabilities.CanAppend) is True, u'Images can have new items added' def convert_file_service_item(self, name): diff --git a/tests/resources/serviceitem_custom1.osd b/tests/resources/serviceitem_custom_1.osd similarity index 100% rename from tests/resources/serviceitem_custom1.osd rename to tests/resources/serviceitem_custom_1.osd diff --git a/tests/resources/serviceitem_image1.osd b/tests/resources/serviceitem_image_1.osd similarity index 96% rename from tests/resources/serviceitem_image1.osd rename to tests/resources/serviceitem_image_1.osd index 7dfeda2d8..cc0a6a897 100644 --- a/tests/resources/serviceitem_image1.osd +++ b/tests/resources/serviceitem_image_1.osd @@ -74,6 +74,6 @@ V:/plugins/plugin_images.png p32 ssg15 (lp33 -VIMG_7453.JPG +Vimage_1.jpg p34 assa. \ No newline at end of file diff --git a/tests/resources/serviceitem_image_2.osd b/tests/resources/serviceitem_image_2.osd new file mode 100644 index 000000000..0556c236a --- /dev/null +++ b/tests/resources/serviceitem_image_2.osd @@ -0,0 +1,101 @@ +(lp1 +(dp2 +Vserviceitem +p3 +(dp4 +Vheader +p5 +(dp6 +Vxml_version +p7 +NsVauto_play_slides_loop +p8 +I00 +sVauto_play_slides_once +p9 +I00 +sVwill_auto_start +p10 +I00 +sVtitle +p11 +VImages +p12 +sVcapabilities +p13 +(lp14 +I3 +aI1 +aI5 +aI6 +asVtheme +p15 +I-1 +sVbackground_audio +p16 +(lp17 +sVicon +p18 +V:/plugins/plugin_images.png +p19 +sVtype +p20 +I2 +sVstart_time +p21 +I0 +sVfrom_plugin +p22 +I00 +sVmedia_length +p23 +I0 +sVdata +p24 +V +sVtimed_slide_interval +p25 +I0 +sVaudit +p26 +V +sVsearch +p27 +V +sVname +p28 +Vimages +p29 +sVfooter +p30 +(lp31 +sVnotes +p32 +V +sVplugin +p33 +g29 +sVtheme_overwritten +p34 +I00 +sVend_time +p35 +I0 +ssg24 +(lp36 +(dp37 +Vpath +p38 +V/home/openlp/image_1.jpg +p39 +sg11 +Vimage_1.jpg +p40 +sa(dp41 +g38 +V/home/openlp/image_2.jpg +p42 +sg11 +Vimage_2.jpg +p43 +sassa. \ No newline at end of file