Merge lp:~tomasgroth/openlp/bugfixes4 into lp:openlp
- bugfixes4
- Merge into trunk
Proposed by
Tomas Groth
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Tim Bentley | ||||||||||||
Approved revision: | 2448 | ||||||||||||
Merged at revision: | 2440 | ||||||||||||
Proposed branch: | lp:~tomasgroth/openlp/bugfixes4 | ||||||||||||
Merge into: | lp:openlp | ||||||||||||
Diff against target: |
440 lines (+179/-40) 12 files modified
openlp.py (+7/-1) openlp/core/ui/projector/__init__.py (+1/-1) openlp/plugins/media/forms/mediaclipselectorform.py (+7/-0) openlp/plugins/songs/forms/duplicatesongremovalform.py (+8/-6) openlp/plugins/songs/lib/importers/wordsofworship.py (+11/-5) openlp/plugins/songs/lib/songcompare.py (+9/-7) tests/functional/openlp_core_ui/test_settingsform.py (+1/-1) tests/functional/openlp_plugins/images/test_imagetab.py (+1/-1) tests/functional/openlp_plugins/songs/test_lib.py (+16/-18) tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py (+56/-0) tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json (+33/-0) tests/resources/wordsofworshipsongs/When morning gilds the skies.json (+29/-0) |
||||||||||||
To merge this branch: | bzr merge lp:~tomasgroth/openlp/bugfixes4 | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Bentley | Approve | ||
Raoul Snyman | Approve | ||
Review via email: mp+240831@code.launchpad.net |
Commit message
Description of the change
Change duplicate check to pass int-string tuples to workers, to workaround bug #1388850, also added multiprocessing
Try to fix DVD 0 track length by waiting. Fixes bug 1387293.
Fix for import of Words of Worship file, bug 1388768, added tests.
To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote : | # |
Revision history for this message
Raoul Snyman (raoul-snyman) : | # |
review:
Approve
Revision history for this message
Tim Bentley (trb143) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp.py' | |||
2 | --- openlp.py 2014-09-04 20:10:34 +0000 | |||
3 | +++ openlp.py 2014-11-06 09:51:19 +0000 | |||
4 | @@ -28,7 +28,9 @@ | |||
5 | 28 | ############################################################################### | 28 | ############################################################################### |
6 | 29 | 29 | ||
7 | 30 | import sys | 30 | import sys |
8 | 31 | import multiprocessing | ||
9 | 31 | 32 | ||
10 | 33 | from openlp.core.common import is_win, is_macosx | ||
11 | 32 | from openlp.core import main | 34 | from openlp.core import main |
12 | 33 | 35 | ||
13 | 34 | 36 | ||
14 | @@ -36,9 +38,13 @@ | |||
15 | 36 | """ | 38 | """ |
16 | 37 | Instantiate and run the application. | 39 | Instantiate and run the application. |
17 | 38 | """ | 40 | """ |
18 | 41 | # Add support for using multiprocessing from frozen Windows executable (built using PyInstaller), | ||
19 | 42 | # see https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support | ||
20 | 43 | if is_win(): | ||
21 | 44 | multiprocessing.freeze_support() | ||
22 | 39 | # Mac OS X passes arguments like '-psn_XXXX' to the application. This argument is actually a process serial number. | 45 | # Mac OS X passes arguments like '-psn_XXXX' to the application. This argument is actually a process serial number. |
23 | 40 | # However, this causes a conflict with other OpenLP arguments. Since we do not use this argument we can delete it | 46 | # However, this causes a conflict with other OpenLP arguments. Since we do not use this argument we can delete it |
24 | 41 | # to avoid any potential conflicts. | 47 | # to avoid any potential conflicts. |
26 | 42 | if sys.platform.startswith('darwin'): | 48 | if is_macosx(): |
27 | 43 | sys.argv = [x for x in sys.argv if not x.startswith('-psn')] | 49 | sys.argv = [x for x in sys.argv if not x.startswith('-psn')] |
28 | 44 | main() | 50 | main() |
29 | 45 | 51 | ||
30 | === modified file 'openlp/core/ui/projector/__init__.py' | |||
31 | --- openlp/core/ui/projector/__init__.py 2014-10-31 19:47:36 +0000 | |||
32 | +++ openlp/core/ui/projector/__init__.py 2014-11-06 09:51:19 +0000 | |||
33 | @@ -28,4 +28,4 @@ | |||
34 | 28 | ############################################################################### | 28 | ############################################################################### |
35 | 29 | """ | 29 | """ |
36 | 30 | The Projector driver module. | 30 | The Projector driver module. |
37 | 31 | """ | ||
38 | 32 | \ No newline at end of file | 31 | \ No newline at end of file |
39 | 32 | """ | ||
40 | 33 | 33 | ||
41 | === modified file 'openlp/plugins/media/forms/mediaclipselectorform.py' | |||
42 | --- openlp/plugins/media/forms/mediaclipselectorform.py 2014-10-31 22:44:22 +0000 | |||
43 | +++ openlp/plugins/media/forms/mediaclipselectorform.py 2014-11-06 09:51:19 +0000 | |||
44 | @@ -446,6 +446,13 @@ | |||
45 | 446 | # Set media length info | 446 | # Set media length info |
46 | 447 | self.playback_length = self.vlc_media_player.get_length() | 447 | self.playback_length = self.vlc_media_player.get_length() |
47 | 448 | log.debug('playback_length: %d ms' % self.playback_length) | 448 | log.debug('playback_length: %d ms' % self.playback_length) |
48 | 449 | # if length is 0, wait a bit, maybe vlc will change its mind... | ||
49 | 450 | loop_count = 0 | ||
50 | 451 | while self.playback_length == 0 and loop_count < 20: | ||
51 | 452 | sleep(0.1) | ||
52 | 453 | self.playback_length = self.vlc_media_player.get_length() | ||
53 | 454 | loop_count += 1 | ||
54 | 455 | log.debug('in loop, playback_length: %d ms' % self.playback_length) | ||
55 | 449 | self.position_slider.setMaximum(self.playback_length) | 456 | self.position_slider.setMaximum(self.playback_length) |
56 | 450 | # setup start and end time | 457 | # setup start and end time |
57 | 451 | rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0) | 458 | rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0) |
58 | 452 | 459 | ||
59 | === modified file 'openlp/plugins/songs/forms/duplicatesongremovalform.py' | |||
60 | --- openlp/plugins/songs/forms/duplicatesongremovalform.py 2014-04-21 09:49:17 +0000 | |||
61 | +++ openlp/plugins/songs/forms/duplicatesongremovalform.py 2014-11-06 09:51:19 +0000 | |||
62 | @@ -48,14 +48,15 @@ | |||
63 | 48 | 48 | ||
64 | 49 | def song_generator(songs): | 49 | def song_generator(songs): |
65 | 50 | """ | 50 | """ |
68 | 51 | This is a generator function to return tuples of two songs. When completed then all songs have once been returned | 51 | This is a generator function to return tuples of tuple with two songs and their position in the song array. |
69 | 52 | combined with any other songs. | 52 | When completed then all songs have once been returned combined with any other songs. |
70 | 53 | 53 | ||
71 | 54 | :param songs: All songs in the database. | 54 | :param songs: All songs in the database. |
72 | 55 | """ | 55 | """ |
73 | 56 | for outer_song_counter in range(len(songs) - 1): | 56 | for outer_song_counter in range(len(songs) - 1): |
74 | 57 | for inner_song_counter in range(outer_song_counter + 1, len(songs)): | 57 | for inner_song_counter in range(outer_song_counter + 1, len(songs)): |
76 | 58 | yield (songs[outer_song_counter], songs[inner_song_counter]) | 58 | yield ((outer_song_counter, songs[outer_song_counter].search_lyrics), |
77 | 59 | (inner_song_counter, songs[inner_song_counter].search_lyrics)) | ||
78 | 59 | 60 | ||
79 | 60 | 61 | ||
80 | 61 | class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): | 62 | class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): |
81 | @@ -187,16 +188,17 @@ | |||
82 | 187 | # Do not accept any further tasks. Also this closes the processes if all tasks are done. | 188 | # Do not accept any further tasks. Also this closes the processes if all tasks are done. |
83 | 188 | pool.close() | 189 | pool.close() |
84 | 189 | # While the processes are still working, start to look at the results. | 190 | # While the processes are still working, start to look at the results. |
86 | 190 | for song_tuple in result: | 191 | for pos_tuple in result: |
87 | 191 | self.duplicate_search_progress_bar.setValue(self.duplicate_search_progress_bar.value() + 1) | 192 | self.duplicate_search_progress_bar.setValue(self.duplicate_search_progress_bar.value() + 1) |
88 | 192 | # The call to process_events() will keep the GUI responsive. | 193 | # The call to process_events() will keep the GUI responsive. |
89 | 193 | self.application.process_events() | 194 | self.application.process_events() |
90 | 194 | if self.break_search: | 195 | if self.break_search: |
91 | 195 | pool.terminate() | 196 | pool.terminate() |
92 | 196 | return | 197 | return |
94 | 197 | if song_tuple is None: | 198 | if pos_tuple is None: |
95 | 198 | continue | 199 | continue |
97 | 199 | song1, song2 = song_tuple | 200 | song1 = songs[pos_tuple[0]] |
98 | 201 | song2 = songs[pos_tuple[1]] | ||
99 | 200 | duplicate_added = self.add_duplicates_to_song_list(song1, song2) | 202 | duplicate_added = self.add_duplicates_to_song_list(song1, song2) |
100 | 201 | if duplicate_added: | 203 | if duplicate_added: |
101 | 202 | self.found_duplicates_edit.appendPlainText(song1.title + " = " + song2.title) | 204 | self.found_duplicates_edit.appendPlainText(song1.title + " = " + song2.title) |
102 | 203 | 205 | ||
103 | === modified file 'openlp/plugins/songs/lib/importers/wordsofworship.py' | |||
104 | --- openlp/plugins/songs/lib/importers/wordsofworship.py 2014-07-04 09:35:10 +0000 | |||
105 | +++ openlp/plugins/songs/lib/importers/wordsofworship.py 2014-11-06 09:51:19 +0000 | |||
106 | @@ -99,7 +99,7 @@ | |||
107 | 99 | """ | 99 | """ |
108 | 100 | Initialise the Words of Worship importer. | 100 | Initialise the Words of Worship importer. |
109 | 101 | """ | 101 | """ |
111 | 102 | SongImport.__init__(self, manager, **kwargs) | 102 | super(WordsOfWorshipImport, self).__init__(manager, **kwargs) |
112 | 103 | 103 | ||
113 | 104 | def do_import(self): | 104 | def do_import(self): |
114 | 105 | """ | 105 | """ |
115 | @@ -112,17 +112,17 @@ | |||
116 | 112 | return | 112 | return |
117 | 113 | self.set_defaults() | 113 | self.set_defaults() |
118 | 114 | song_data = open(source, 'rb') | 114 | song_data = open(source, 'rb') |
120 | 115 | if song_data.read(19) != 'WoW File\nSong Words': | 115 | if song_data.read(19).decode() != 'WoW File\nSong Words': |
121 | 116 | self.log_error(source, | 116 | self.log_error(source, |
122 | 117 | str(translate('SongsPlugin.WordsofWorshipSongImport', | 117 | str(translate('SongsPlugin.WordsofWorshipSongImport', |
124 | 118 | 'Invalid Words of Worship song file. Missing "Wow File\\nSong ' | 118 | 'Invalid Words of Worship song file. Missing "WoW File\\nSong ' |
125 | 119 | 'Words" header.'))) | 119 | 'Words" header.'))) |
126 | 120 | continue | 120 | continue |
127 | 121 | # Seek to byte which stores number of blocks in the song | 121 | # Seek to byte which stores number of blocks in the song |
128 | 122 | song_data.seek(56) | 122 | song_data.seek(56) |
129 | 123 | no_of_blocks = ord(song_data.read(1)) | 123 | no_of_blocks = ord(song_data.read(1)) |
130 | 124 | song_data.seek(66) | 124 | song_data.seek(66) |
132 | 125 | if song_data.read(16) != 'CSongDoc::CBlock': | 125 | if song_data.read(16).decode() != 'CSongDoc::CBlock': |
133 | 126 | self.log_error(source, | 126 | self.log_error(source, |
134 | 127 | str(translate('SongsPlugin.WordsofWorshipSongImport', | 127 | str(translate('SongsPlugin.WordsofWorshipSongImport', |
135 | 128 | 'Invalid Words of Worship song file. Missing "CSongDoc::CBlock" ' | 128 | 'Invalid Words of Worship song file. Missing "CSongDoc::CBlock" ' |
136 | @@ -131,11 +131,17 @@ | |||
137 | 131 | # Seek to the beginning of the first block | 131 | # Seek to the beginning of the first block |
138 | 132 | song_data.seek(82) | 132 | song_data.seek(82) |
139 | 133 | for block in range(no_of_blocks): | 133 | for block in range(no_of_blocks): |
140 | 134 | skip_char_at_end = True | ||
141 | 134 | self.lines_to_read = ord(song_data.read(4)[:1]) | 135 | self.lines_to_read = ord(song_data.read(4)[:1]) |
142 | 135 | block_text = '' | 136 | block_text = '' |
143 | 136 | while self.lines_to_read: | 137 | while self.lines_to_read: |
144 | 137 | self.line_text = str(song_data.read(ord(song_data.read(1))), 'cp1252') | 138 | self.line_text = str(song_data.read(ord(song_data.read(1))), 'cp1252') |
146 | 138 | song_data.seek(1, os.SEEK_CUR) | 139 | if skip_char_at_end: |
147 | 140 | skip_char = ord(song_data.read(1)) | ||
148 | 141 | # Check if we really should skip a char. In some wsg files we shouldn't | ||
149 | 142 | if skip_char != 0: | ||
150 | 143 | song_data.seek(-1, os.SEEK_CUR) | ||
151 | 144 | skip_char_at_end = False | ||
152 | 139 | if block_text: | 145 | if block_text: |
153 | 140 | block_text += '\n' | 146 | block_text += '\n' |
154 | 141 | block_text += self.line_text | 147 | block_text += self.line_text |
155 | 142 | 148 | ||
156 | === modified file 'openlp/plugins/songs/lib/songcompare.py' | |||
157 | --- openlp/plugins/songs/lib/songcompare.py 2014-04-12 16:05:27 +0000 | |||
158 | +++ openlp/plugins/songs/lib/songcompare.py 2014-11-06 09:51:19 +0000 | |||
159 | @@ -59,12 +59,14 @@ | |||
160 | 59 | :param song_tupel: A tuple of two songs to compare. | 59 | :param song_tupel: A tuple of two songs to compare. |
161 | 60 | """ | 60 | """ |
162 | 61 | song1, song2 = song_tupel | 61 | song1, song2 = song_tupel |
166 | 62 | if len(song1.search_lyrics) < len(song2.search_lyrics): | 62 | pos1, lyrics1 = song1 |
167 | 63 | small = song1.search_lyrics | 63 | pos2, lyrics2 = song2 |
168 | 64 | large = song2.search_lyrics | 64 | if len(lyrics1) < len(lyrics2): |
169 | 65 | small = lyrics1 | ||
170 | 66 | large = lyrics2 | ||
171 | 65 | else: | 67 | else: |
174 | 66 | small = song2.search_lyrics | 68 | small = lyrics2 |
175 | 67 | large = song1.search_lyrics | 69 | large = lyrics1 |
176 | 68 | differ = difflib.SequenceMatcher(a=large, b=small) | 70 | differ = difflib.SequenceMatcher(a=large, b=small) |
177 | 69 | diff_tuples = differ.get_opcodes() | 71 | diff_tuples = differ.get_opcodes() |
178 | 70 | diff_no_typos = _remove_typos(diff_tuples) | 72 | diff_no_typos = _remove_typos(diff_tuples) |
179 | @@ -77,7 +79,7 @@ | |||
180 | 77 | length_of_equal_blocks += _op_length(element) | 79 | length_of_equal_blocks += _op_length(element) |
181 | 78 | 80 | ||
182 | 79 | if length_of_equal_blocks >= MIN_BLOCK_SIZE: | 81 | if length_of_equal_blocks >= MIN_BLOCK_SIZE: |
184 | 80 | return song1, song2 | 82 | return pos1, pos2 |
185 | 81 | # Check 2: Similarity based on the relative length of the longest equal block. | 83 | # Check 2: Similarity based on the relative length of the longest equal block. |
186 | 82 | # Calculate the length of the largest equal block of the diff set. | 84 | # Calculate the length of the largest equal block of the diff set. |
187 | 83 | length_of_longest_equal_block = 0 | 85 | length_of_longest_equal_block = 0 |
188 | @@ -85,7 +87,7 @@ | |||
189 | 85 | if element[0] == "equal" and _op_length(element) > length_of_longest_equal_block: | 87 | if element[0] == "equal" and _op_length(element) > length_of_longest_equal_block: |
190 | 86 | length_of_longest_equal_block = _op_length(element) | 88 | length_of_longest_equal_block = _op_length(element) |
191 | 87 | if length_of_longest_equal_block > len(small) * 2 // 3: | 89 | if length_of_longest_equal_block > len(small) * 2 // 3: |
193 | 88 | return song1, song2 | 90 | return pos1, pos2 |
194 | 89 | # Both checks failed. We assume the songs are not equal. | 91 | # Both checks failed. We assume the songs are not equal. |
195 | 90 | return None | 92 | return None |
196 | 91 | 93 | ||
197 | 92 | 94 | ||
198 | === modified file 'tests/functional/openlp_core_ui/test_settingsform.py' | |||
199 | --- tests/functional/openlp_core_ui/test_settingsform.py 2014-10-30 22:53:06 +0000 | |||
200 | +++ tests/functional/openlp_core_ui/test_settingsform.py 2014-11-06 09:51:19 +0000 | |||
201 | @@ -157,4 +157,4 @@ | |||
202 | 157 | 157 | ||
203 | 158 | # THEN: The general tab's cancel() method should have been called, but not the themes tab | 158 | # THEN: The general tab's cancel() method should have been called, but not the themes tab |
204 | 159 | mocked_general_cancel.assert_called_with() | 159 | mocked_general_cancel.assert_called_with() |
205 | 160 | self.assertEqual(0, mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called') | ||
206 | 161 | \ No newline at end of file | 160 | \ No newline at end of file |
207 | 161 | self.assertEqual(0, mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called') | ||
208 | 162 | 162 | ||
209 | === modified file 'tests/functional/openlp_plugins/images/test_imagetab.py' | |||
210 | --- tests/functional/openlp_plugins/images/test_imagetab.py 2014-11-01 11:06:17 +0000 | |||
211 | +++ tests/functional/openlp_plugins/images/test_imagetab.py 2014-11-06 09:51:19 +0000 | |||
212 | @@ -95,4 +95,4 @@ | |||
213 | 95 | self.form.save() | 95 | self.form.save() |
214 | 96 | # THEN: the post process should be requested | 96 | # THEN: the post process should be requested |
215 | 97 | self.assertEqual(1, self.form.settings_form.register_post_process.call_count, | 97 | self.assertEqual(1, self.form.settings_form.register_post_process.call_count, |
216 | 98 | 'Image Post processing should have been requested') | ||
217 | 99 | \ No newline at end of file | 98 | \ No newline at end of file |
218 | 99 | 'Image Post processing should have been requested') | ||
219 | 100 | 100 | ||
220 | === modified file 'tests/functional/openlp_plugins/songs/test_lib.py' | |||
221 | --- tests/functional/openlp_plugins/songs/test_lib.py 2014-05-07 23:52:51 +0000 | |||
222 | +++ tests/functional/openlp_plugins/songs/test_lib.py 2014-11-06 09:51:19 +0000 | |||
223 | @@ -58,8 +58,6 @@ | |||
224 | 58 | i love that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the | 58 | i love that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the |
225 | 59 | old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it | 59 | old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it |
226 | 60 | some day for a crown''' | 60 | some day for a crown''' |
227 | 61 | self.song1 = MagicMock() | ||
228 | 62 | self.song2 = MagicMock() | ||
229 | 63 | 61 | ||
230 | 64 | def clean_string_test(self): | 62 | def clean_string_test(self): |
231 | 65 | """ | 63 | """ |
232 | @@ -92,53 +90,53 @@ | |||
233 | 92 | Test the songs_probably_equal function with twice the same song. | 90 | Test the songs_probably_equal function with twice the same song. |
234 | 93 | """ | 91 | """ |
235 | 94 | # GIVEN: Two equal songs. | 92 | # GIVEN: Two equal songs. |
238 | 95 | self.song1.search_lyrics = self.full_lyrics | 93 | song_tuple1 = (2, self.full_lyrics) |
239 | 96 | self.song2.search_lyrics = self.full_lyrics | 94 | song_tuple2 = (4, self.full_lyrics) |
240 | 97 | 95 | ||
241 | 98 | # WHEN: We compare those songs for equality. | 96 | # WHEN: We compare those songs for equality. |
243 | 99 | result = songs_probably_equal((self.song1, self.song2)) | 97 | result = songs_probably_equal((song_tuple1, song_tuple2)) |
244 | 100 | 98 | ||
245 | 101 | # THEN: The result should be a tuple.. | 99 | # THEN: The result should be a tuple.. |
247 | 102 | assert result == (self.song1, self.song2), 'The result should be the tuble of songs' | 100 | assert result == (2, 4), 'The result should be the tuble of song positions' |
248 | 103 | 101 | ||
249 | 104 | def songs_probably_equal_short_song_test(self): | 102 | def songs_probably_equal_short_song_test(self): |
250 | 105 | """ | 103 | """ |
251 | 106 | Test the songs_probably_equal function with a song and a shorter version of the same song. | 104 | Test the songs_probably_equal function with a song and a shorter version of the same song. |
252 | 107 | """ | 105 | """ |
253 | 108 | # GIVEN: A song and a short version of the same song. | 106 | # GIVEN: A song and a short version of the same song. |
256 | 109 | self.song1.search_lyrics = self.full_lyrics | 107 | song_tuple1 = (1, self.full_lyrics) |
257 | 110 | self.song2.search_lyrics = self.short_lyrics | 108 | song_tuple2 = (3, self.short_lyrics) |
258 | 111 | 109 | ||
259 | 112 | # WHEN: We compare those songs for equality. | 110 | # WHEN: We compare those songs for equality. |
261 | 113 | result = songs_probably_equal((self.song1, self.song2)) | 111 | result = songs_probably_equal((song_tuple1, song_tuple2)) |
262 | 114 | 112 | ||
263 | 115 | # THEN: The result should be a tuple.. | 113 | # THEN: The result should be a tuple.. |
265 | 116 | assert result == (self.song1, self.song2), 'The result should be the tuble of songs' | 114 | assert result == (1, 3), 'The result should be the tuble of song positions' |
266 | 117 | 115 | ||
267 | 118 | def songs_probably_equal_error_song_test(self): | 116 | def songs_probably_equal_error_song_test(self): |
268 | 119 | """ | 117 | """ |
269 | 120 | Test the songs_probably_equal function with a song and a very erroneous version of the same song. | 118 | Test the songs_probably_equal function with a song and a very erroneous version of the same song. |
270 | 121 | """ | 119 | """ |
271 | 122 | # GIVEN: A song and the same song with lots of errors. | 120 | # GIVEN: A song and the same song with lots of errors. |
274 | 123 | self.song1.search_lyrics = self.full_lyrics | 121 | song_tuple1 = (4, self.full_lyrics) |
275 | 124 | self.song2.search_lyrics = self.error_lyrics | 122 | song_tuple2 = (7, self.error_lyrics) |
276 | 125 | 123 | ||
277 | 126 | # WHEN: We compare those songs for equality. | 124 | # WHEN: We compare those songs for equality. |
279 | 127 | result = songs_probably_equal((self.song1, self.song2)) | 125 | result = songs_probably_equal((song_tuple1, song_tuple2)) |
280 | 128 | 126 | ||
283 | 129 | # THEN: The result should be a tuple of songs.. | 127 | # THEN: The result should be a tuple of song positions. |
284 | 130 | assert result == (self.song1, self.song2), 'The result should be the tuble of songs' | 128 | assert result == (4, 7), 'The result should be the tuble of song positions' |
285 | 131 | 129 | ||
286 | 132 | def songs_probably_equal_different_song_test(self): | 130 | def songs_probably_equal_different_song_test(self): |
287 | 133 | """ | 131 | """ |
288 | 134 | Test the songs_probably_equal function with two different songs. | 132 | Test the songs_probably_equal function with two different songs. |
289 | 135 | """ | 133 | """ |
290 | 136 | # GIVEN: Two different songs. | 134 | # GIVEN: Two different songs. |
293 | 137 | self.song1.search_lyrics = self.full_lyrics | 135 | song_tuple1 = (5, self.full_lyrics) |
294 | 138 | self.song2.search_lyrics = self.different_lyrics | 136 | song_tuple2 = (8, self.different_lyrics) |
295 | 139 | 137 | ||
296 | 140 | # WHEN: We compare those songs for equality. | 138 | # WHEN: We compare those songs for equality. |
298 | 141 | result = songs_probably_equal((self.song1, self.song2)) | 139 | result = songs_probably_equal((song_tuple1, song_tuple2)) |
299 | 142 | 140 | ||
300 | 143 | # THEN: The result should be None. | 141 | # THEN: The result should be None. |
301 | 144 | assert result is None, 'The result should be None' | 142 | assert result is None, 'The result should be None' |
302 | 145 | 143 | ||
303 | === added file 'tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py' | |||
304 | --- tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py 1970-01-01 00:00:00 +0000 | |||
305 | +++ tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py 2014-11-06 09:51:19 +0000 | |||
306 | @@ -0,0 +1,56 @@ | |||
307 | 1 | # -*- coding: utf-8 -*- | ||
308 | 2 | # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 | ||
309 | 3 | |||
310 | 4 | ############################################################################### | ||
311 | 5 | # OpenLP - Open Source Lyrics Projection # | ||
312 | 6 | # --------------------------------------------------------------------------- # | ||
313 | 7 | # Copyright (c) 2008-2014 Raoul Snyman # | ||
314 | 8 | # Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # | ||
315 | 9 | # Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # | ||
316 | 10 | # Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # | ||
317 | 11 | # Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # | ||
318 | 12 | # Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # | ||
319 | 13 | # Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # | ||
320 | 14 | # Frode Woldsund, Martin Zibricky, Patrick Zimmermann # | ||
321 | 15 | # --------------------------------------------------------------------------- # | ||
322 | 16 | # This program is free software; you can redistribute it and/or modify it # | ||
323 | 17 | # under the terms of the GNU General Public License as published by the Free # | ||
324 | 18 | # Software Foundation; version 2 of the License. # | ||
325 | 19 | # # | ||
326 | 20 | # This program is distributed in the hope that it will be useful, but WITHOUT # | ||
327 | 21 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # | ||
328 | 22 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # | ||
329 | 23 | # more details. # | ||
330 | 24 | # # | ||
331 | 25 | # You should have received a copy of the GNU General Public License along # | ||
332 | 26 | # with this program; if not, write to the Free Software Foundation, Inc., 59 # | ||
333 | 27 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA # | ||
334 | 28 | ############################################################################### | ||
335 | 29 | """ | ||
336 | 30 | This module contains tests for the Words of Worship song importer. | ||
337 | 31 | """ | ||
338 | 32 | |||
339 | 33 | import os | ||
340 | 34 | |||
341 | 35 | from tests.helpers.songfileimport import SongImportTestHelper | ||
342 | 36 | from openlp.plugins.songs.lib.importers.wordsofworship import WordsOfWorshipImport | ||
343 | 37 | |||
344 | 38 | TEST_PATH = os.path.abspath( | ||
345 | 39 | os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'wordsofworshipsongs')) | ||
346 | 40 | |||
347 | 41 | |||
348 | 42 | class TestWordsOfWorshipFileImport(SongImportTestHelper): | ||
349 | 43 | |||
350 | 44 | def __init__(self, *args, **kwargs): | ||
351 | 45 | self.importer_class_name = 'WordsOfWorshipImport' | ||
352 | 46 | self.importer_module_name = 'wordsofworship' | ||
353 | 47 | super(TestWordsOfWorshipFileImport, self).__init__(*args, **kwargs) | ||
354 | 48 | |||
355 | 49 | def test_song_import(self): | ||
356 | 50 | """ | ||
357 | 51 | Test that loading a Words of Worship file works correctly | ||
358 | 52 | """ | ||
359 | 53 | self.file_import([os.path.join(TEST_PATH, 'Amazing Grace (6 Verses).wow-song')], | ||
360 | 54 | self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace (6 Verses).json'))) | ||
361 | 55 | self.file_import([os.path.join(TEST_PATH, 'When morning gilds the skies.wsg')], | ||
362 | 56 | self.load_external_result_data(os.path.join(TEST_PATH, 'When morning gilds the skies.json'))) | ||
363 | 0 | 57 | ||
364 | === added directory 'tests/resources/wordsofworshipsongs' | |||
365 | === added file 'tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json' | |||
366 | --- tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json 1970-01-01 00:00:00 +0000 | |||
367 | +++ tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json 2014-11-06 09:51:19 +0000 | |||
368 | @@ -0,0 +1,33 @@ | |||
369 | 1 | { | ||
370 | 2 | "authors": [ | ||
371 | 3 | "John Newton (1725-1807)" | ||
372 | 4 | ], | ||
373 | 5 | "title": "Amazing Grace (6 Verses)", | ||
374 | 6 | "verse_order_list": [], | ||
375 | 7 | "verses": [ | ||
376 | 8 | [ | ||
377 | 9 | "Amazing grace! how sweet the sound\nThat saved a wretch like me;\nI once was lost, but now am found,\nWas blind, but now I see.", | ||
378 | 10 | "V" | ||
379 | 11 | ], | ||
380 | 12 | [ | ||
381 | 13 | "'Twas grace that taught my heart to fear,\nAnd grace my fears relieved;\nHow precious did that grace appear,\nThe hour I first believed!", | ||
382 | 14 | "V" | ||
383 | 15 | ], | ||
384 | 16 | [ | ||
385 | 17 | "Through many dangers, toils and snares\nI have already come;\n'Tis grace that brought me safe thus far,\nAnd grace will lead me home.", | ||
386 | 18 | "V" | ||
387 | 19 | ], | ||
388 | 20 | [ | ||
389 | 21 | "The Lord has promised good to me,\nHis word my hope secures;\nHe will my shield and portion be\nAs long as life endures.", | ||
390 | 22 | "V" | ||
391 | 23 | ], | ||
392 | 24 | [ | ||
393 | 25 | "Yes, when this heart and flesh shall fail,\nAnd mortal life shall cease,\nI shall possess within the veil\nA life of joy and peace.", | ||
394 | 26 | "V" | ||
395 | 27 | ], | ||
396 | 28 | [ | ||
397 | 29 | "When we've been there ten thousand years,\nBright shining as the sun,\nWe've no less days to sing God's praise\nThan when we first begun.", | ||
398 | 30 | "V" | ||
399 | 31 | ] | ||
400 | 32 | ] | ||
401 | 33 | } | ||
402 | 0 | 34 | ||
403 | === added file 'tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song' | |||
404 | 1 | Binary files tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song 1970-01-01 00:00:00 +0000 and tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song 2014-11-06 09:51:19 +0000 differ | 35 | Binary files tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song 1970-01-01 00:00:00 +0000 and tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song 2014-11-06 09:51:19 +0000 differ |
405 | === added file 'tests/resources/wordsofworshipsongs/When morning gilds the skies.json' | |||
406 | --- tests/resources/wordsofworshipsongs/When morning gilds the skies.json 1970-01-01 00:00:00 +0000 | |||
407 | +++ tests/resources/wordsofworshipsongs/When morning gilds the skies.json 2014-11-06 09:51:19 +0000 | |||
408 | @@ -0,0 +1,29 @@ | |||
409 | 1 | { | ||
410 | 2 | "authors": [ | ||
411 | 3 | "Author Unknown. Tr. Edward Caswall" | ||
412 | 4 | ], | ||
413 | 5 | "title": "When morning gilds the skies", | ||
414 | 6 | "verse_order_list": [], | ||
415 | 7 | "verses": [ | ||
416 | 8 | [ | ||
417 | 9 | "When morning gilds the skies\nMy heart awaking cries:\n'May Jesus Christ be prais'd!'\nAlike at work and prayer to Jesus I repair:\n'May Jesus Christ be prais'd!'", | ||
418 | 10 | "V" | ||
419 | 11 | ], | ||
420 | 12 | [ | ||
421 | 13 | "Does sadness fill my mind?\nA solace here I find:\n'May Jesus Christ be praised!'\nWhen evil thoughts molest,\nWith this I shield my breast:\n'May Jesus Christ be prais'd!'", | ||
422 | 14 | "V" | ||
423 | 15 | ], | ||
424 | 16 | [ | ||
425 | 17 | "To God, the Word, on high\nThe hosts of angels cry:\n'May Jesus Christ be prais'd!'\nLet mortals, too, upraise\nTheir voice in hymns of praise:\n'May Jesus Christ be prais'd!'", | ||
426 | 18 | "V" | ||
427 | 19 | ], | ||
428 | 20 | [ | ||
429 | 21 | "Let earth's wide circle round\nIn joyful notes resound:\n'May Jesus Christ be prais'd!'\nLet air, and sea, and sky,\nFrom depth to height, reply:\n'May Jesus Christ be prais'd!'", | ||
430 | 22 | "V" | ||
431 | 23 | ], | ||
432 | 24 | [ | ||
433 | 25 | "Be this while life is mine\nMy canticle divine\n'May Jesus Christ be prais'd!'\nBe this the eternal song,\nThrough all the ages long:\n'May Jesus Christ be prais'd!'", | ||
434 | 26 | "V" | ||
435 | 27 | ] | ||
436 | 28 | ] | ||
437 | 29 | } | ||
438 | 0 | 30 | ||
439 | === added file 'tests/resources/wordsofworshipsongs/When morning gilds the skies.wsg' | |||
440 | 1 | Binary files tests/resources/wordsofworshipsongs/When morning gilds the skies.wsg 1970-01-01 00:00:00 +0000 and tests/resources/wordsofworshipsongs/When morning gilds the skies.wsg 2014-11-06 09:51:19 +0000 differ | 31 | Binary files tests/resources/wordsofworshipsongs/When morning gilds the skies.wsg 1970-01-01 00:00:00 +0000 and tests/resources/wordsofworshipsongs/When morning gilds the skies.wsg 2014-11-06 09:51:19 +0000 differ |
lp:~tomasgroth/openlp/bugfixes4 (revision 2448) ci.openlp. org/job/ Branch- 01-Pull/ 750/ ci.openlp. org/job/ Branch- 02-Functional- Tests/688/ ci.openlp. org/job/ Branch- 03-Interface- Tests/632/ ci.openlp. org/job/ Branch- 04a-Windows_ Functional_ Tests/571/ ci.openlp. org/job/ Branch- 04b-Windows_ Interface_ Tests/180/ ci.openlp. org/job/ Branch- 05a-Code_ Analysis/ 385/ ci.openlp. org/job/ Branch- 05b-Test_ Coverage/ 259/
[SUCCESS] http://
[SUCCESS] http://
[SUCCESS] http://
[SUCCESS] http://
[SUCCESS] http://
[SUCCESS] http://
[SUCCESS] http://