forked from openlp/openlp
Fixed the new test.
This commit is contained in:
parent
839df08eb7
commit
9b8b114a59
@ -66,7 +66,13 @@ SONG_TEST_DATA = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tags_str ='[{"protected": false, "desc": "z", "start tag": "{z}", "end html": "</strong>", "temporary": false, "end tag": "{/z}", "start html": "strong>"}]'
|
start_tags = [{"protected": False, "desc": "z", "start tag": "{z}", "end html": "</strong>", "temporary": False,
|
||||||
|
"end tag": "{/z}", "start html": "strong>"}]
|
||||||
|
result_tags = [{"temporary": False, "protected": False, "desc": "z", "start tag": "{z}", "start html": "strong>",
|
||||||
|
"end html": "</strong>", "end tag": "{/z}"},
|
||||||
|
{"temporary": False, "end tag": "{/c}", "desc": "c", "start tag": "{c}",
|
||||||
|
"start html": "<span class=\"chord\" style=\"display:none\"><strong>", "end html": "</strong></span>",
|
||||||
|
"protected": False}]
|
||||||
|
|
||||||
|
|
||||||
class TestOpenLyricsImport(TestCase, TestMixin):
|
class TestOpenLyricsImport(TestCase, TestMixin):
|
||||||
@ -126,9 +132,9 @@ class TestOpenLyricsImport(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Test that _process_formatting_tags works
|
Test that _process_formatting_tags works
|
||||||
"""
|
"""
|
||||||
# GIVEN: A OpenLyric XML with formatting and a mocked out formattingtag-setting
|
# GIVEN: A OpenLyric XML with formatting tags and a mocked out manager
|
||||||
mocked_manager = MagicMock()
|
mocked_manager = MagicMock()
|
||||||
Settings().setValue('formattingTags/html_tags', json.loads(tags_str))
|
Settings().setValue('formattingTags/html_tags', json.dumps(start_tags))
|
||||||
ol = OpenLyrics(mocked_manager)
|
ol = OpenLyrics(mocked_manager)
|
||||||
parser = etree.XMLParser(remove_blank_text=True)
|
parser = etree.XMLParser(remove_blank_text=True)
|
||||||
parsed_file = etree.parse(open(os.path.join(TEST_PATH, 'duchu-tags.xml'), 'rb'), parser)
|
parsed_file = etree.parse(open(os.path.join(TEST_PATH, 'duchu-tags.xml'), 'rb'), parser)
|
||||||
@ -136,9 +142,9 @@ class TestOpenLyricsImport(TestCase, TestMixin):
|
|||||||
song_xml = objectify.fromstring(xml)
|
song_xml = objectify.fromstring(xml)
|
||||||
|
|
||||||
# WHEN: processing the formatting tags
|
# WHEN: processing the formatting tags
|
||||||
print(Settings().value('formattingTags/html_tags'))
|
|
||||||
ol._process_formatting_tags(song_xml, False)
|
ol._process_formatting_tags(song_xml, False)
|
||||||
|
|
||||||
# THEN: New tags should have been saved
|
# THEN: New tags should have been saved
|
||||||
print(str(Settings().value('formattingTags/html_tags')))
|
self.assertListEqual(json.loads(json.dumps(result_tags)),
|
||||||
self.assertTrue(False)
|
json.loads(str(Settings().value('formattingTags/html_tags'))),
|
||||||
|
'The formatting tags should contain both the old and the new')
|
||||||
|
27
tests/resources/openlyricssongs/duchu-tags.xml
Normal file
27
tests/resources/openlyricssongs/duchu-tags.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<song xmlns="http://openlyrics.info/namespace/2009/song" version="0.8" createdIn="OpenLP 2.0.4" modifiedIn="OpenLP 2.0.4" modifiedDate="2014-06-27T09:55:49">
|
||||||
|
<properties>
|
||||||
|
<titles>
|
||||||
|
<title>Duchu svätý volám príď <akordy></title>
|
||||||
|
</titles>
|
||||||
|
<authors>
|
||||||
|
<author>Author Unknown</author>
|
||||||
|
</authors>
|
||||||
|
</properties>
|
||||||
|
<format>
|
||||||
|
<tags application="OpenLP">
|
||||||
|
<tag name="c">
|
||||||
|
<open><span class="chord" style="display:none"><strong></open>
|
||||||
|
<close></strong></span></close>
|
||||||
|
</tag>
|
||||||
|
</tags>
|
||||||
|
</format>
|
||||||
|
<lyrics>
|
||||||
|
<verse name="v1">
|
||||||
|
<lines><tag name="c">[D]</tag>Duchu svätý volám príď, <tag name="c">[Ami]</tag>oheň mojej duši daj,<br/><tag name="c">[G]</tag>Oheň môjmu telu daj, <tag name="c">[D]</tag>rozpáľ ma.</lines>
|
||||||
|
</verse>
|
||||||
|
<verse name="c1">
|
||||||
|
<lines>Všemoh<tag name="c">[Ami]</tag>úci <tag name="c">[G]</tag>Boh tu s nami <tag name="c">[D]</tag>je,<br/>neko<tag name="c">[Ami]</tag>nečne <tag name="c">[G]</tag>milostivý <tag name="c">[D]</tag>je,<br/>Uka<tag name="c">[Ami]</tag>zuje <tag name="c">[G]</tag>dobrotivú <tag name="c">[D]</tag>tvár voči <tag name="c">[Ami]</tag>t<tag name="c">[G]</tag>ým,<br/>ktorí milovať ho <tag name="c">[D]</tag>chcú.</lines>
|
||||||
|
</verse>
|
||||||
|
</lyrics>
|
||||||
|
</song>
|
Loading…
Reference in New Issue
Block a user