Fix various tests and broken code revealed by tests.

bzr-revno: 2296
This commit is contained in:
Jeffrey Smith 2013-09-13 17:11:27 +02:00 committed by Andreas Preikschat
commit 1ef5d00d45
6 changed files with 9 additions and 9 deletions

View File

@ -88,9 +88,9 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
""" """
Split time up into hours minutes and seconds from secongs Split time up into hours minutes and seconds from secongs
""" """
hours = seconds / 3600 hours = seconds // 3600
seconds -= 3600 * hours seconds -= 3600 * hours
minutes = seconds / 60 minutes = seconds // 60
seconds -= 60 * minutes seconds -= 60 * minutes
return hours, minutes, seconds return hours, minutes, seconds

View File

@ -256,7 +256,7 @@ def is_not_image_file(file_name):
if not file_name: if not file_name:
return True return True
else: 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)) file_part, file_extension = os.path.splitext(str(file_name))
if file_extension[1:].lower() in formats and os.path.exists(file_name): if file_extension[1:].lower() in formats and os.path.exists(file_name):
return False return False

View File

@ -717,7 +717,7 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre
return None return None
page_source = page.read() page_source = page.read()
if pre_parse_regex and pre_parse_substitute is not None: 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 soup = None
try: try:
soup = BeautifulSoup(page_source) soup = BeautifulSoup(page_source)

View File

@ -187,7 +187,7 @@ class TestLib(TestCase):
""" """
Test the get_text_file_string() method when a read error happens 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 # GIVEN: A mocked-out open() which raises an exception and isfile returns True
filename = 'testfile.txt' filename = 'testfile.txt'
mocked_isfile.return_value = True mocked_isfile.return_value = True
@ -252,7 +252,7 @@ class TestLib(TestCase):
# GIVEN: A set of mocked-out Qt classes # GIVEN: A set of mocked-out Qt classes
mocked_byte_array = MagicMock() mocked_byte_array = MagicMock()
MockedQtCore.QByteArray.return_value = mocked_byte_array 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() mocked_buffer = MagicMock()
MockedQtCore.QBuffer.return_value = mocked_buffer MockedQtCore.QBuffer.return_value = mocked_buffer
MockedQtCore.QIODevice.WriteOnly = 'writeonly' MockedQtCore.QIODevice.WriteOnly = 'writeonly'

View File

@ -43,7 +43,7 @@ class TestBibleHTTP(TestCase):
results = handler.get_bible_chapter('NIV', 'John', 3) results = handler.get_bible_chapter('NIV', 'John', 3)
# THEN: We should get back a valid service item # 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): def crosswalk_extract_books_test(self):
""" """
@ -69,5 +69,5 @@ class TestBibleHTTP(TestCase):
results = handler.get_bible_chapter('niv', 'john', 3) results = handler.get_bible_chapter('niv', 'john', 3)
# THEN: We should get back a valid service item # 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'

View File

@ -9,7 +9,7 @@ from mock import MagicMock
import urllib.request, urllib.error, urllib.parse import urllib.request, urllib.error, urllib.parse
import cherrypy import cherrypy
from BeautifulSoup import BeautifulSoup from bs4 import BeautifulSoup
from openlp.core.lib import Settings from openlp.core.lib import Settings
from openlp.plugins.remotes.lib.httpserver import HttpServer from openlp.plugins.remotes.lib.httpserver import HttpServer