← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/wine-test-fixes into lp:openlp

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/wine-test-fixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/wine-test-fixes/+merge/246642

Fixes for wine and pep8 test.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/wine-test-fixes into lp:openlp.
=== modified file 'openlp/core/lib/db.py'
--- openlp/core/lib/db.py	2014-12-31 10:58:13 +0000
+++ openlp/core/lib/db.py	2015-01-15 20:37:48 +0000
@@ -156,7 +156,10 @@
     except (SQLAlchemyError, DBAPIError):
         version_meta = Metadata.populate(key='version', value=int(upgrade.__version__))
         session.commit()
-    return int(version_meta.value), upgrade.__version__
+    upgrade_version = upgrade.__version__
+    version_meta = int(version_meta.value)
+    session.close()
+    return version_meta, upgrade_version
 
 
 def delete_database(plugin_name, db_file_name=None):

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2015-01-02 11:58:44 +0000
+++ openlp/core/ui/slidecontroller.py	2015-01-15 20:37:48 +0000
@@ -125,7 +125,6 @@
             alignment = QtCore.Qt.AlignLeft
         painter.drawText(self.rect(), alignment, elided)
 
-
     def setText(self, text):
         """
         Reimplemented to set the tool tip text.

=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2015-01-09 15:38:10 +0000
+++ openlp/core/utils/__init__.py	2015-01-15 20:37:48 +0000
@@ -429,7 +429,7 @@
     """
     for command in ['libreoffice', 'soffice']:
         if which(command):
-             break
+            break
     else:
         raise FileNotFoundError('Command not found')
 

=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
--- tests/functional/openlp_core_ui/test_slidecontroller.py	2015-01-11 19:46:41 +0000
+++ tests/functional/openlp_core_ui/test_slidecontroller.py	2015-01-15 20:37:48 +0000
@@ -560,6 +560,7 @@
         mocked_preview_widget.change_slide.assert_called_once_with(7)
         mocked_slide_selected.assert_called_once_with()
 
+
 class TestInfoLabel(TestCase):
 
     def paint_event_text_fits_test(self):
@@ -570,7 +571,7 @@
         metrics = QtGui.QFontMetrics(font)
 
         with patch('openlp.core.ui.slidecontroller.QtGui.QLabel'), \
-            patch('openlp.core.ui.slidecontroller.QtGui.QPainter') as mocked_qpainter:
+                patch('openlp.core.ui.slidecontroller.QtGui.QPainter') as mocked_qpainter:
 
             # GIVEN: An instance of InfoLabel, with mocked text return, width and rect methods
             info_label = InfoLabel()
@@ -598,7 +599,7 @@
         metrics = QtGui.QFontMetrics(font)
 
         with patch('openlp.core.ui.slidecontroller.QtGui.QLabel'), \
-            patch('openlp.core.ui.slidecontroller.QtGui.QPainter') as mocked_qpainter:
+                patch('openlp.core.ui.slidecontroller.QtGui.QPainter') as mocked_qpainter:
 
             # GIVEN: An instance of InfoLabel, with mocked text return, width and rect methods
             info_label = InfoLabel()

=== modified file 'tests/functional/openlp_core_ui/test_themeform.py'
--- tests/functional/openlp_core_ui/test_themeform.py	2015-01-11 15:18:17 +0000
+++ tests/functional/openlp_core_ui/test_themeform.py	2015-01-15 20:37:48 +0000
@@ -48,13 +48,12 @@
         # GIVEN: An instance of Theme Form and mocked QFileDialog which returns an empty string (similating a user
         #       pressing cancel)
         with patch('openlp.core.ui.ThemeForm._setup'),\
