Another attempt to fix projector test across platforms and versions

This commit is contained in:
Tomas Groth 2014-11-28 10:53:39 +00:00
parent 612041dafa
commit 6af0aef8bd
2 changed files with 10 additions and 4 deletions

View File

@ -85,8 +85,11 @@ class TestProjectorDB(TestCase):
Set up anything necessary for all tests
"""
if not hasattr(self, 'projector'):
with patch('openlp.core.lib.db.init_url') as mocked_init_url:
mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
# 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()
def find_record_by_ip_test(self):

View File

@ -57,8 +57,11 @@ class TestProjectorManager(TestCase, TestMixin):
self.setup_application()
Registry.create()
if not hasattr(self, 'projector_manager'):
with patch('openlp.core.lib.db.init_url') as mocked_init_url:
mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
# 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)