Another projector test fix attempt

This commit is contained in:
Tomas Groth 2014-12-01 08:22:17 +00:00
parent 6af0aef8bd
commit 7d2f2d147c
2 changed files with 20 additions and 15 deletions

View File

@ -32,7 +32,7 @@ record functions.
PREREQUISITE: add_record() and get_all() functions validated.
"""
import sys
from unittest import TestCase
from tests.functional import MagicMock, patch
@ -85,12 +85,14 @@ class TestProjectorDB(TestCase):
Set up anything necessary for all tests
"""
if not hasattr(self, 'projector'):
# We need to patch this twice to make it work across multiple platforms and versions.
with patch('openlp.core.lib.db.init_url') as mocked_init_url1, \
patch('openlp.core.lib.projector.db.init_url') as mocked_init_url2:
mocked_init_url1.return_value = 'sqlite:///%s' % tmpfile
mocked_init_url2.return_value = 'sqlite:///%s' % tmpfile
self.projector = ProjectorDB()
# We need to patch this in different ways to make to work an all versions
if sys.version_info > (3, 4, 0):
mocked_init_url = patch('openlp.core.lib.db.init_url')
else:
mocked_init_url = patch('openlp.core.lib.projector.db.init_url')
mocked_init_url.start()
mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
self.projector = ProjectorDB()
def find_record_by_ip_test(self):
"""

View File

@ -31,6 +31,7 @@ Interface tests to test the themeManager class and related methods.
"""
import os
import sys
from unittest import TestCase
from openlp.core.common import Registry, Settings
@ -57,14 +58,16 @@ class TestProjectorManager(TestCase, TestMixin):
self.setup_application()
Registry.create()
if not hasattr(self, 'projector_manager'):
# We need to patch this twice to make it work across multiple platforms and versions.
with patch('openlp.core.lib.db.init_url') as mocked_init_url1, \
patch('openlp.core.lib.projector.db.init_url') as mocked_init_url2:
mocked_init_url1.return_value = 'sqlite:///%s' % tmpfile
mocked_init_url2.return_value = 'sqlite:///%s' % tmpfile
self.projectordb = ProjectorDB()
if not hasattr(self, 'projector_manager'):
self.projector_manager = ProjectorManager(projectordb=self.projectordb)
# We need to patch this in different ways to make to work an all versions
if sys.version_info > (3, 4, 0):
mocked_init_url = patch('openlp.core.lib.db.init_url')
else:
mocked_init_url = patch('openlp.core.lib.projector.db.init_url')
mocked_init_url.start()
mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
self.projectordb = ProjectorDB()
if not hasattr(self, 'projector_manager'):
self.projector_manager = ProjectorManager(projectordb=self.projectordb)
def tearDown(self):
"""