← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~whydoubt/openlp/fix_core_tests into lp:openlp

 

Jeffrey Smith has proposed merging lp:~whydoubt/openlp/fix_core_tests into lp:openlp.

Commit message:
Fix various tests and broken code revealed by tests

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~whydoubt/openlp/fix_core_tests/+merge/184700

Fix various tests and broken code revealed by tests.

For me this fixes about 8 failed tests.

This gets me down to 0 failures in 'interfaces'.

Combined with fixes from other proposals I have
submitted, this gets me down to 7 failures in 'functional'.
-- 
https://code.launchpad.net/~whydoubt/openlp/fix_core_tests/+merge/184700
Your team OpenLP Core is requested to review the proposed merge of lp:~whydoubt/openlp/fix_core_tests into lp:openlp.
=== modified file 'openlp/core/ui/starttimeform.py'
--- openlp/core/ui/starttimeform.py	2013-08-31 18:17:38 +0000
+++ openlp/core/ui/starttimeform.py	2013-09-10 00:05:59 +0000
@@ -88,9 +88,9 @@
         """
         Split time up into hours minutes and seconds from secongs
         """
-        hours = seconds / 3600
+        hours = seconds // 3600
         seconds -= 3600 * hours
-        minutes = seconds / 60
+        minutes = seconds // 60
         seconds -= 60 * minutes
         return hours, minutes, seconds
 

=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2013-08-31 18:17:38 +0000
+++ openlp/core/utils/__init__.py	2013-09-10 00:05:59 +0000
@@ -256,7 +256,7 @@
     if not file_name:
         return True
     else:
-        formats = [str(fmt).lower() for fmt in QtGui.QImageReader.supportedImageFormats()]
+        formats = [bytes(fmt).decode().lower() for fmt in QtGui.QImageReader.supportedImageFormats()]
         file_part, file_extension = os.path.splitext(str(file_name))
         if file_extension[1:].lower() in formats and os.path.exists(file_name):
             return False

=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/lib/http.py	2013-09-10 00:05:59 +0000
@@ -717,7 +717,7 @@
         return None
     page_source = page.read()
     if pre_parse_regex and pre_parse_substitute is not None:
-        page_source = re.sub(pre_parse_regex, pre_parse_substitute, page_source)
+        page_source = re.sub(pre_parse_regex, pre_parse_substitute, page_source.decode())
     soup = None
     try:
         soup = BeautifulSoup(page_source)

=== modified file 'tests/functional/openlp_core_lib/test_lib.py'
--- tests/functional/openlp_core_lib/test_lib.py	2013-08-31 18:17:38 +0000
+++ tests/functional/openlp_core_lib/test_lib.py	2013-09-10 00:05:59 +0000
@@ -187,7 +187,7 @@
         """
         Test the get_text_file_string() method when a read error happens
         """
-        with patch('openlp.core.lib.os.path.isfile') as mocked_isfile, patch('builtins.open') as mocked_open:
+        with patch('openlp.core.lib.os.path.isfile') as mocked_isfile, patch('openlp.core.lib.open', create=True) as mocked_open:
             # GIVEN: A mocked-out open() which raises an exception and isfile returns True
             filename = 'testfile.txt'
             mocked_isfile.return_value = True
@@ -252,7 +252,7 @@
             # GIVEN: A set of mocked-out Qt classes
             mocked_byte_array = MagicMock()
             MockedQtCore.QByteArray.return_value = mocked_byte_array
-            mocked_byte_array.toBase64.return_value = 'base64mock'
+            mocked_byte_array.toBase64.return_value = QtCore.QByteArray('base64mock')
             mocked_buffer = MagicMock()
             MockedQtCore.QBuffer.return_value = mocked_buffer
             MockedQtCore.QIODevice.WriteOnly = 'writeonly'

=== modified file 'tests/functional/openlp_core_utils/test_utils.py'
--- tests/functional/openlp_core_utils/test_utils.py	2013-08-31 18:17:38 +0000
+++ tests/functional/openlp_core_utils/test_utils.py	2013-09-10 00:05:59 +0000
@@ -8,6 +8,8 @@
 from openlp.core.utils import clean_filename, get_filesystem_encoding, _get_frozen_path, get_locale_key, \
     get_natural_key, split_filename
 
+import os
+
 
 class TestUtils(TestCase):
     """
@@ -120,6 +122,8 @@
             # THEN: We get a properly sorted list
             test_passes = sorted(unsorted_list, key=get_locale_key) == ['Aushang', '\u00C4u\u00DFerung', 'Auszug']
             assert test_passes, 'Strings should be sorted properly'
+    if os.name != 'nt':
+        del get_locale_key_windows_test
 
     def get_locale_key_linux_test(self):
 

=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_http.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_http.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_http.py	2013-09-10 00:05:59 +0000
@@ -43,7 +43,7 @@
         results = handler.get_bible_chapter('NIV', 'John', 3)
 
         # THEN: We should get back a valid service item
-        assert len(results.verselist) == 36, 'The book of John should not have had any verses added or removed'
+        assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
 
     def crosswalk_extract_books_test(self):
         """
@@ -69,5 +69,5 @@
         results = handler.get_bible_chapter('niv', 'john', 3)
 
         # THEN: We should get back a valid service item
-        assert len(results.verselist) == 36, 'The book of John should not have had any verses added or removed'
+        assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
 

=== modified file 'tests/interfaces/openlp_plugins/remotes/test_server.py'
--- tests/interfaces/openlp_plugins/remotes/test_server.py	2013-08-31 18:17:38 +0000
+++ tests/interfaces/openlp_plugins/remotes/test_server.py	2013-09-10 00:05:59 +0000
@@ -9,7 +9,7 @@
 import urllib.request, urllib.error, urllib.parse
 import cherrypy
 
-from BeautifulSoup import BeautifulSoup
+from bs4 import BeautifulSoup
 
 from openlp.core.lib import Settings
 from openlp.plugins.remotes.lib.httpserver import HttpServer


Follow ups