Merge lp:~sam92/openlp/bug-1154467 into lp:openlp

Proposed by Samuel Mehrbrodt
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2352
Merged at revision: 2365
Proposed branch: lp:~sam92/openlp/bug-1154467
Merge into: lp:openlp
Diff against target: 90 lines (+64/-1)
2 files modified
openlp/plugins/bibles/lib/db.py (+8/-1)
tests/functional/openlp_plugins/songs/test_zionworximport.py (+56/-0)
To merge this branch: bzr merge lp:~sam92/openlp/bug-1154467
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+215964@code.launchpad.net

This proposal supersedes a proposal from 2014-04-10.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Please try to make your tests a little bit more substantial.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/bibles/lib/db.py'
2--- openlp/plugins/bibles/lib/db.py 2014-04-12 20:19:22 +0000
3+++ openlp/plugins/bibles/lib/db.py 2014-04-15 21:19:26 +0000
4@@ -32,9 +32,11 @@
5 import os
6 import re
7 import sqlite3
8+import time
9
10 from PyQt4 import QtCore
11 from sqlalchemy import Column, ForeignKey, Table, or_, types, func
12+from sqlalchemy.exc import OperationalError
13 from sqlalchemy.orm import class_mapper, mapper, relation
14 from sqlalchemy.orm.exc import UnmappedClassError
15
16@@ -235,7 +237,12 @@
17 text=verse_text
18 )
19 self.session.add(verse)
20- self.session.commit()
21+ try:
22+ self.session.commit()
23+ except OperationalError:
24+ # Wait 10ms and try again (lp#1154467)
25+ time.sleep(0.01)
26+ self.session.commit()
27
28 def create_verse(self, book_id, chapter, verse, text):
29 """
30
31=== added file 'tests/functional/openlp_plugins/songs/test_zionworximport.py'
32--- tests/functional/openlp_plugins/songs/test_zionworximport.py 1970-01-01 00:00:00 +0000
33+++ tests/functional/openlp_plugins/songs/test_zionworximport.py 2014-04-15 21:19:26 +0000
34@@ -0,0 +1,56 @@
35+# -*- coding: utf-8 -*-
36+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
37+
38+###############################################################################
39+# OpenLP - Open Source Lyrics Projection #
40+# --------------------------------------------------------------------------- #
41+# Copyright (c) 2008-2014 Raoul Snyman #
42+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
43+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
44+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
45+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
46+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
47+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
48+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
49+# --------------------------------------------------------------------------- #
50+# This program is free software; you can redistribute it and/or modify it #
51+# under the terms of the GNU General Public License as published by the Free #
52+# Software Foundation; version 2 of the License. #
53+# #
54+# This program is distributed in the hope that it will be useful, but WITHOUT #
55+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
56+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
57+# more details. #
58+# #
59+# You should have received a copy of the GNU General Public License along #
60+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
61+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
62+###############################################################################
63+"""
64+This module contains tests for the ZionWorx song importer.
65+"""
66+
67+from unittest import TestCase
68+
69+from tests.functional import MagicMock, patch
70+from openlp.plugins.songs.lib.zionworximport import ZionWorxImport
71+from openlp.plugins.songs.lib.songimport import SongImport
72+
73+
74+class TestZionWorxImport(TestCase):
75+ """
76+ Test the functions in the :mod:`zionworximport` module.
77+ """
78+ def create_importer_test(self):
79+ """
80+ Test creating an instance of the ZionWorx file importer
81+ """
82+ # GIVEN: A mocked out SongImport class, and a mocked out "manager"
83+ with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
84+ mocked_manager = MagicMock()
85+
86+ # WHEN: An importer object is created
87+ importer = ZionWorxImport(mocked_manager, filenames=[])
88+
89+ # THEN: The importer should be an instance of SongImport
90+ self.assertIsInstance(importer, SongImport)