Merge lp:~suutari-olli/openlp/add-bible-license-field into lp:openlp

Proposed by Azaziah
Status: Superseded
Proposed branch: lp:~suutari-olli/openlp/add-bible-license-field
Merge into: lp:openlp
Diff against target: 400 lines (+125/-23)
9 files modified
openlp/core/common/uistrings.py (+10/-7)
openlp/plugins/bibles/forms/bibleimportform.py (+17/-2)
openlp/plugins/bibles/forms/editbibledialog.py (+7/-0)
openlp/plugins/bibles/forms/editbibleform.py (+23/-4)
openlp/plugins/bibles/lib/manager.py (+5/-5)
openlp/plugins/songs/lib/mediaitem.py (+7/-2)
openlp/plugins/songs/lib/songstab.py (+13/-1)
openlp/plugins/songs/songsplugin.py (+1/-0)
tests/functional/openlp_plugins/songs/test_mediaitem.py (+42/-2)
To merge this branch: bzr merge lp:~suutari-olli/openlp/add-bible-license-field
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Fixing
Tim Bentley Pending
Review via email: mp+312426@code.launchpad.net

This proposal supersedes a proposal from 2016-09-18.

This proposal has been superseded by a proposal from 2016-12-18.

Description of the change

In this branch:
- Added "Full License" field for Bibles (1623631)
- Added a setting for controlling visibility of "Written by:" (1557579)
- Added placeholder texts for Bible metadata fields
- Re-organized uistrings to alphabetical order

lp:~suutari-olli/openlp/add-bible-license-field (revision 2711)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1856/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1767/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1705/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1449/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/1039/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/1107/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/975/
[SUCCESS] https://ci.openlp.io/job/Branch-05c-Code_Analysis2/127/

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Needs a test just a minor fix is not enough
Some inline comments.

review: Needs Fixing
Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

Thanks for the comments, I've replied to them.

Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

> Needs a test just a minor fix is not enough
> Some inline comments.

I've replied to the comments,
will work on a test later.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

A few small fixes and then you should be good to go.

review: Needs Fixing
2712. By Azaziah

- Changed one pair of " to '
- Changed the code for checking Bible meta exists
- Changed the default value for the new setting to "True"

Revision history for this message
Azaziah (suutari-olli) wrote :

Thanks for the review, I've fixed them.

2713. By Azaziah

- Merged trunk on 23.12.16

2714. By Azaziah

