From 568806b0ed174dd0f11a05be9f3d6bf63ce98b9b Mon Sep 17 00:00:00 2001 From: STEPHANVS Date: Thu, 22 Jul 2021 23:08:23 +0200 Subject: [PATCH] More pipeline fixes --- openlp/plugins/songs/lib/__init__.py | 2 +- tests/openlp_plugins/songs/test_lib.py | 31 +++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 2fdfdc9dc..f2463bfa1 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -604,7 +604,7 @@ def transpose_verse(verse_text, transpose_value, notation, key): else: # This MUST be a chord transposed_chord, key, lastchord = transpose_chord(word, transpose_value, notation, key, lastchord, - isbass) + isbass) isbass = False transposed_lyrics += transposed_chord # If still inside a chord tag something is wrong! diff --git a/tests/openlp_plugins/songs/test_lib.py b/tests/openlp_plugins/songs/test_lib.py index 3a36b9555..56dfc9f5b 100644 --- a/tests/openlp_plugins/songs/test_lib.py +++ b/tests/openlp_plugins/songs/test_lib.py @@ -275,12 +275,17 @@ def test_transpose_chord_up(): """ # GIVEN: A Chord chord = 'C' + key = None + lastchord = None + isbass = False # WHEN: Transposing it 1 up - new_chord = transpose_chord(chord, 1, 'english', None, None, False) + new_chord, key, lastchord = transpose_chord(chord, 1, 'english', key, lastchord, isbass) # THEN: The chord should be transposed up one note assert new_chord == 'C#', 'The chord should be transposed up.' + assert key == None, 'The key should not be set' + assert lastchord == 'C#', 'If not isbass, then lastchord should be returned' def test_transpose_chord_up_adv(): @@ -289,13 +294,22 @@ def test_transpose_chord_up_adv(): """ # GIVEN: An advanced Chord chord = '(D/F#)' - + key = None + lastchord = None + isbass = False + chordsplit = chord.split("/") # WHEN: Transposing it 1 up - new_chord = transpose_chord(chord, 1, 'english', None, None, False) + new_chord, key, lastchord = transpose_chord(chordsplit[0], 1, 'english', key, lastchord, isbass) + + # AFTER "/" isbass is true, lastchord is set + isbass = True + new_bass, key, lastchord = transpose_chord(chordsplit[1], 1, 'english', key, lastchord, isbass) # THEN: The chord should be transposed up one note - assert new_chord == '(Eb/G)', 'The chord should be transposed up.' - + assert new_chord == '(Eb', 'The chord should be transposed up.' + assert new_bass == 'G)', 'Bass should be transposed up.' + assert key == None, 'no key should be defined' + assert lastchord == 'Eb', 'lastchord is generated' def test_transpose_chord_down(): """ @@ -303,12 +317,17 @@ def test_transpose_chord_down(): """ # GIVEN: A Chord chord = 'C' + key = None + lastchord = None + isbass = False # WHEN: Transposing it 1 down - new_chord = transpose_chord(chord, -1, 'english', None, None, False) + new_chord, key, lastchord = transpose_chord(chord, -1, 'english', key, lastchord, isbass) # THEN: The chord should be transposed down one note assert new_chord == 'B', 'The chord should be transposed down.' + assert key == None, 'The key should not be set' + assert lastchord == 'B', 'If not isbass, then lastchord should be returned' def test_transpose_chord_error():