forked from openlp/openlp
Fix up unit tests
This commit is contained in:
parent
4224e2441a
commit
db9d2a4a56
@ -26,8 +26,8 @@ class TestServiceItem(TestCase):
|
|||||||
service_item = ServiceItem(None)
|
service_item = ServiceItem(None)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
assert service_item.is_valid is True, u'A valid Service Item'
|
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||||
assert service_item.missing_frames() is True, u'No frames loaded yet'
|
assert service_item.missing_frames() is True, u'There should not be any frames in the service item'
|
||||||
|
|
||||||
def serviceitem_add_text_test(self):
|
def serviceitem_add_text_test(self):
|
||||||
"""
|
"""
|
||||||
@ -41,7 +41,7 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.raw_footer = FOOTER
|
service_item.raw_footer = FOOTER
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
assert service_item.is_valid is True, u'A valid Service Item'
|
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||||
assert service_item.missing_frames() is False, u'check frames loaded '
|
assert service_item.missing_frames() is False, u'check frames loaded '
|
||||||
|
|
||||||
# GIVEN: A service item with text
|
# GIVEN: A service item with text
|
||||||
@ -50,12 +50,12 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.renderer = mocked_renderer
|
service_item.renderer = mocked_renderer
|
||||||
|
|
||||||
# WHEN: Render called
|
# WHEN: Render called
|
||||||
assert len(service_item._display_frames) is 0, u'A blank Service Item'
|
assert len(service_item._display_frames) == 0, u'A blank Service Item with no display frames'
|
||||||
service_item.render(True)
|
service_item.render(True)
|
||||||
|
|
||||||
# THEN: We should have a page of output.
|
# THEN: We should have a page of output.
|
||||||
assert len(service_item._display_frames) is 1, u'A valid rendered Service Item has display frames'
|
assert len(service_item._display_frames) == 1, u'A valid rendered Service Item has 1 display frame'
|
||||||
assert service_item.get_rendered_frame(0) == VERSE.split(u'\n')[0], u'A valid render'
|
assert service_item.get_rendered_frame(0) == VERSE.split(u'\n')[0], u'A output has rendered correctly.'
|
||||||
|
|
||||||
def serviceitem_add_image_test(self):
|
def serviceitem_add_image_test(self):
|
||||||
"""
|
"""
|
||||||
@ -71,46 +71,47 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.add_from_image(u'resources/church.jpg', u'Image Title')
|
service_item.add_from_image(u'resources/church.jpg', u'Image Title')
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
assert service_item.is_valid is True, u'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) is 0, u'A blank Service Item'
|
assert len(service_item._display_frames) == 0, u'The service item has no display frames'
|
||||||
|
|
||||||
# THEN: We should have a page of output.
|
# THEN: We should have a page of output.
|
||||||
assert len(service_item._raw_frames) is 1, u'A valid rendered Service Item has display frames'
|
assert len(service_item._raw_frames) == 1, 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) == u'resources/church.jpg'
|
||||||
|
|
||||||
# WHEN: adding a second image to a service item
|
# WHEN: adding a second image to a service item
|
||||||
service_item.add_from_image(u'resources/church.jpg', u'Image1 Title')
|
service_item.add_from_image(u'resources/church.jpg', u'Image1 Title')
|
||||||
|
|
||||||
# THEN: We should have an increased page of output.
|
# THEN: We should have an increased page of output.
|
||||||
assert len(service_item._raw_frames) is 2, u'A valid rendered Service Item has display frames'
|
assert len(service_item._raw_frames) == 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) == u'resources/church.jpg'
|
||||||
assert service_item.get_rendered_frame(0) == service_item.get_rendered_frame(1)
|
assert service_item.get_rendered_frame(0) == service_item.get_rendered_frame(1)
|
||||||
|
|
||||||
#When requesting a saved service item
|
# WHEN requesting a saved service item
|
||||||
service = service_item.get_service_repr(True)
|
service = service_item.get_service_repr(True)
|
||||||
|
|
||||||
# THEN: We should have two parts of the service.
|
# THEN: We should have two parts of the service.
|
||||||
assert len(service) is 2, u'A saved service has two parts'
|
assert len(service) == 2, u'A saved service has two parts'
|
||||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin'
|
assert service[u'header'][u'name'] == u'test' , u'A test plugin was returned'
|
||||||
assert service[u'data'][0][u'title'] == u'Image Title' , u'The first title name '
|
assert service[u'data'][0][u'title'] == u'Image Title' , u'The first title name matches the request'
|
||||||
assert service[u'data'][0][u'path'] == u'resources/church.jpg' , u'The first image name'
|
assert service[u'data'][0][u'path'] == u'resources/church.jpg' , u'The first image name matches'
|
||||||
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'title'] != service[u'data'][1][u'title'], \
|
||||||
assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The files should match'
|
u'The individual titles should not match'
|
||||||
|
assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The file paths should match'
|
||||||
|
|
||||||
#When validating a service item
|
# WHEN validating a service item
|
||||||
service_item.validate_item([u'jpg'])
|
service_item.validate_item([u'jpg'])
|
||||||
|
|
||||||
#Then the service item should be valid
|
# THEN the service item should be valid
|
||||||
assert service_item.is_valid is True, u'The service item is valid'
|
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||||
|
|
||||||
# WHEN: adding a second image to a service item
|
# WHEN: adding a second image to a service item
|
||||||
service_item.add_from_image(u'resources/church1.jpg', u'Image1 Title')
|
service_item.add_from_image(u'resources/church1.jpg', u'Image1 Title')
|
||||||
|
|
||||||
#When validating a service item
|
# WHEN validating a service item
|
||||||
service_item.validate_item([u'jpg'])
|
service_item.validate_item([u'jpg'])
|
||||||
|
|
||||||
#Then the service item should be valid
|
# THEN the service item should be valid
|
||||||
assert service_item.is_valid is False, u'The service item is not valid'
|
assert service_item.is_valid is False, u'The service item is not valid due to validation changes'
|
||||||
|
|
||||||
def serviceitem_add_command_test(self):
|
def serviceitem_add_command_test(self):
|
||||||
"""
|
"""
|
||||||
@ -126,31 +127,31 @@ class TestServiceItem(TestCase):
|
|||||||
service_item.add_from_command(u'resources', u'church.jpg', u'resources/church.jpg')
|
service_item.add_from_command(u'resources', u'church.jpg', u'resources/church.jpg')
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
assert service_item.is_valid is True, u'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) is 0, u'A blank Service Item'
|
assert len(service_item._display_frames) == 0, u'The service item has no display frames '
|
||||||
|
|
||||||
# THEN: We should have a page of output.
|
# THEN: We should have a page of output.
|
||||||
assert len(service_item._raw_frames) is 1, u'A valid rendered Service Item has display frames'
|
assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item has one raw frame'
|
||||||
assert service_item.get_rendered_frame(0) == u'resources/church.jpg'
|
assert service_item.get_rendered_frame(0) == u'resources/church.jpg', u'The image matches the input'
|
||||||
|
|
||||||
#When requesting a saved service item
|
# WHEN requesting a saved service item
|
||||||
service = service_item.get_service_repr(True)
|
service = service_item.get_service_repr(True)
|
||||||
|
|
||||||
# THEN: We should have two parts of the service.
|
# THEN: We should have two parts of the service.
|
||||||
assert len(service) is 2, u'A saved service has two parts'
|
assert len(service) == 2, u'A saved service has two parts'
|
||||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin'
|
assert service[u'header'][u'name'] == u'test' , u'A test plugin'
|
||||||
assert service[u'data'][0][u'title'] == u'church.jpg' , u'The first title name '
|
assert service[u'data'][0][u'title'] == u'church.jpg' , u'The first title name '
|
||||||
assert service[u'data'][0][u'path'] == u'resources' , u'The first image name'
|
assert service[u'data'][0][u'path'] == u'resources' , u'The first image name'
|
||||||
assert service[u'data'][0][u'image'] == u'resources/church.jpg' , u'The first image name'
|
assert service[u'data'][0][u'image'] == u'resources/church.jpg' , u'The first image name'
|
||||||
|
|
||||||
#When validating a service item
|
# WHEN validating a service item
|
||||||
service_item.validate_item([u'jpg'])
|
service_item.validate_item([u'jpg'])
|
||||||
|
|
||||||
#Then the service item should be valid
|
# THEN the service item should be valid
|
||||||
assert service_item.is_valid is True, u'The service item is valid'
|
assert service_item.is_valid is True, u'The service item is valid'
|
||||||
|
|
||||||
#When validating a service item with a different suffix
|
# WHEN validating a service item with a different suffix
|
||||||
service_item.validate_item([u'png'])
|
service_item.validate_item([u'png'])
|
||||||
|
|
||||||
#Then the service item should not be valid
|
# THEN the service item should not be valid
|
||||||
assert service_item.is_valid is False, u'The service item is not valid'
|
assert service_item.is_valid is False, u'The service item is not valid'
|
Loading…
Reference in New Issue
Block a user