- Merged trunk on 8.1.17

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/common/uistrings.py'
2--- openlp/core/common/uistrings.py 2016-11-12 10:00:36 +0000
3+++ openlp/core/common/uistrings.py 2016-12-18 06:07:36 +0000
4@@ -59,6 +59,13 @@
5 self.Automatic = translate('OpenLP.Ui', 'Automatic')
6 self.BackgroundColor = translate('OpenLP.Ui', 'Background Color')
7 self.BackgroundColorColon = translate('OpenLP.Ui', 'Background color:')
8+ self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
9+ self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
10+ 'than 3 characters long.</strong><br><br>Please try again with '
11+ 'a longer search.')
12+ self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
13+ self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
14+ 'Please use the Import Wizard to install one or more Bibles.')
15 self.Bottom = translate('OpenLP.Ui', 'Bottom')
16 self.Browse = translate('OpenLP.Ui', 'Browse...')
17 self.Cancel = translate('OpenLP.Ui', 'Cancel')
18@@ -118,6 +125,8 @@
19 self.OLPV2x = "{name} {version}".format(name=self.OLP, version="2.4")
20 self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')
21 self.OpenService = translate('OpenLP.Ui', 'Open service.')
22+ self.OptionalShowInFooter = translate('OpenLP.Ui', 'Optional, this will be displayed in footer.')
23+ self.OptionalHideInFooter = translate('OpenLP.Ui', 'Optional, this won\'t be displayed in footer.')
24 self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop')
25 self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End')
26 self.Preview = translate('OpenLP.Ui', 'Preview')
27@@ -131,6 +140,7 @@
28 'player is disabled.')
29 self.ResetBG = translate('OpenLP.Ui', 'Reset Background')
30 self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.')
31+ self.RequiredShowInFooter = translate('OpenLP.Ui', 'Required, this will be displayed in footer.')
32 self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
33 self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
34 self.Search = translate('OpenLP.Ui', 'Search')
35@@ -159,13 +169,6 @@
36 self.View = translate('OpenLP.Ui', 'View')
37 self.ViewMode = translate('OpenLP.Ui', 'View Mode')
38 self.Video = translate('OpenLP.Ui', 'Video')
39- self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
40- self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
41- 'than 3 characters long.</strong><br><br>Please try again with '
42- 'a longer search.')
43- self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
44- self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
45- 'Please use the Import Wizard to install one or more Bibles.')
46 book_chapter = translate('OpenLP.Ui', 'Book Chapter')
47 chapter = translate('OpenLP.Ui', 'Chapter')
48 verse = translate('OpenLP.Ui', 'Verse')
49
50=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
51--- openlp/plugins/bibles/forms/bibleimportform.py 2016-11-25 14:21:27 +0000
52+++ openlp/plugins/bibles/forms/bibleimportform.py 2016-12-18 06:07:36 +0000
53@@ -408,6 +408,12 @@
54 self.permissions_edit = QtWidgets.QLineEdit(self.license_details_page)
55 self.permissions_edit.setObjectName('PermissionsEdit')
56 self.license_details_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.permissions_edit)
57+ self.full_license_label = QtWidgets.QLabel(self.license_details_page)
58+ self.full_license_label.setObjectName('FullLicenseLabel')
59+ self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.full_license_label)
60+ self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_page)
61+ self.full_license_edit.setObjectName('FullLicenseEdit')
62+ self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.full_license_edit)
63 self.addPage(self.license_details_page)
64
65 def retranslateUi(self):
66@@ -480,6 +486,7 @@
67 self.version_name_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
68 self.copyright_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
69 self.permissions_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
70+ self.full_license_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Full license:'))
71 self.progress_page.setTitle(WizardStrings.Importing)
72 self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
73 'Please wait while your Bible is imported.'))
74@@ -504,6 +511,7 @@
75 elif self.currentPage() == self.select_page:
76 self.version_name_edit.clear()
77 self.permissions_edit.clear()
78+ self.full_license_edit.clear()
79 self.copyright_edit.clear()
80 if self.field('source_format') == BibleFormat.OSIS:
81 if not self.field('osis_location'):
82@@ -763,6 +771,7 @@
83 self.license_details_page.registerField('license_version', self.version_name_edit)
84 self.license_details_page.registerField('license_copyright', self.copyright_edit)
85 self.license_details_page.registerField('license_permissions', self.permissions_edit)
86+ self.license_details_page.registerField("license_full_license", self.full_license_edit, 'plainText')
87
88 def set_defaults(self):
89 """
90@@ -787,8 +796,13 @@
91 self.setField('proxy_username', settings.value('proxy username'))
92 self.setField('proxy_password', settings.value('proxy password'))
93 self.setField('license_version', self.version_name_edit.text())
94+ self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
95 self.setField('license_copyright', self.copyright_edit.text())
96+ self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
97 self.setField('license_permissions', self.permissions_edit.text())
98+ self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
99+ self.setField('license_full_license', self.full_license_edit.toPlainText())
100+ self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
101 self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
102 settings.endGroup()
103
104@@ -812,6 +826,7 @@
105 license_version = self.field('license_version')
106 license_copyright = self.field('license_copyright')
107 license_permissions = self.field('license_permissions')
108+ license_full_license = self.field('license_full_license')
109 importer = None
110 if bible_type == BibleFormat.OSIS:
111 # Import an OSIS bible.
112@@ -861,10 +876,10 @@
113 sword_path=self.field('sword_zip_path'),
114 sword_key=self.sword_zipbible_combo_box.itemData(
115 self.sword_zipbible_combo_box.currentIndex()))
116-
117 try:
118 if importer.do_import(license_version) and not importer.stop_import_flag:
119- self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions)
120+ self.manager.save_meta_data(license_version, license_version,
121+ license_copyright, license_permissions, license_full_license)
122 self.manager.reload_bibles()
123 if bible_type == BibleFormat.WebDownload:
124 self.progress_label.setText(
125
126=== modified file 'openlp/plugins/bibles/forms/editbibledialog.py'
127--- openlp/plugins/bibles/forms/editbibledialog.py 2016-10-27 17:45:50 +0000
128+++ openlp/plugins/bibles/forms/editbibledialog.py 2016-12-18 06:07:36 +0000
129@@ -68,6 +68,12 @@
130 self.permissions_edit.setObjectName('permissions_edit')
131 self.permissions_label.setBuddy(self.permissions_edit)
132 self.license_details_layout.addRow(self.permissions_label, self.permissions_edit)
133+ self.full_license_label = QtWidgets.QLabel(self.license_details_group_box)
134+ self.full_license_label.setObjectName('full_license_label')
135+ self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_group_box)
136+ self.full_license_edit.setObjectName('full_license_edit')
137+ self.full_license_label.setBuddy(self.full_license_edit)
138+ self.license_details_layout.addRow(self.full_license_label, self.full_license_edit)
139 self.meta_tab_layout.addWidget(self.license_details_group_box)
140 self.language_selection_group_box = QtWidgets.QGroupBox(self.meta_tab)
141 self.language_selection_group_box.setObjectName('language_selection_group_box')
142@@ -132,6 +138,7 @@
143 self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
144 self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
145 self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
146+ self.full_license_label.setText(translate('BiblesPlugin.EditBibleForm', 'Full license:'))
147 self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
148 self.language_selection_label.setText(
149 translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and '
150
151=== modified file 'openlp/plugins/bibles/forms/editbibleform.py'
152--- openlp/plugins/bibles/forms/editbibleform.py 2016-05-21 08:31:24 +0000
153+++ openlp/plugins/bibles/forms/editbibleform.py 2016-12-18 06:07:36 +0000
154@@ -61,10 +61,28 @@
155 """
156 log.debug('Load Bible')
157 self.bible = bible
158- self.version_name_edit.setText(self.manager.get_meta_data(self.bible, 'name').value)
159- self.copyright_edit.setText(self.manager.get_meta_data(self.bible, 'copyright').value)
160- self.permissions_edit.setText(self.manager.get_meta_data(self.bible, 'permissions').value)
161 book_name_language = self.manager.get_meta_data(self.bible, 'book_name_language')
162+ """
163+ Try loading the metadata, if the field does not exist in the metadata, continue executing the code,
164+ missing fields will be created on "self.accept" (save).
165+ """
166+ meta = self.manager.get_meta_data(self.bible, 'name')
167+ copyright = self.manager.get_meta_data(self.bible, 'copyright')
168+ permission = self.manager.get_meta_data(self.bible, 'permissions')
169+ full_license = self.manager.get_meta_data(self.bible, 'full_license')
170+ if meta:
171+ self.version_name_edit.setText(meta.value)
172+ if copyright:
173+ self.copyright_edit.setText(copyright.value)
174+ if permission:
175+ self.permissions_edit.setText(permission.value)
176+ if full_license:
177+ self.full_license_edit.setPlainText(full_license.value)
178+ # Set placeholder texts for the fields.
179+ self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
180+ self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
181+ self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
182+ self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
183 if book_name_language and book_name_language.value != 'None':
184 self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1)
185 self.books = {}
186@@ -107,6 +125,7 @@
187 version = self.version_name_edit.text()
188 copyright = self.copyright_edit.text()
189 permissions = self.permissions_edit.text()
190+ full_license = self.full_license_edit.toPlainText()
191 book_name_language = self.language_selection_combo_box.currentIndex() - 1
192 if book_name_language == -1:
193 book_name_language = None
194@@ -121,7 +140,7 @@
195 if not self.validate_book(custom_names[abbr], abbr):
196 return
197 self.application.set_busy_cursor()
198- self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
199+ self.manager.save_meta_data(self.bible, version, copyright, permissions, full_license, book_name_language)
200 if not self.web_bible:
201 for abbr, book in self.books.items():
202 if book:
203
204=== modified file 'openlp/plugins/bibles/lib/manager.py'
205--- openlp/plugins/bibles/lib/manager.py 2016-11-24 21:48:51 +0000
206+++ openlp/plugins/bibles/lib/manager.py 2016-12-18 06:07:36 +0000
207@@ -380,17 +380,17 @@
208 else:
209 return None
210
211- def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None):
212+ def save_meta_data(self, bible, version, copyright, permissions, full_license, book_name_language=None):
213 """
214 Saves the bibles meta data.
215 """
216- log.debug('save_meta data {bible}, {version}, {copyright}, {perms}'.format(bible=bible,
217- version=version,
218- copyright=copyright,
219- perms=permissions))
220+ log.debug('save_meta data {bible}, {version}, {copyright},'
221+ ' {perms}, {full_license}'.format(bible=bible, version=version, copyright=copyright,
222+ perms=permissions, full_license=full_license))
223 self.db_cache[bible].save_meta('name', version)
224 self.db_cache[bible].save_meta('copyright', copyright)
225 self.db_cache[bible].save_meta('permissions', permissions)
226+ self.db_cache[bible].save_meta('full_license', full_license)
227 self.db_cache[bible].save_meta('book_name_language', book_name_language)
228
229 def get_meta_data(self, bible, key):
230
231=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
232--- openlp/plugins/songs/lib/mediaitem.py 2016-11-15 22:44:11 +0000
233+++ openlp/plugins/songs/lib/mediaitem.py 2016-12-18 06:07:36 +0000
234@@ -126,6 +126,7 @@
235 self.update_service_on_edit = Settings().value(self.settings_section + '/update service on edit')
236 self.add_song_from_service = Settings().value(self.settings_section + '/add song from service')
237 self.display_songbook = Settings().value(self.settings_section + '/display songbook')
238+ self.display_written_by_text = Settings().value(self.settings_section + '/display written by')
239 self.display_copyright_symbol = Settings().value(self.settings_section + '/display copyright symbol')
240
241 def retranslateUi(self):
242@@ -640,8 +641,12 @@
243 item.raw_footer = []
244 item.raw_footer.append(song.title)
245 if authors_none:
246- item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
247- authors=create_separated_list(authors_none)))
248+ # If the setting for showing "Written by:" is enabled, show it before unspecified authors.
249+ if Settings().value('songs/display written by'):
250+ item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
251+ authors=create_separated_list(authors_none)))
252+ else:
253+ item.raw_footer.append("{authors}".format(authors=create_separated_list(authors_none)))
254 if authors_words_music:
255 item.raw_footer.append("{text}: {authors}".format(text=AuthorType.Types[AuthorType.WordsAndMusic],
256 authors=create_separated_list(authors_words_music)))
257
258=== modified file 'openlp/plugins/songs/lib/songstab.py'
259--- openlp/plugins/songs/lib/songstab.py 2016-07-24 20:20:25 +0000
260+++ openlp/plugins/songs/lib/songstab.py 2016-12-18 06:07:36 +0000
261@@ -53,6 +53,9 @@
262 self.display_songbook_check_box = QtWidgets.QCheckBox(self.mode_group_box)
263 self.display_songbook_check_box.setObjectName('songbook_check_box')
264 self.mode_layout.addWidget(self.display_songbook_check_box)
265+ self.display_written_by_check_box = QtWidgets.QCheckBox(self.mode_group_box)
266+ self.display_written_by_check_box.setObjectName('written_by_check_box')
267+ self.mode_layout.addWidget(self.display_written_by_check_box)
268 self.display_copyright_check_box = QtWidgets.QCheckBox(self.mode_group_box)
269 self.display_copyright_check_box.setObjectName('copyright_check_box')
270 self.mode_layout.addWidget(self.display_copyright_check_box)
271@@ -63,16 +66,19 @@
272 self.update_on_edit_check_box.stateChanged.connect(self.on_update_on_edit_check_box_changed)
273 self.add_from_service_check_box.stateChanged.connect(self.on_add_from_service_check_box_changed)
274 self.display_songbook_check_box.stateChanged.connect(self.on_songbook_check_box_changed)
275+ self.display_written_by_check_box.stateChanged.connect(self.on_written_by_check_box_changed)
276 self.display_copyright_check_box.stateChanged.connect(self.on_copyright_check_box_changed)
277
278 def retranslateUi(self):
279- self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Songs Mode'))
280+ self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Song related settings'))
281 self.tool_bar_active_check_box.setText(translate('SongsPlugin.SongsTab',
282 'Enable "Go to verse" button in Live panel'))
283 self.update_on_edit_check_box.setText(translate('SongsPlugin.SongsTab', 'Update service from song edit'))
284 self.add_from_service_check_box.setText(translate('SongsPlugin.SongsTab',
285 'Import missing songs from Service files'))
286 self.display_songbook_check_box.setText(translate('SongsPlugin.SongsTab', 'Display songbook in footer'))
287+ self.display_written_by_check_box.setText(translate(
288+ 'SongsPlugin.SongsTab', 'Show "Written by:" in footer for unspecified authors'))
289 self.display_copyright_check_box.setText(translate('SongsPlugin.SongsTab',
290 'Display "{symbol}" symbol before copyright '
291 'info').format(symbol=SongStrings.CopyrightSymbol))
292@@ -92,6 +98,9 @@
293 def on_songbook_check_box_changed(self, check_state):
294 self.display_songbook = (check_state == QtCore.Qt.Checked)
295
296+ def on_written_by_check_box_changed(self, check_state):
297+ self.display_written_by = (check_state == QtCore.Qt.Checked)
298+
299 def on_copyright_check_box_changed(self, check_state):
300 self.display_copyright_symbol = (check_state == QtCore.Qt.Checked)
301
302@@ -102,11 +111,13 @@
303 self.update_edit = settings.value('update service on edit')
304 self.update_load = settings.value('add song from service')
305 self.display_songbook = settings.value('display songbook')
306+ self.display_written_by = settings.value('display written by')
307 self.display_copyright_symbol = settings.value('display copyright symbol')
308 self.tool_bar_active_check_box.setChecked(self.tool_bar)
309 self.update_on_edit_check_box.setChecked(self.update_edit)
310 self.add_from_service_check_box.setChecked(self.update_load)
311 self.display_songbook_check_box.setChecked(self.display_songbook)
312+ self.display_written_by_check_box.setChecked(self.display_written_by)
313 self.display_copyright_check_box.setChecked(self.display_copyright_symbol)
314 settings.endGroup()
315
316@@ -117,6 +128,7 @@
317 settings.setValue('update service on edit', self.update_edit)
318 settings.setValue('add song from service', self.update_load)
319 settings.setValue('display songbook', self.display_songbook)
320+ settings.setValue('display written by', self.display_written_by)
321 settings.setValue('display copyright symbol', self.display_copyright_symbol)
322 settings.endGroup()
323 if self.tab_visited:
324
325=== modified file 'openlp/plugins/songs/songsplugin.py'
326--- openlp/plugins/songs/songsplugin.py 2016-09-19 18:51:48 +0000
327+++ openlp/plugins/songs/songsplugin.py 2016-12-18 06:07:36 +0000
328@@ -60,6 +60,7 @@
329 'songs/add song from service': True,
330 'songs/display songbar': True,
331 'songs/display songbook': False,
332+ 'songs/display written by': True,
333 'songs/display copyright symbol': False,
334 'songs/last directory import': '',
335 'songs/last directory export': '',
336
337=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
338--- tests/functional/openlp_plugins/songs/test_mediaitem.py 2016-05-31 21:40:13 +0000
339+++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2016-12-18 06:07:36 +0000
340@@ -295,11 +295,18 @@
341 mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
342 self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
343
344- def test_build_song_footer_one_author(self):
345+ @patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
346+ def test_build_song_footer_one_author_show_written_by(self, MockedSettings):
347 """
348 Test build songs footer with basic song and one author
349 """
350- # GIVEN: A Song and a Service Item
351+ # GIVEN: A Song and a Service Item, mocked settings: True for 'songs/display written by'
352+ # and False for 'core/ccli number' (ccli will cause traceback if true)
353+
354+ mocked_settings = MagicMock()
355+ mocked_settings.value.side_effect = [True, False]
356+ MockedSettings.return_value = mocked_settings
357+
358 mock_song = MagicMock()
359 mock_song.title = 'My Song'
360 mock_song.authors_songs = []
361@@ -320,6 +327,39 @@
362 self.assertEqual(author_list, ['my author'],
363 'The author list should be returned correctly with one author')
364
365+ @patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
366+ def test_build_song_footer_one_author_hide_written_by(self, MockedSettings):
367+ """
368+ Test build songs footer with basic song and one author
369+ """
370+ # GIVEN: A Song and a Service Item, mocked settings: False for 'songs/display written by'
371+ # and False for 'core/ccli number' (ccli will cause traceback if true)
372+
373+ mocked_settings = MagicMock()
374+ mocked_settings.value.side_effect = [False, False]
375+ MockedSettings.return_value = mocked_settings
376+
377+ mock_song = MagicMock()
378+ mock_song.title = 'My Song'
379+ mock_song.authors_songs = []
380+ mock_author = MagicMock()
381+ mock_author.display_name = 'my author'
382+ mock_author_song = MagicMock()
383+ mock_author_song.author = mock_author
384+ mock_song.authors_songs.append(mock_author_song)
385+ mock_song.copyright = 'My copyright'
386+ service_item = ServiceItem(None)
387+
388+ # WHEN: I generate the Footer with default settings
389+ author_list = self.media_item.generate_footer(service_item, mock_song)
390+
391+ # THEN: I get the following Array returned
392+ self.assertEqual(service_item.raw_footer, ['My Song', 'my author', 'My copyright'],
393+ 'The array should be returned correctly with a song, one author and copyright,'
394+ 'text Written by should not be part of the text.')
395+ self.assertEqual(author_list, ['my author'],
396+ 'The author list should be returned correctly with one author')
397+
398 def test_build_song_footer_two_authors(self):
399 """
400 Test build songs footer with basic song and two authors