diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py
index 9b88a96ad..6804acb4d 100644
--- a/tests/functional/openlp_plugins/songs/test_mediaitem.py
+++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py
@@ -35,46 +35,59 @@ from openlp.plugins.songs.lib.mediaitem import SongMediaItem
from tests.helpers.testmixin import TestMixin
__default_settings__ = {
- 'songs/footer template': """{{title}}
+ 'songs/footer template': """
+${title}
-{{#authors_none}}
- {{#first}}{{authors_none_label}}: {{/first}}
- {{entry}}{{^last}}, {{/last}}
- {{#last}}
{{/last}}
-{{/authors_none}}
-{{#authors_words_music}}
- {{#first}}{{authors_words_music_label}}: {{/first}}
- {{entry}}{{^last}}, {{/last}}
- {{#last}}
{{/last}}
-{{/authors_words_music}}
-{{#authors_words}}
- {{#first}}{{authors_words_label}}: {{/first}}
- {{entry}}{{^last}}, {{/last}}
- {{#last}}
{{/last}}
-{{/authors_words}}
-{{#authors_music}}
- {{#first}}{{authors_music_label}}: {{/first}}
- {{entry}}{{^last}}, {{/last}}
- {{#last}}
{{/last}}
-{{/authors_music}}
-{{#authors_translation}}
- {{#first}}{{authors_translation_label}}: {{/first}}
- {{entry}}{{^last}}, {{/last}}
- {{#last}}
{{/last}}
-{{/authors_translation}}
+%if authors_none:
+ <%
+ authors = ", ".join(authors_none)
+ %>
+ ${authors_none_label}: ${authors}
+%endif
-{{#copyright}}
- © {{copyright}}
-{{/copyright}}
+%if authors_words_music:
+ <%
+ authors = ", ".join(authors_words_music)
+ %>
+ ${authors_words_music_label}: ${authors}
+%endif
-{{#songbook_entries}}
- {{entry}}{{^last}}, {{/last}}
- {{#last}}
{{/last}}
-{{/songbook_entries}}
+%if authors_words:
+ <%
+ authors = ", ".join(authors_words)
+ %>
+ ${authors_words_label}: ${authors}
+%endif
-{{#ccli_license}}
- {{ccli_license_label}}: {{ccli_license}}
-{{/ccli_license}}"""
+%if authors_music:
+ <%
+ authors = ", ".join(authors_music)
+ %>
+ ${authors_music_label}: ${authors}
+%endif
+
+%if authors_translation:
+ <%
+ authors = ", ".join(authors_translation)
+ %>
+ ${authors_translation_label}: ${authors}
+%endif
+
+%if copyright:
+ © ${copyright}
+%endif
+
+%if songbook_entries:
+ <%
+ entries = ", ".join(songbook_entries)
+ %>
+ ${entries}
+%endif
+
+%if ccli_license:
+ ${ccli_license_label} ${ccli_license}
+%endif
+"""
}
@@ -344,14 +357,13 @@ class TestMediaItem(TestCase, TestMixin):
"""
Test build songs footer with basic song and one author
"""
- # GIVEN: A Song and a Service Item, mocked settings: True for 'songs/display written by'
- # and False for 'core/ccli number' (ccli will cause traceback if true)
+ # GIVEN: A Song and a Service Item, mocked settings
mocked_settings = MagicMock()
mocked_settings.value.side_effect = [False, "", "0"]
MockedSettings.return_value = mocked_settings
- with patch('pystache.Renderer.render') as MockedRenderer:
+ with patch('mako.template.Template.render_unicode') as MockedRenderer:
mock_song = MagicMock()
mock_song.title = 'My Song'
mock_song.alternate_title = ''
@@ -365,27 +377,23 @@ class TestMediaItem(TestCase, TestMixin):
mock_song.copyright = 'My copyright'
mock_song.songbook_entries = []
service_item = ServiceItem(None)
- MockedRenderer.return_value = ""
# WHEN: I generate the Footer with default settings
author_list = self.media_item.generate_footer(service_item, mock_song)
- # THEN: I get nothing real returned
- self.assertEqual(service_item.footer_html, "", 'pystache isnt in scope')
-
- # AND: The psytache function was called with the following arguments
- MockedRenderer.assert_called_once_with('', {'authors_translation': [], 'authors_music_label': 'Music',
- 'copyright': 'My copyright', 'songbook_entries': [],
- 'alternate_title': '', 'topics': [], 'authors_music_all': [],
- 'authors_words_label': 'Words', 'authors_music': [],
- 'authors_words_music': [], 'ccli_number': '',
- 'authors_none_label': 'Written by', 'title': 'My Song',
- 'authors_words_music_label': 'Words and Music',
- 'authors_none': [{'last_or_penultimate': True, 'last': True,
- 'entry': 'my author', 'first': True}],
- 'ccli_license_label': 'CCLI License', 'authors_words': [],
- 'ccli_license': '0', 'authors_translation_label': 'Translation',
- 'authors_words_all': []})
+ # THEN: The mako function was called with the following arguments
+ args = {'authors_translation': [], 'authors_music_label': 'Music',
+ 'copyright': 'My copyright', 'songbook_entries': [],
+ 'alternate_title': '', 'topics': [], 'authors_music_all': [],
+ 'authors_words_label': 'Words', 'authors_music': [],
+ 'authors_words_music': [], 'ccli_number': '',
+ 'authors_none_label': 'Written by', 'title': 'My Song',
+ 'authors_words_music_label': 'Words and Music',
+ 'authors_none': ['my author'],
+ 'ccli_license_label': 'CCLI License', 'authors_words': [],
+ 'ccli_license': '0', 'authors_translation_label': 'Translation',
+ 'authors_words_all': []}
+ MockedRenderer.assert_called_once_with(**args)
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')