forked from openlp/openlp
fixed test method descriptions; created costant
This commit is contained in:
parent
434349b47d
commit
db00a864fc
@ -9,6 +9,16 @@ from mock import patch
|
|||||||
from openlp.core.lib import FormattingTags
|
from openlp.core.lib import FormattingTags
|
||||||
|
|
||||||
|
|
||||||
|
TAG = {
|
||||||
|
u'end tag': '{/aa}',
|
||||||
|
u'start html': '<span>',
|
||||||
|
u'start tag': '{aa}',
|
||||||
|
u'protected': False,
|
||||||
|
u'end html': '</span>',
|
||||||
|
u'desc': 'name'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestFormattingTags(TestCase):
|
class TestFormattingTags(TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -19,7 +29,7 @@ class TestFormattingTags(TestCase):
|
|||||||
|
|
||||||
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 FormattingTags class' get_html_tags static method.
|
||||||
"""
|
"""
|
||||||
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, \
|
||||||
@ -40,7 +50,7 @@ class TestFormattingTags(TestCase):
|
|||||||
|
|
||||||
def get_html_tags_with_user_tags_test(self):
|
def get_html_tags_with_user_tags_test(self):
|
||||||
"""
|
"""
|
||||||
Add a tag and check if it still exists after reloading the tags list.
|
Test the FormattingTags class' get_html_tags static method in combination with user tags.
|
||||||
"""
|
"""
|
||||||
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, \
|
||||||
@ -48,15 +58,7 @@ class TestFormattingTags(TestCase):
|
|||||||
# 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''
|
||||||
tag = {
|
mocked_cPickle.loads.side_effect = [[], [TAG]]
|
||||||
u'end tag': '{/aa}',
|
|
||||||
u'start html': '<span>',
|
|
||||||
u'start tag': '{aa}',
|
|
||||||
u'protected': False,
|
|
||||||
u'end html': '</span>',
|
|
||||||
u'desc': 'name'
|
|
||||||
}
|
|
||||||
mocked_cPickle.loads.side_effect = [[], [tag]]
|
|
||||||
|
|
||||||
# WHEN: Get the display tags.
|
# WHEN: Get the display tags.
|
||||||
FormattingTags.load_tags()
|
FormattingTags.load_tags()
|
||||||
@ -64,7 +66,7 @@ class TestFormattingTags(TestCase):
|
|||||||
|
|
||||||
# WHEN: Add our tag and get the tags again.
|
# WHEN: Add our tag and get the tags again.
|
||||||
FormattingTags.load_tags()
|
FormattingTags.load_tags()
|
||||||
FormattingTags.add_html_tags([tag])
|
FormattingTags.add_html_tags([TAG])
|
||||||
new_tags_list = FormattingTags.get_html_tags()
|
new_tags_list = FormattingTags.get_html_tags()
|
||||||
|
|
||||||
# THEN: Lists should not be identically.
|
# THEN: Lists should not be identically.
|
||||||
@ -72,5 +74,5 @@ class TestFormattingTags(TestCase):
|
|||||||
|
|
||||||
# THEN: Added tag and last tag should be the same.
|
# THEN: Added tag and last tag should be the same.
|
||||||
new_tag = new_tags_list.pop()
|
new_tag = new_tags_list.pop()
|
||||||
assert tag == new_tag, u'Tags should be identically.'
|
assert TAG == new_tag, u'Tags should be identically.'
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class TestUiStrings(TestCase):
|
|||||||
|
|
||||||
def check_same_instance_test(self):
|
def check_same_instance_test(self):
|
||||||
"""
|
"""
|
||||||
Test if the always only one instance of the UiStrings is created.
|
Test the UiStrings class - we always should have only one instance of the UiStrings class.
|
||||||
"""
|
"""
|
||||||
# WHEN: Create two instances of the UiStrings class.
|
# WHEN: Create two instances of the UiStrings class.
|
||||||
first_instance = UiStrings()
|
first_instance = UiStrings()
|
||||||
|
Loading…
Reference in New Issue
Block a user