Merge lp:~raoul-snyman/openlp/fix-tests into lp:openlp

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 2589
Proposed branch: lp:~raoul-snyman/openlp/fix-tests
Merge into: lp:openlp
Diff against target: 642 lines (+129/-176)
11 files modified
openlp/core/lib/db.py (+16/-14)
openlp/core/lib/projector/db.py (+18/-18)
tests/functional/openlp_core_lib/__init__.py (+0/-23)
tests/functional/openlp_core_lib/test_projectordb.py (+38/-36)
tests/functional/openlp_core_ui/test_maindisplay.py (+5/-5)
tests/interfaces/openlp_core_ui/__init__.py (+0/-32)
tests/interfaces/openlp_core_ui/test_projectoreditform.py (+9/-5)
tests/interfaces/openlp_core_ui/test_projectormanager.py (+8/-10)
tests/interfaces/openlp_core_ui/test_projectorsourceform.py (+11/-9)
tests/interfaces/openlp_plugins/bibles/test_lib_http.py (+1/-1)
tests/resources/projector/data.py (+23/-23)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/fix-tests
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Tomas Groth Approve
Review via email: mp+281936@code.launchpad.net

Description of the change

Fix tests. Sadly Windows tests are still broken.

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/fix-tests (revision 2596)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1215/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1141/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1080/
[FAILURE] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/920/

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) :
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
=== modified file 'openlp/core/lib/db.py'
--- openlp/core/lib/db.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/db.py 2016-01-07 22:31:35 +0000
@@ -55,7 +55,7 @@
55 metadata = MetaData(bind=engine)55 metadata = MetaData(bind=engine)
56 else:56 else:
57 base.metadata.bind = engine57 base.metadata.bind = engine
58 metadata = None58 metadata = base.metadata
59 session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine))59 session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine))
60 return session, metadata60 return session, metadata
6161
@@ -227,13 +227,12 @@
227 """227 """
228 self.is_dirty = False228 self.is_dirty = False
229 self.session = None229 self.session = None
230 # See if we're using declarative_base with a pre-existing session.230 self.db_url = None
231 log.debug('Manager: Testing for pre-existing session')231 if db_file_name:
232 if session is not None:232 log.debug('Manager: Creating new DB url')
233 log.debug('Manager: Using existing session')
234 else:
235 log.debug('Manager: Creating new session')
236 self.db_url = init_url(plugin_name, db_file_name)233 self.db_url = init_url(plugin_name, db_file_name)
234 else:
235 self.db_url = init_url(plugin_name)
237 if upgrade_mod:236 if upgrade_mod:
238 try:237 try:
239 db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod)238 db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod)
@@ -248,10 +247,13 @@
248 'not be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url)247 'not be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url)
249 )248 )
250 return249 return
251 try:250 if not session:
252 self.session = init_schema(self.db_url)251 try:
253 except (SQLAlchemyError, DBAPIError):252 self.session = init_schema(self.db_url)
254 handle_db_error(plugin_name, db_file_name)253 except (SQLAlchemyError, DBAPIError):
254 handle_db_error(plugin_name, db_file_name)
255 else:
256 self.session = session
255257
256 def save_object(self, object_instance, commit=True):258 def save_object(self, object_instance, commit=True):
257 """259 """
@@ -344,13 +346,13 @@
344 for try_count in range(3):346 for try_count in range(3):
345 try:347 try:
346 return self.session.query(object_class).filter(filter_clause).first()348 return self.session.query(object_class).filter(filter_clause).first()
347 except OperationalError:349 except OperationalError as oe:
348 # This exception clause is for users running MySQL which likes to terminate connections on its own350 # This exception clause is for users running MySQL which likes to terminate connections on its own
349 # without telling anyone. See bug #927473. However, other dbms can raise it, usually in a351 # without telling anyone. See bug #927473. However, other dbms can raise it, usually in a
350 # non-recoverable way. So we only retry 3 times.352 # non-recoverable way. So we only retry 3 times.
353 if try_count >= 2 or 'MySQL has gone away' in str(oe):
354 raise
351 log.exception('Probably a MySQL issue, "MySQL has gone away"')355 log.exception('Probably a MySQL issue, "MySQL has gone away"')
352 if try_count >= 2:
353 raise
354356
355 def get_all_objects(self, object_class, filter_clause=None, order_by_ref=None):357 def get_all_objects(self, object_class, filter_clause=None, order_by_ref=None):
356 """358 """
357359
=== modified file 'openlp/core/lib/projector/db.py'
--- openlp/core/lib/projector/db.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/projector/db.py 2016-01-07 22:31:35 +0000
@@ -20,18 +20,18 @@
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################21###############################################################################
22"""22"""
23 :mod:`openlp.core.lib.projector.db` module23:mod:`openlp.core.lib.projector.db` module
2424
25 Provides the database functions for the Projector module.25Provides the database functions for the Projector module.
2626
27 The Manufacturer, Model, Source tables keep track of the video source27The Manufacturer, Model, Source tables keep track of the video source
28 strings used for display of input sources. The Source table maps28strings used for display of input sources. The Source table maps
29 manufacturer-defined or user-defined strings from PJLink default strings29manufacturer-defined or user-defined strings from PJLink default strings
30 to end-user readable strings; ex: PJLink code 11 would map "RGB 1"30to end-user readable strings; ex: PJLink code 11 would map "RGB 1"
31 default string to "RGB PC (analog)" string.31default string to "RGB PC (analog)" string.
32 (Future feature).32(Future feature).
3333
34 The Projector table keeps track of entries for controlled projectors.34The Projector table keeps track of entries for controlled projectors.
35"""35"""
3636
37import logging37import logging
@@ -218,19 +218,19 @@
218 """218 """
219 def __init__(self, *args, **kwargs):219 def __init__(self, *args, **kwargs):
220 log.debug('ProjectorDB().__init__(args="%s", kwargs="%s")' % (args, kwargs))220 log.debug('ProjectorDB().__init__(args="%s", kwargs="%s")' % (args, kwargs))
221 super().__init__(plugin_name='projector',221 super().__init__(plugin_name='projector', init_schema=self.init_schema)
222 init_schema=self.init_schema)
223 log.debug('ProjectorDB() Initialized using db url %s' % self.db_url)222 log.debug('ProjectorDB() Initialized using db url %s' % self.db_url)
223 log.debug('Session: %s', self.session)
224224
225 def init_schema(*args, **kwargs):225 def init_schema(self, *args, **kwargs):
226 """226 """
227 Setup the projector database and initialize the schema.227 Setup the projector database and initialize the schema.
228228
229 Declarative uses table classes to define schema.229 Declarative uses table classes to define schema.
230 """230 """
231 url = init_url('projector')231 self.db_url = init_url('projector')
232 session, metadata = init_db(url, base=Base)232 session, metadata = init_db(self.db_url, base=Base)
233 Base.metadata.create_all(checkfirst=True)233 metadata.create_all(checkfirst=True)
234 return session234 return session
235235
236 def get_projector_by_id(self, dbid):236 def get_projector_by_id(self, dbid):
237237
=== modified file 'tests/functional/openlp_core_lib/__init__.py'
--- tests/functional/openlp_core_lib/__init__.py 2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_core_lib/__init__.py 2016-01-07 22:31:35 +0000
@@ -22,26 +22,3 @@
22"""22"""
23Module-level functions for the functional test suite23Module-level functions for the functional test suite
24"""24"""
25
26import os
27from tests.functional import patch
28
29from openlp.core.common import is_win
30
31from .test_projectordb import tmpfile
32
33
34def setUp():
35 if not is_win():
36 # Wine creates a sharing violation during tests. Ignore.
37 try:
38 os.remove(tmpfile)
39 except:
40 pass
41
42
43def tearDown():
44 """
45 Ensure test suite has been cleaned up after tests
46 """
47 patch.stopall()
4825
=== modified file 'tests/functional/openlp_core_lib/test_projectordb.py'
--- tests/functional/openlp_core_lib/test_projectordb.py 2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_core_lib/test_projectordb.py 2016-01-07 22:31:35 +0000
@@ -25,15 +25,13 @@
2525
26PREREQUISITE: add_record() and get_all() functions validated.26PREREQUISITE: add_record() and get_all() functions validated.
27"""27"""
2828import os
29from unittest import TestCase29from unittest import TestCase
30
31from openlp.core.lib.projector.db import Projector, ProjectorDB, ProjectorSource
32
30from tests.functional import MagicMock, patch33from tests.functional import MagicMock, patch
3134from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA
32from openlp.core.lib.projector.db import Projector, ProjectorDB, ProjectorSource
33
34from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA
35
36tmpfile = '/tmp/openlp-test-projectordb.sql'
3735
3836
39def compare_data(one, two):37def compare_data(one, two):
@@ -60,15 +58,15 @@
60 one.text == two.text58 one.text == two.text
6159
6260
63def add_records(self, test):61def add_records(projector_db, test):
64 """62 """
65 Add record if not in database63 Add record if not in database
66 """64 """
67 record_list = self.projector.get_projector_all()65 record_list = projector_db.get_projector_all()
68 if len(record_list) < 1:66 if len(record_list) < 1:
69 added = False67 added = False
70 for record in test:68 for record in test:
71 added = self.projector.add_projector(record) or added69 added = projector_db.add_projector(record) or added
72 return added70 return added
7371
74 for new_record in test:72 for new_record in test:
@@ -76,7 +74,7 @@
76 for record in record_list:74 for record in record_list:
77 if compare_data(record, new_record):75 if compare_data(record, new_record):
78 break76 break
79 added = self.projector.add_projector(new_record)77 added = projector_db.add_projector(new_record)
80 return added78 return added
8179
8280
@@ -88,15 +86,17 @@
88 """86 """
89 Set up anything necessary for all tests87 Set up anything necessary for all tests
90 """88 """
91 if not hasattr(self, 'projector'):89 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
92 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:90 if os.path.exists(TEST_DB):
93 mocked_init_url.return_value = 'sqlite:///%s' % tmpfile91 os.unlink(TEST_DB)
94 self.projector = ProjectorDB()92 mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
93 self.projector = ProjectorDB()
9594
96 def tearDown(self):95 def tearDown(self):
97 """96 """
98 Clean up97 Clean up
99 """98 """
99 self.projector.session.close()
100 self.projector = None100 self.projector = None
101101
102 def find_record_by_ip_test(self):102 def find_record_by_ip_test(self):
@@ -104,13 +104,13 @@
104 Test find record by IP104 Test find record by IP
105 """105 """
106 # GIVEN: Record entries in database106 # GIVEN: Record entries in database
107 add_records(self, [TEST1_DATA, TEST2_DATA])107 add_records(self.projector, [Projector(**TEST1_DATA), Projector(**TEST2_DATA)])
108108
109 # WHEN: Search for record using IP109 # WHEN: Search for record using IP
110 record = self.projector.get_projector_by_ip(TEST2_DATA.ip)110 record = self.projector.get_projector_by_ip(TEST2_DATA['ip'])
111111
112 # THEN: Verify proper record returned112 # THEN: Verify proper record returned
113 self.assertTrue(compare_data(TEST2_DATA, record),113 self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
114 'Record found should have been test_2 data')114 'Record found should have been test_2 data')
115115
116 def find_record_by_name_test(self):116 def find_record_by_name_test(self):
@@ -118,13 +118,13 @@
118 Test find record by name118 Test find record by name
119 """119 """
120 # GIVEN: Record entries in database120 # GIVEN: Record entries in database
121 add_records(self, [TEST1_DATA, TEST2_DATA])121 add_records(self.projector, [Projector(**TEST1_DATA), Projector(**TEST2_DATA)])
122122
123 # WHEN: Search for record using name123 # WHEN: Search for record using name
124 record = self.projector.get_projector_by_name(TEST2_DATA.name)124 record = self.projector.get_projector_by_name(TEST2_DATA['name'])
125125
126 # THEN: Verify proper record returned126 # THEN: Verify proper record returned
127 self.assertTrue(compare_data(TEST2_DATA, record),127 self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
128 'Record found should have been test_2 data')128 'Record found should have been test_2 data')
129129
130 def record_delete_test(self):130 def record_delete_test(self):
@@ -132,14 +132,14 @@
132 Test record can be deleted132 Test record can be deleted
133 """133 """
134 # GIVEN: Record in database134 # GIVEN: Record in database
135 add_records(self, [TEST3_DATA, ])135 add_records(self.projector, [Projector(**TEST3_DATA), ])
136 record = self.projector.get_projector_by_ip(TEST3_DATA.ip)136 record = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
137137
138 # WHEN: Record deleted138 # WHEN: Record deleted
139 self.projector.delete_projector(record)139 self.projector.delete_projector(record)
140140
141 # THEN: Verify record not retrievable141 # THEN: Verify record not retrievable
142 found = self.projector.get_projector_by_ip(TEST3_DATA.ip)142 found = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
143 self.assertFalse(found, 'test_3 record should have been deleted')143 self.assertFalse(found, 'test_3 record should have been deleted')
144144
145 def record_edit_test(self):145 def record_edit_test(self):
@@ -147,34 +147,35 @@
147 Test edited record returns the same record ID with different data147 Test edited record returns the same record ID with different data
148 """148 """
149 # GIVEN: Record entries in database149 # GIVEN: Record entries in database
150 add_records(self, [TEST1_DATA, TEST2_DATA])150 add_records(self.projector, [Projector(**TEST1_DATA), Projector(**TEST2_DATA)])
151151
152 # WHEN: We retrieve a specific record152 # WHEN: We retrieve a specific record
153 record = self.projector.get_projector_by_ip(TEST1_DATA.ip)153 record = self.projector.get_projector_by_ip(TEST1_DATA['ip'])
154 record_id = record.id154 record_id = record.id
155155
156 # WHEN: Data is changed156 # WHEN: Data is changed
157 record.ip = TEST3_DATA.ip157 record.ip = TEST3_DATA['ip']
158 record.port = TEST3_DATA.port158 record.port = TEST3_DATA['port']
159 record.pin = TEST3_DATA.pin159 record.pin = TEST3_DATA['pin']
160 record.name = TEST3_DATA.name160 record.name = TEST3_DATA['name']
161 record.location = TEST3_DATA.location161 record.location = TEST3_DATA['location']
162 record.notes = TEST3_DATA.notes162 record.notes = TEST3_DATA['notes']
163 updated = self.projector.update_projector(record)163 updated = self.projector.update_projector(record)
164 self.assertTrue(updated, 'Save updated record should have returned True')164 self.assertTrue(updated, 'Save updated record should have returned True')
165 record = self.projector.get_projector_by_ip(TEST3_DATA.ip)165 record = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
166166
167 # THEN: Record ID should remain the same, but data should be changed167 # THEN: Record ID should remain the same, but data should be changed
168 self.assertEqual(record_id, record.id, 'Edited record should have the same ID')168 self.assertEqual(record_id, record.id, 'Edited record should have the same ID')
169 self.assertTrue(compare_data(TEST3_DATA, record), 'Edited record should have new data')169 self.assertTrue(compare_data(Projector(**TEST3_DATA), record), 'Edited record should have new data')
170170
171 def source_add_test(self):171 def source_add_test(self):
172 """172 """
173 Test source entry for projector item173 Test source entry for projector item
174 """174 """
175 # GIVEN: Record entries in database175 # GIVEN: Record entries in database
176 self.projector.add_projector(TEST1_DATA)176 projector1 = Projector(**TEST1_DATA)
177 item = self.projector.get_projector_by_id(TEST1_DATA.id)177 self.projector.add_projector(projector1)
178 item = self.projector.get_projector_by_id(projector1.id)
178 item_id = item.id179 item_id = item.id
179180
180 # WHEN: A source entry is saved for item181 # WHEN: A source entry is saved for item
@@ -184,3 +185,4 @@
184 # THEN: Projector should have the same source entry185 # THEN: Projector should have the same source entry
185 item = self.projector.get_projector_by_id(item_id)186 item = self.projector.get_projector_by_id(item_id)
186 self.assertTrue(compare_source(item.source_list[0], source))187 self.assertTrue(compare_source(item.source_list[0], source))
188
187189
=== modified file 'tests/functional/openlp_core_ui/test_maindisplay.py'
--- tests/functional/openlp_core_ui/test_maindisplay.py 2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_core_ui/test_maindisplay.py 2016-01-07 22:31:35 +0000
@@ -22,7 +22,7 @@
22"""22"""
23Package to test the openlp.core.ui.slidecontroller package.23Package to test the openlp.core.ui.slidecontroller package.
24"""24"""
25from unittest import TestCase25from unittest import TestCase, skipUnless
2626
27from PyQt5 import QtCore27from PyQt5 import QtCore
2828
@@ -141,13 +141,14 @@
141 mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame)141 mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame)
142 mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)142 mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)
143143
144 @patch('openlp.core.ui.maindisplay.is_macosx')144 @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
145 def macosx_display_window_flags_state_test(self, is_macosx):145 def macosx_display_window_flags_state_test(self, is_macosx):
146 """146 """
147 Test that on Mac OS X we set the proper window flags147 Test that on Mac OS X we set the proper window flags
148 """148 """
149 if not is_macosx():
150 self.skipTest('Can only run test on Mac OS X due to pyobjc dependency.')
149 # GIVEN: A new SlideController instance on Mac OS X.151 # GIVEN: A new SlideController instance on Mac OS X.
150 is_macosx.return_value = True
151 self.screens.set_current_display(0)152 self.screens.set_current_display(0)
152 display = MagicMock()153 display = MagicMock()
153154
@@ -159,12 +160,11 @@
159 main_display.windowFlags(),160 main_display.windowFlags(),
160 'The window flags should be Qt.Window, and Qt.FramelessWindowHint.')161 'The window flags should be Qt.Window, and Qt.FramelessWindowHint.')
161162
163 @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
162 def macosx_display_test(self):164 def macosx_display_test(self):
163 """165 """
164 Test display on Mac OS X166 Test display on Mac OS X
165 """167 """
166 if not is_macosx():
167 self.skipTest('Can only run test on Mac OS X due to pyobjc dependency.')
168 # GIVEN: A new SlideController instance on Mac OS X.168 # GIVEN: A new SlideController instance on Mac OS X.
169 self.screens.set_current_display(0)169 self.screens.set_current_display(0)
170 display = MagicMock()170 display = MagicMock()
171171
=== modified file 'tests/interfaces/openlp_core_ui/__init__.py'
--- tests/interfaces/openlp_core_ui/__init__.py 2015-12-31 22:46:06 +0000
+++ tests/interfaces/openlp_core_ui/__init__.py 2016-01-07 22:31:35 +0000
@@ -22,35 +22,3 @@
22"""22"""
23Module-level functions for the functional test suite23Module-level functions for the functional test suite
24"""24"""
25
26import os
27
28from openlp.core.common import is_win
29
30from tests.interfaces import patch
31from .test_projectormanager import tmpfile
32
33
34def setUp():
35 """
36 Set up this module of tests
37 """
38 if not is_win():
39 # Wine creates a sharing violation during tests. Ignore.
40 try:
41 os.remove(tmpfile)
42 except:
43 pass
44
45
46def tearDown():
47 """
48 Ensure test suite has been cleaned up after tests
49 """
50 patch.stopall()
51 if not is_win():
52 try:
53 # In case of changed schema, remove old test file
54 os.remove(tmpfile)
55 except FileNotFoundError:
56 pass
5725
=== modified file 'tests/interfaces/openlp_core_ui/test_projectoreditform.py'
--- tests/interfaces/openlp_core_ui/test_projectoreditform.py 2015-12-31 22:46:06 +0000
+++ tests/interfaces/openlp_core_ui/test_projectoreditform.py 2016-01-07 22:31:35 +0000
@@ -23,7 +23,7 @@
23Interface tests to test the openlp.core.ui.projector.editform.ProjectorEditForm()23Interface tests to test the openlp.core.ui.projector.editform.ProjectorEditForm()
24class and methods.24class and methods.
25"""25"""
2626import os
27from unittest import TestCase27from unittest import TestCase
2828
29from openlp.core.common import Registry, Settings29from openlp.core.common import Registry, Settings
@@ -32,7 +32,7 @@
3232
33from tests.functional import patch33from tests.functional import patch
34from tests.helpers.testmixin import TestMixin34from tests.helpers.testmixin import TestMixin
35from tests.resources.projector.data import TEST1_DATA, TEST2_DATA35from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA
3636
3737
38class TestProjectorEditForm(TestCase, TestMixin):38class TestProjectorEditForm(TestCase, TestMixin):
@@ -49,7 +49,9 @@
49 self.setup_application()49 self.setup_application()
50 Registry.create()50 Registry.create()
51 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:51 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
52 mocked_init_url.return_value = 'sqlite://'52 if os.path.exists(TEST_DB):
53 os.unlink(TEST_DB)
54 mocked_init_url.return_value = 'sqlite:///' + TEST_DB
53 self.projectordb = ProjectorDB()55 self.projectordb = ProjectorDB()
54 self.projector_form = ProjectorEditForm(projectordb=self.projectordb)56 self.projector_form = ProjectorEditForm(projectordb=self.projectordb)
5557
@@ -93,11 +95,13 @@
93 with patch('openlp.core.ui.projector.editform.QDialog.exec'):95 with patch('openlp.core.ui.projector.editform.QDialog.exec'):
9496
95 # WHEN: Calling edit form with existing projector instance97 # WHEN: Calling edit form with existing projector instance
96 self.projector_form.exec(projector=TEST1_DATA)98 self.projector_form.exec(projector=Projector(**TEST1_DATA))
97 item = self.projector_form.projector99 item = self.projector_form.projector
98100
99 # THEN: Should be editing an existing entry101 # THEN: Should be editing an existing entry
100 self.assertFalse(self.projector_form.new_projector,102 self.assertFalse(self.projector_form.new_projector,
101 'Projector edit form should be marked as existing entry')103 'Projector edit form should be marked as existing entry')
102 self.assertTrue((item.ip is TEST1_DATA.ip and item.name is TEST1_DATA.name),104 self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']),
103 'Projector edit form should have TEST1_DATA() instance to edit')105 'Projector edit form should have TEST1_DATA() instance to edit')
106
107
104108
=== modified file 'tests/interfaces/openlp_core_ui/test_projectormanager.py'
--- tests/interfaces/openlp_core_ui/test_projectormanager.py 2015-12-31 22:46:06 +0000
+++ tests/interfaces/openlp_core_ui/test_projectormanager.py 2016-01-07 22:31:35 +0000
@@ -22,7 +22,6 @@
22"""22"""
23Interface tests to test the themeManager class and related methods.23Interface tests to test the themeManager class and related methods.
24"""24"""
25
26import os25import os
27from unittest import TestCase26from unittest import TestCase
2827
@@ -33,9 +32,7 @@
33from openlp.core.ui import ProjectorManager, ProjectorEditForm32from openlp.core.ui import ProjectorManager, ProjectorEditForm
34from openlp.core.lib.projector.db import Projector, ProjectorDB33from openlp.core.lib.projector.db import Projector, ProjectorDB
3534
36from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA35from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA
37
38tmpfile = '/tmp/openlp-test-projectormanager.sql'
3936
4037
41class TestProjectorManager(TestCase, TestMixin):38class TestProjectorManager(TestCase, TestMixin):
@@ -49,12 +46,13 @@
49 self.build_settings()46 self.build_settings()
50 self.setup_application()47 self.setup_application()
51 Registry.create()48 Registry.create()
52 if not hasattr(self, 'projector_manager'):49 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
53 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:50 if os.path.exists(TEST_DB):
54 mocked_init_url.return_value = 'sqlite:///%s' % tmpfile51 os.unlink(TEST_DB)
55 self.projectordb = ProjectorDB()52 mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
56 if not hasattr(self, 'projector_manager'):53 self.projectordb = ProjectorDB()
57 self.projector_manager = ProjectorManager(projectordb=self.projectordb)54 if not hasattr(self, 'projector_manager'):
55 self.projector_manager = ProjectorManager(projectordb=self.projectordb)
5856
59 def tearDown(self):57 def tearDown(self):
60 """58 """
6159
=== modified file 'tests/interfaces/openlp_core_ui/test_projectorsourceform.py'
--- tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2015-12-31 22:46:06 +0000
+++ tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2016-01-07 22:31:35 +0000
@@ -20,24 +20,24 @@
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################21###############################################################################
22"""22"""
23 :mod: `tests.interfaces.openlp_core_ui.test_projectorsourceform` module23:mod: `tests.interfaces.openlp_core_ui.test_projectorsourceform` module
2424
25 Tests for the Projector Source Select form.25Tests for the Projector Source Select form.
26"""26"""
27import logging27import logging
28log = logging.getLogger(__name__)28log = logging.getLogger(__name__)
29log.debug('test_projectorsourceform loaded')29log.debug('test_projectorsourceform loaded')
3030import os
31from unittest import TestCase31from unittest import TestCase
32
32from PyQt5.QtWidgets import QDialog33from PyQt5.QtWidgets import QDialog
3334
34from tests.functional import patch35from tests.functional import patch
35from tests.functional.openlp_core_lib.test_projectordb import tmpfile
36from tests.helpers.testmixin import TestMixin36from tests.helpers.testmixin import TestMixin
37from tests.resources.projector.data import TEST_DB, TEST1_DATA37from tests.resources.projector.data import TEST_DB, TEST1_DATA
3838
39from openlp.core.common import Registry, Settings39from openlp.core.common import Registry, Settings
40from openlp.core.lib.projector.db import ProjectorDB40from openlp.core.lib.projector.db import ProjectorDB, Projector
41from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES41from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
42from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle42from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
4343
@@ -65,7 +65,9 @@
65 """65 """
66 Set up anything necessary for all tests66 Set up anything necessary for all tests
67 """67 """
68 mocked_init_url.return_value = 'sqlite:///{}'.format(tmpfile)68 if os.path.exists(TEST_DB):
69 os.unlink(TEST_DB)
70 mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB)
69 self.build_settings()71 self.build_settings()
70 self.setup_application()72 self.setup_application()
71 Registry.create()73 Registry.create()
@@ -73,10 +75,10 @@
73 if not hasattr(self, 'projectordb'):75 if not hasattr(self, 'projectordb'):
74 self.projectordb = ProjectorDB()76 self.projectordb = ProjectorDB()
75 # Retrieve/create a database record77 # Retrieve/create a database record
76 self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA.ip)78 self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA['ip'])
77 if not self.projector:79 if not self.projector:
78 self.projectordb.add_projector(projector=TEST1_DATA)80 self.projectordb.add_projector(projector=Projector(**TEST1_DATA))
79 self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA.ip)81 self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA['ip'])
80 self.projector.dbid = self.projector.id82 self.projector.dbid = self.projector.id
81 self.projector.db_item = self.projector83 self.projector.db_item = self.projector
8284
8385
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_http.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_http.py 2015-12-31 22:46:06 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_http.py 2016-01-07 22:31:35 +0000
@@ -130,7 +130,7 @@
130 # THEN: The list should not be None, and some known bibles should be there130 # THEN: The list should not be None, and some known bibles should be there
131 self.assertIsNotNone(bibles)131 self.assertIsNotNone(bibles)
132 self.assertIn(('New Int. Readers Version', 'NIRV', 'en'), bibles)132 self.assertIn(('New Int. Readers Version', 'NIRV', 'en'), bibles)
133 self.assertIn(('Българската Библия', 'BLG', 'bg'), bibles)133 self.assertIn(('Священное Писание, Восточный перевод', 'CARS', 'ru'), bibles)
134134
135 def biblegateway_get_bibles_test(self):135 def biblegateway_get_bibles_test(self):
136 """136 """
137137
=== modified file 'tests/resources/projector/data.py'
--- tests/resources/projector/data.py 2015-12-31 22:46:06 +0000
+++ tests/resources/projector/data.py 2016-01-07 22:31:35 +0000
@@ -24,28 +24,28 @@
24"""24"""
2525
26import os26import os
27from openlp.core.lib.projector.db import Projector27from tempfile import gettempdir
2828
29# Test data29# Test data
30TEST_DB = os.path.join('tmp', 'openlp-test-projectordb.sql')30TEST_DB = os.path.join(gettempdir(), 'openlp-test-projectordb.sql')
3131
32TEST1_DATA = Projector(ip='111.111.111.111',32TEST1_DATA = dict(ip='111.111.111.111',
33 port='1111',33 port='1111',
34 pin='1111',34 pin='1111',
35 name='___TEST_ONE___',35 name='___TEST_ONE___',
36 location='location one',36 location='location one',
37 notes='notes one')37 notes='notes one')
3838
39TEST2_DATA = Projector(ip='222.222.222.222',39TEST2_DATA = dict(ip='222.222.222.222',
40 port='2222',40 port='2222',
41 pin='2222',41 pin='2222',
42 name='___TEST_TWO___',42 name='___TEST_TWO___',
43 location='location two',43 location='location two',
44 notes='notes two')44 notes='notes two')
4545
46TEST3_DATA = Projector(ip='333.333.333.333',46TEST3_DATA = dict(ip='333.333.333.333',
47 port='3333',47 port='3333',
48 pin='3333',48 pin='3333',
49 name='___TEST_THREE___',49 name='___TEST_THREE___',
50 location='location three',50 location='location three',
51 notes='notes three')51 notes='notes three')