forked from openlp/openlp
Add some more tests
This commit is contained in:
parent
a235602acb
commit
8f7c53c1fc
BIN
tests/functional/openlp_core_lib/resources/church.jpg
Normal file
BIN
tests/functional/openlp_core_lib/resources/church.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 213 KiB |
@ -56,3 +56,44 @@ class TestServiceItem(TestCase):
|
||||
#THEN: We should should have a page of output.
|
||||
assert len(service_item._display_frames) is 1, u'A valid rendered Service Item has display frames'
|
||||
assert service_item.get_rendered_frame(0) == VERSE.split(u'\n')[0], u'A valid render'
|
||||
|
||||
def serviceitem_add_image_test_single(self):
|
||||
"""
|
||||
Test the Service Item
|
||||
"""
|
||||
#GIVEN: A new service item and a mocked renderer
|
||||
service_item = ServiceItem(None)
|
||||
service_item.name = u'test'
|
||||
mocked_renderer = MagicMock()
|
||||
service_item.renderer = mocked_renderer
|
||||
|
||||
# WHEN: adding image to a service item
|
||||
service_item.add_from_image(u'resources/church.jpg', u'Image Title')
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'A valid Service Item'
|
||||
assert service_item.missing_frames() is False, u'frames loaded '
|
||||
assert len(service_item._display_frames) is 0, u'A blank Service Item'
|
||||
|
||||
#THEN: We should should have a page of output.
|
||||
assert len(service_item._raw_frames) is 1, u'A valid rendered Service Item has display frames'
|
||||
assert service_item.get_rendered_frame(0) == u'resources/church.jpg'
|
||||
|
||||
# WHEN: adding a second image to a service item
|
||||
service_item.add_from_image(u'resources/church.jpg', u'Image1 Title')
|
||||
|
||||
#THEN: We should should have a page of output.
|
||||
assert len(service_item._raw_frames) is 2, u'A valid rendered Service Item has display frames'
|
||||
assert service_item.get_rendered_frame(0) == u'resources/church.jpg'
|
||||
assert service_item.get_rendered_frame(0) == service_item.get_rendered_frame(1)
|
||||
|
||||
#When requesting a saved service item
|
||||
service = service_item.get_service_repr(True)
|
||||
|
||||
#THEN: We should should have two parts of the service.
|
||||
assert len(service) is 2, u'A saved service has two parts'
|
||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin'
|
||||
assert service[u'data'][0][u'title'] == u'Image Title' , u'The first title name '
|
||||
assert service[u'data'][0][u'path'] == u'resources/church.jpg' , u'The first image name'
|
||||
assert service[u'data'][0][u'title'] != service[u'data'][1][u'title'], u'The titles should not match'
|
||||
assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The files should match'
|
Loading…
Reference in New Issue
Block a user