fixed test

This commit is contained in:
Andreas Preikschat 2013-02-15 12:09:51 +01:00
parent 6b2274645a
commit b77ae7a187

View File

@ -10,6 +10,12 @@ from openlp.core.lib import FormattingTags
class TestFormattingTags(TestCase): class TestFormattingTags(TestCase):
def tearDown(self):
"""
Clean up the FormattingTags class.
"""
FormattingTags.html_expands = []
def get_html_tags_no_user_tags_test(self): def get_html_tags_no_user_tags_test(self):
""" """
Test the get_html_tags static method. Test the get_html_tags static method.
@ -18,7 +24,7 @@ class TestFormattingTags(TestCase):
patch(u'openlp.core.lib.settings') as mocked_settings, \ patch(u'openlp.core.lib.settings') as mocked_settings, \
patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle: patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
# GIVEN: Our mocked modules and functions. # GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
mocked_settings.value.return_value = u'' mocked_settings.value.return_value = u''
mocked_cPickle.load.return_value = [] mocked_cPickle.load.return_value = []
@ -35,32 +41,32 @@ class TestFormattingTags(TestCase):
""" """
Add a tag and check if it still exists after reloading the tags list. Add a tag and check if it still exists after reloading the tags list.
""" """
# FIXME: not working yet.
with patch(u'openlp.core.lib.translate') as mocked_translate, \ with patch(u'openlp.core.lib.translate') as mocked_translate, \
patch(u'openlp.core.lib.settings') as mocked_settings, \ patch(u'openlp.core.lib.settings') as mocked_settings, \
patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle: patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
# GIVEN: Our mocked modules and functions. # GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
mocked_settings.value.return_value = u'' mocked_settings.value.return_value = u''
mocked_cPickle.load.return_value = []
tags = [{ tags = [{
u'end tag': '{/aa}', u'end tag': '{/aa}',
u'start html': '<span>', u'start html': '<span>',
u'start tag': '{aa}', u'start tag': '{aa}',
u'protected': False, u'protected': False,
u'end html': '</span>', u'end html': '</span>',
u'desc': 'name'} u'desc': 'name'
] }]
mocked_cPickle.load.return_value = tags
# WHEN: Get the display tags. # WHEN: Get the display tags.
FormattingTags.add_html_tags(tags)
FormattingTags.load_tags() FormattingTags.load_tags()
old_tags_list = FormattingTags.get_html_tags() old_tags_list = FormattingTags.get_html_tags()
FormattingTags.add_html_tags(tags)
FormattingTags.load_tags() FormattingTags.load_tags()
new_tags_list = FormattingTags.get_html_tags() new_tags_list = FormattingTags.get_html_tags()
# THEN: Lists should be identically. # THEN: Lists should not be identically.
assert old_tags_list == new_tags_list, u'The formatting tag lists with user tags should be identically.' assert len(old_tags_list) - 1 == len(new_tags_list), u'The lists should be different.'