diff --git a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py index 7e1fba1fa..b782a14ba 100644 --- a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py +++ b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py @@ -66,7 +66,13 @@ SONG_TEST_DATA = { } } -tags_str ='[{"protected": false, "desc": "z", "start tag": "{z}", "end html": "", "temporary": false, "end tag": "{/z}", "start html": "strong>"}]' +start_tags = [{"protected": False, "desc": "z", "start tag": "{z}", "end html": "", "temporary": False, + "end tag": "{/z}", "start html": "strong>"}] +result_tags = [{"temporary": False, "protected": False, "desc": "z", "start tag": "{z}", "start html": "strong>", + "end html": "", "end tag": "{/z}"}, + {"temporary": False, "end tag": "{/c}", "desc": "c", "start tag": "{c}", + "start html": "", "end html": "", + "protected": False}] class TestOpenLyricsImport(TestCase, TestMixin): @@ -126,9 +132,9 @@ class TestOpenLyricsImport(TestCase, TestMixin): """ 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() - Settings().setValue('formattingTags/html_tags', json.loads(tags_str)) + Settings().setValue('formattingTags/html_tags', json.dumps(start_tags)) ol = OpenLyrics(mocked_manager) parser = etree.XMLParser(remove_blank_text=True) 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) # WHEN: processing the formatting tags - print(Settings().value('formattingTags/html_tags')) ol._process_formatting_tags(song_xml, False) # THEN: New tags should have been saved - print(str(Settings().value('formattingTags/html_tags'))) - self.assertTrue(False) + self.assertListEqual(json.loads(json.dumps(result_tags)), + json.loads(str(Settings().value('formattingTags/html_tags'))), + 'The formatting tags should contain both the old and the new') diff --git a/tests/resources/openlyricssongs/duchu-tags.xml b/tests/resources/openlyricssongs/duchu-tags.xml new file mode 100644 index 000000000..e082ce5fc --- /dev/null +++ b/tests/resources/openlyricssongs/duchu-tags.xml @@ -0,0 +1,27 @@ + + + + + Duchu svätý volám príď <akordy> + + + Author Unknown + + + + + + <span class="chord" style="display:none"><strong> + </strong></span> + + + + + + [D]Duchu svätý volám príď, [Ami]oheň mojej duši daj,
[G]Oheň môjmu telu daj, [D]rozpáľ ma.
+
+ + Všemoh[Ami]úci [G]Boh tu s nami [D]je,
neko[Ami]nečne [G]milostivý [D]je,
Uka[Ami]zuje [G]dobrotivú [D]tvár voči [Ami]t[G]ým,
ktorí milovať ho [D]chcú.
+
+
+
\ No newline at end of file