update tests

This commit is contained in:
Tim Bentley 2012-12-30 22:10:51 +00:00
parent 44a9f96c87
commit 174905b991
3 changed files with 48 additions and 4 deletions

View File

@ -628,7 +628,7 @@ class ServiceItem(object):
file = os.path.join(frame[u'path'],frame[u'title'])
if not os.path.exists(file):
self.is_valid = False
if suffix_list:
if suffix_list and not self.is_text():
type = frame[u'title'].split(u'.')[-1]
if type.lower() not in suffix_list:
self.is_valid = False

View File

@ -57,7 +57,7 @@ class TestServiceItem(TestCase):
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):
def serviceitem_add_image_test(self):
"""
Test the Service Item
"""
@ -82,7 +82,7 @@ class TestServiceItem(TestCase):
# 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.
#THEN: We should 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 service_item.get_rendered_frame(0) == u'resources/church.jpg'
assert service_item.get_rendered_frame(0) == service_item.get_rendered_frame(1)
@ -96,4 +96,48 @@ class TestServiceItem(TestCase):
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'
assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The files should match'
#When validating a service item
service_item.validate_item([u'jpg'])
#Then the service item should be valid
assert service_item.is_valid is True, u'The service item is valid'
def serviceitem_add_command_test(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_command(u'resources', u'church.jpg', u'resources/church.jpg')
# 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 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'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'image'] == u'resources/church.jpg' , u'The first image name'
#When validating a service item
service_item.validate_item([u'jpg'])
#Then the service item should be valid
assert service_item.is_valid is True, u'The service item is valid'

View File

Before

Width:  |  Height:  |  Size: 213 KiB

After

Width:  |  Height:  |  Size: 213 KiB