Fix the author_type import properly

This commit is contained in:
Raoul Snyman 2017-03-27 21:08:50 -07:00
parent 419b3e46d8
commit ddd9d4d865
6 changed files with 76 additions and 10 deletions

View File

@ -909,7 +909,9 @@ class SlideController(DisplayController, RegistryProperties):
Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
if old_item.is_media() and not self.service_item.is_media():
self.on_media_close()
Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
if self.is_live:
# This even is only registered for live
Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
def on_slide_selected_index(self, message):
"""

View File

@ -149,7 +149,12 @@ class OpenLPSongImport(SongImport):
class_mapper(OldSongBookEntry)
except UnmappedClassError:
mapper(OldSongBookEntry, source_songs_songbooks_table, properties={'songbook': relation(OldBook)})
if has_authors_songs and 'author_type' in source_authors_songs_table.c.values():
if has_authors_songs:
try:
class_mapper(OldAuthorSong)
except UnmappedClassError:
mapper(OldAuthorSong, source_authors_songs_table)
if has_authors_songs and 'author_type' in source_authors_songs_table.c.keys():
has_author_type = True
else:
has_author_type = False
@ -190,11 +195,6 @@ class OpenLPSongImport(SongImport):
class_mapper(OldTopic)
except UnmappedClassError:
mapper(OldTopic, source_topics_table)
if has_authors_songs:
try:
class_mapper(OldAuthorSong)
except UnmappedClassError:
mapper(OldAuthorSong, source_authors_songs_table)
source_songs = self.source_session.query(OldSong).all()
if self.import_wizard:

View File

@ -22,11 +22,32 @@
"""
This module contains tests for the OpenLP song importer.
"""
import os
from unittest import TestCase
from unittest.mock import patch, MagicMock
from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
from openlp.core.common import Registry
from tests.functional import patch, MagicMock
from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
from tests.helpers.songfileimport import SongImportTestHelper
TEST_PATH = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'openlpsongs'))
class TestOpenLPFileImport(SongImportTestHelper):
def __init__(self, *args, **kwargs):
self.importer_class_name = 'OpenLPSongImport'
self.importer_module_name = 'openlp'
super(TestOpenLPFileImport, self).__init__(*args, **kwargs)
def test_song_import(self):
"""
Test that loading an OpenSong file works correctly on various files
"""
self.file_import([os.path.join(TEST_PATH, 'songs.sqlite')],
self.load_external_result_data(os.path.join(TEST_PATH, 'AmazingGrace.json')))
class TestOpenLPImport(TestCase):

View File

@ -0,0 +1,43 @@
{
"authors": [
"John Newton"
],
"ccli_number": 22025,
"comments": "",
"copyright": "Public Domain ",
"song_book_name": "",
"song_number": 0,
"title": "Amazing Grace",
"topics": [
"Grace"
],
"verse_order_list": [
"V1",
"V2",
"V3",
"V4",
"V5"
],
"verses": [
[
"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.",
"v1"
],
[
"'Twas grace that taught my heart to fear,\nAnd grace my fears relieved.\nHow precious did that grace appear,\nThe hour I first believed.",
"v2"
],
[
"The Lord has promised good to me,\nHis Word my hope secures.\nHe will my shield and portion be\nAs long as life endures.",
"v3"
],
[
"Thro' many dangers, toils and snares\nI have already come.\n'Tis grace that brought me safe thus far,\nAnd grace will lead me home.",
"v4"
],
[
"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.",
"v5"
]
]
}

Binary file not shown.

View File

@ -39,4 +39,4 @@
"v5"
]
]
}
}