Esempio n. 1
0
    def test_process_formatting_tags(self):
        """
        Test that _process_formatting_tags works
        """
        # GIVEN: A OpenLyric XML with formatting tags and a mocked out manager
        mocked_manager = MagicMock()
        Settings().setValue('formattingTags/html_tags', json.dumps(start_tags))
        ol = OpenLyrics(mocked_manager)
        parser = etree.XMLParser(remove_blank_text=True)
        parsed_file = etree.parse((TEST_PATH / 'duchu-tags.xml').open('rb'),
                                  parser)
        xml = etree.tostring(parsed_file).decode()
        song_xml = objectify.fromstring(xml)

        # WHEN: processing the formatting tags
        ol._process_formatting_tags(song_xml, False)

        # THEN: New tags should have been saved
        assert 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'
Esempio n. 2
0
    def test_process_formatting_tags(self):
        """
        Test that _process_formatting_tags works
        """
        # GIVEN: A OpenLyric XML with formatting tags and a mocked out manager
        mocked_manager = MagicMock()
        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)
        xml = etree.tostring(parsed_file).decode()
        song_xml = objectify.fromstring(xml)

        # WHEN: processing the formatting tags
        ol._process_formatting_tags(song_xml, False)

        # THEN: New tags should have been saved
        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')