-            patch('openlp.core.ui.themeform.get_images_filter',
-                  **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\
-            patch('openlp.core.ui.themeform.QtGui.QFileDialog.getOpenFileName',
-                  **{'return_value': ''}) as mocked_get_open_file_name,\
-            patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\
-            patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_set_background_page_values:
-
+                patch('openlp.core.ui.themeform.get_images_filter',
+                      **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\
+                patch('openlp.core.ui.themeform.QtGui.QFileDialog.getOpenFileName',
+                      **{'return_value': ''}) as mocked_get_open_file_name,\
+                patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\
+                patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_set_background_page_values:
             instance = ThemeForm(None)
             mocked_image_file_edit = MagicMock()
             mocked_image_file_edit.text.return_value = '/original_path/file.ext'
@@ -66,8 +65,8 @@
             # THEN: The QFileDialog getOpenFileName and set_background_page_values moethods should have been called
             #       with known arguments
             mocked_get_open_file_name.assert_called_once_with(instance, 'Translated String', '/original_path/file.ext',
-                                                              'Image Files (*.bmp; *.gif)(*.bmp *.gif);;All Files (*.*)'
-            )
+                                                              'Image Files (*.bmp; *.gif)(*.bmp *.gif);;'
+                                                              'All Files (*.*)')
             mocked_set_background_page_values.assert_called_once_with()
 
     def select_image_file_dialog_new_file_test(self):
@@ -76,13 +75,12 @@
         """
         # GIVEN: An instance of Theme Form and mocked QFileDialog which returns a file path
         with patch('openlp.core.ui.ThemeForm._setup'),\
-            patch('openlp.core.ui.themeform.get_images_filter',
-                  **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\
-            patch('openlp.core.ui.themeform.QtGui.QFileDialog.getOpenFileName',
-                  **{'return_value': '/new_path/file.ext'}) as mocked_get_open_file_name,\
-            patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\
-            patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_background_page_values:
-
+                patch('openlp.core.ui.themeform.get_images_filter',
+                      **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\
+                patch('openlp.core.ui.themeform.QtGui.QFileDialog.getOpenFileName',
+                      **{'return_value': '/new_path/file.ext'}) as mocked_get_open_file_name,\
+                patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\
+                patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_background_page_values:
             instance = ThemeForm(None)
             mocked_image_file_edit = MagicMock()
             mocked_image_file_edit.text.return_value = '/original_path/file.ext'
@@ -95,8 +93,8 @@
             # THEN: The QFileDialog getOpenFileName and set_background_page_values moethods should have been called
             #       with known arguments and theme.background_filename should be set
             mocked_get_open_file_name.assert_called_once_with(instance, 'Translated String', '/original_path/file.ext',
-                                                              'Image Files (*.bmp; *.gif)(*.bmp *.gif);;All Files (*.*)'
-            )
+                                                              'Image Files (*.bmp; *.gif)(*.bmp *.gif);;'
+                                                              'All Files (*.*)')
             self.assertEqual(instance.theme.background_filename, '/new_path/file.ext',
                              'theme.background_filename should be set to the path that the file dialog returns')
             mocked_background_page_values.assert_called_once_with()

=== modified file 'tests/functional/openlp_core_utils/test_init.py'
--- tests/functional/openlp_core_utils/test_init.py	2015-01-02 11:40:51 +0000
+++ tests/functional/openlp_core_utils/test_init.py	2015-01-15 20:37:48 +0000
@@ -83,7 +83,7 @@
 
             # THEN: The command 'libreoffice' should be called with the appropriate parameters
             self.assertEquals(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
-                                       ' "--accept=pipe,name=openlp_pipe;urp;"')
+                                      ' "--accept=pipe,name=openlp_pipe;urp;"')
 
     def get_uno_command_only_soffice_command_exists_test(self):
         """
@@ -101,7 +101,7 @@
 
             # THEN: The command 'soffice' should be called with the appropriate parameters
             self.assertEquals(result, 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
-                                       ' "--accept=pipe,name=openlp_pipe;urp;"')
+                                      ' "--accept=pipe,name=openlp_pipe;urp;"')
 
     def get_uno_command_when_no_command_exists_test(self):
         """

=== modified file 'tests/functional/openlp_plugins/custom/test_mediaitem.py'
--- tests/functional/openlp_plugins/custom/test_mediaitem.py	2014-12-18 21:15:14 +0000
+++ tests/functional/openlp_plugins/custom/test_mediaitem.py	2015-01-15 20:37:48 +0000
@@ -98,4 +98,4 @@
 
             # THEN: the item should not be added to the database.
             self.assertEqual(self.media_item.create_from_service_item.call_count, 1,
-                             'The item should have been added to the database')
\ No newline at end of file
+                             'The item should have been added to the database')

=== modified file 'tests/interfaces/openlp_core_ui/test_projectoreditform.py'
--- tests/interfaces/openlp_core_ui/test_projectoreditform.py	2015-01-07 00:36:39 +0000
+++ tests/interfaces/openlp_core_ui/test_projectoreditform.py	2015-01-15 20:37:48 +0000
@@ -31,8 +31,6 @@
 class and methods.
 """
 
-import os
-import tempfile
 from unittest import TestCase
 
 from openlp.core.common import Registry, Settings
@@ -43,8 +41,6 @@
 from tests.helpers.testmixin import TestMixin
 from tests.resources.projector.data import TEST1_DATA, TEST2_DATA
 
-tmpfile = tempfile.mkstemp(prefix='openlp-test-projectormanager', suffix='.sql')[1]
-
 
 class TestProjectorEditForm(TestCase, TestMixin):
     """
@@ -60,8 +56,7 @@
         self.setup_application()
         Registry.create()
         with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
-            mocked_init_url.start()
-            mocked_init_url.return_value = 'sqlite:///{}'.format(tmpfile)
+            mocked_init_url.return_value = 'sqlite://'
             self.projectordb = ProjectorDB()
             self.projector_form = ProjectorEditForm(projectordb=self.projectordb)
 
@@ -74,7 +69,6 @@
         """
         self.projectordb.session.close()
         del(self.projector_form)
-        os.remove(tmpfile)
         self.destroy_settings()
 
     def edit_form_add_projector_test(self):


Follow ups