forked from openlp/openlp
test fixes
This commit is contained in:
parent
3e7370c656
commit
c38c576f94
@ -28,15 +28,15 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The :mod:`http` module contains the API web server. This is a lightweight web
|
The :mod:`http` module contains the API web server. This is a lightweight web server used by remotes to interact
|
||||||
server used by remotes to interact with OpenLP. It uses JSON to communicate with
|
with OpenLP. It uses JSON to communicate with the remotes.
|
||||||
the remotes.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ssl
|
import ssl
|
||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
@ -53,8 +53,8 @@ log = logging.getLogger(__name__)
|
|||||||
class CustomHandler(BaseHTTPRequestHandler, HttpRouter):
|
class CustomHandler(BaseHTTPRequestHandler, HttpRouter):
|
||||||
"""
|
"""
|
||||||
Stateless session handler to handle the HTTP request and process it.
|
Stateless session handler to handle the HTTP request and process it.
|
||||||
This class handles just the overrides to the base methods and the logic to invoke the
|
This class handles just the overrides to the base methods and the logic to invoke the methods within the HttpRouter
|
||||||
methods within the HttpRouter class.
|
class.
|
||||||
DO not try change the structure as this is as per the documentation.
|
DO not try change the structure as this is as per the documentation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -116,9 +116,20 @@ class OpenLPServer():
|
|||||||
log.debug('Started ssl httpd...')
|
log.debug('Started ssl httpd...')
|
||||||
else:
|
else:
|
||||||
port = Settings().value(self.settings_section + '/port')
|
port = Settings().value(self.settings_section + '/port')
|
||||||
|
loop = 1
|
||||||
|
while loop < 3:
|
||||||
|
try:
|
||||||
self.httpd = ThreadingHTTPServer((address, port), CustomHandler)
|
self.httpd = ThreadingHTTPServer((address, port), CustomHandler)
|
||||||
|
except OSError:
|
||||||
|
loop += 1
|
||||||
|
time.sleep(0.1)
|
||||||
|
except:
|
||||||
|
log.error('Failed to start server ')
|
||||||
log.debug('Started non ssl httpd...')
|
log.debug('Started non ssl httpd...')
|
||||||
|
if hasattr(self, 'httpd') and self.httpd:
|
||||||
self.httpd.serve_forever()
|
self.httpd.serve_forever()
|
||||||
|
else:
|
||||||
|
log.debug('Failed to start server')
|
||||||
|
|
||||||
def stop_server(self):
|
def stop_server(self):
|
||||||
"""
|
"""
|
||||||
|
@ -32,4 +32,3 @@ The :mod:`resources` module contains a bunch of resources for OpenLP.
|
|||||||
DO NOT REMOVE THIS FILE, IT IS REQUIRED FOR INCLUDING THE RESOURCES ON SOME
|
DO NOT REMOVE THIS FILE, IT IS REQUIRED FOR INCLUDING THE RESOURCES ON SOME
|
||||||
PLATFORMS!
|
PLATFORMS!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -52,7 +52,9 @@ This is done easily via the ``-d``, ``-p`` and ``-u`` options::
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import urllib.request, urllib.error, urllib.parse
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
@ -70,6 +72,7 @@ quiet_mode = False
|
|||||||
username = ''
|
username = ''
|
||||||
password = ''
|
password = ''
|
||||||
|
|
||||||
|
|
||||||
class Command(object):
|
class Command(object):
|
||||||
"""
|
"""
|
||||||
Provide an enumeration of commands.
|
Provide an enumeration of commands.
|
||||||
@ -80,6 +83,7 @@ class Command(object):
|
|||||||
Update = 4
|
Update = 4
|
||||||
Generate = 5
|
Generate = 5
|
||||||
|
|
||||||
|
|
||||||
class CommandStack(object):
|
class CommandStack(object):
|
||||||
"""
|
"""
|
||||||
This class provides an iterable stack.
|
This class provides an iterable stack.
|
||||||
@ -134,13 +138,13 @@ class CommandStack(object):
|
|||||||
results.append(str((item['command'], )))
|
results.append(str((item['command'], )))
|
||||||
return '[%s]' % ', '.join(results)
|
return '[%s]' % ', '.join(results)
|
||||||
|
|
||||||
|
|
||||||
def print_quiet(text, linefeed=True):
|
def print_quiet(text, linefeed=True):
|
||||||
"""
|
"""
|
||||||
This method checks to see if we are in quiet mode, and if not prints
|
This method checks to see if we are in quiet mode, and if not prints ``text`` out.
|
||||||
``text`` out.
|
|
||||||
|
|
||||||
``text``
|
:param text: The text to print.
|
||||||
The text to print.
|
:param linefeed: Linefeed required
|
||||||
"""
|
"""
|
||||||
global quiet_mode
|
global quiet_mode
|
||||||
if not quiet_mode:
|
if not quiet_mode:
|
||||||
@ -149,33 +153,33 @@ def print_quiet(text, linefeed=True):
|
|||||||
else:
|
else:
|
||||||
print(text, end=' ')
|
print(text, end=' ')
|
||||||
|
|
||||||
|
|
||||||
def print_verbose(text):
|
def print_verbose(text):
|
||||||
"""
|
"""
|
||||||
This method checks to see if we are in verbose mode, and if so prints
|
This method checks to see if we are in verbose mode, and if so prints ``text`` out.
|
||||||
``text`` out.
|
|
||||||
|
|
||||||
``text``
|
:param text: The text to print.
|
||||||
The text to print.
|
|
||||||
"""
|
"""
|
||||||
global verbose_mode, quiet_mode
|
global verbose_mode, quiet_mode
|
||||||
if not quiet_mode and verbose_mode:
|
if not quiet_mode and verbose_mode:
|
||||||
print(' %s' % text)
|
print(' %s' % text)
|
||||||
|
|
||||||
|
|
||||||
def run(command):
|
def run(command):
|
||||||
"""
|
"""
|
||||||
This method runs an external application.
|
This method runs an external application.
|
||||||
|
|
||||||
``command``
|
:param command: The command to run.
|
||||||
The command to run.
|
|
||||||
"""
|
"""
|
||||||
print_verbose(command)
|
print_verbose(command)
|
||||||
process = QtCore.QProcess()
|
process = QtCore.QProcess()
|
||||||
process.start(command)
|
process.start(command)
|
||||||
while (process.waitForReadyRead()):
|
while process.waitForReadyRead():
|
||||||
print_verbose('ReadyRead: %s' % QtCore.QString(process.readAll()))
|
print_verbose('ReadyRead: %s' % QtCore.QString(process.readAll()))
|
||||||
print_verbose('Error(s):\n%s' % process.readAllStandardError())
|
print_verbose('Error(s):\n%s' % process.readAllStandardError())
|
||||||
print_verbose('Output:\n%s' % process.readAllStandardOutput())
|
print_verbose('Output:\n%s' % process.readAllStandardOutput())
|
||||||
|
|
||||||
|
|
||||||
def download_translations():
|
def download_translations():
|
||||||
"""
|
"""
|
||||||
This method downloads the translation files from the Pootle server.
|
This method downloads the translation files from the Pootle server.
|
||||||
@ -190,8 +194,7 @@ def download_translations():
|
|||||||
password = getpass(' Transifex password: ')
|
password = getpass(' Transifex password: ')
|
||||||
# First get the list of languages
|
# First get the list of languages
|
||||||
url = SERVER_URL + 'resource/ents/'
|
url = SERVER_URL + 'resource/ents/'
|
||||||
base64string = base64.encodestring(
|
base64string = base64.encodbytes('%s:%s' % (username, password))[:-1]
|
||||||
'%s:%s' % (username, password))[:-1]
|
|
||||||
auth_header = 'Basic %s' % base64string
|
auth_header = 'Basic %s' % base64string
|
||||||
request = urllib.request.Request(url + '?details')
|
request = urllib.request.Request(url + '?details')
|
||||||
request.add_header('Authorization', auth_header)
|
request.add_header('Authorization', auth_header)
|
||||||
@ -207,8 +210,7 @@ def download_translations():
|
|||||||
lang_url = url + 'translation/%s/?file' % language
|
lang_url = url + 'translation/%s/?file' % language
|
||||||
request = urllib.request.Request(lang_url)
|
request = urllib.request.Request(lang_url)
|
||||||
request.add_header('Authorization', auth_header)
|
request.add_header('Authorization', auth_header)
|
||||||
filename = os.path.join(os.path.abspath('..'), 'resources', 'i18n',
|
filename = os.path.join(os.path.abspath('..'), 'resources', 'i18n', language + '.ts')
|
||||||
language + '.ts')
|
|
||||||
print_verbose('Get Translation File: %s' % filename)
|
print_verbose('Get Translation File: %s' % filename)
|
||||||
response = urllib.request.urlopen(request)
|
response = urllib.request.urlopen(request)
|
||||||
fd = open(filename, 'w')
|
fd = open(filename, 'w')
|
||||||
@ -217,10 +219,10 @@ def download_translations():
|
|||||||
print_quiet(' Done.')
|
print_quiet(' Done.')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def prepare_project():
|
def prepare_project():
|
||||||
"""
|
"""
|
||||||
This method creates the project file needed to update the translation files
|
This method creates the project file needed to update the translation files and compile them into .qm files.
|
||||||
and compile them into .qm files.
|
|
||||||
"""
|
"""
|
||||||
print_quiet('Generating the openlp.pro file')
|
print_quiet('Generating the openlp.pro file')
|
||||||
lines = []
|
lines = []
|
||||||
@ -229,7 +231,7 @@ def prepare_project():
|
|||||||
print_verbose('Starting directory: %s' % start_dir)
|
print_verbose('Starting directory: %s' % start_dir)
|
||||||
for root, dirs, files in os.walk(start_dir):
|
for root, dirs, files in os.walk(start_dir):
|
||||||
for file in files:
|
for file in files:
|
||||||
path = root.replace(start_dir, '').replace('\\', '/') #.replace(u'..', u'.')
|
path = root.replace(start_dir, '').replace('\\', '/')
|
||||||
if file.startswith('hook-') or file.startswith('test_'):
|
if file.startswith('hook-') or file.startswith('test_'):
|
||||||
continue
|
continue
|
||||||
ignore = False
|
ignore = False
|
||||||
@ -263,6 +265,7 @@ def prepare_project():
|
|||||||
file.close()
|
file.close()
|
||||||
print_quiet(' Done.')
|
print_quiet(' Done.')
|
||||||
|
|
||||||
|
|
||||||
def update_translations():
|
def update_translations():
|
||||||
print_quiet('Update the translation files')
|
print_quiet('Update the translation files')
|
||||||
if not os.path.exists(os.path.join(os.path.abspath('..'), 'openlp.pro')):
|
if not os.path.exists(os.path.join(os.path.abspath('..'), 'openlp.pro')):
|
||||||
@ -273,6 +276,7 @@ def update_translations():
|
|||||||
run('pylupdate4 -verbose -noobsolete openlp.pro')
|
run('pylupdate4 -verbose -noobsolete openlp.pro')
|
||||||
os.chdir(os.path.abspath('scripts'))
|
os.chdir(os.path.abspath('scripts'))
|
||||||
|
|
||||||
|
|
||||||
def generate_binaries():
|
def generate_binaries():
|
||||||
print_quiet('Generate the related *.qm files')
|
print_quiet('Generate the related *.qm files')
|
||||||
if not os.path.exists(os.path.join(os.path.abspath('..'), 'openlp.pro')):
|
if not os.path.exists(os.path.join(os.path.abspath('..'), 'openlp.pro')):
|
||||||
@ -290,12 +294,11 @@ def create_translation():
|
|||||||
This method opens a browser to the OpenLP project page at Transifex so
|
This method opens a browser to the OpenLP project page at Transifex so
|
||||||
that the user can request a new language.
|
that the user can request a new language.
|
||||||
"""
|
"""
|
||||||
print_quiet('Please request a new language at the OpenLP project on '
|
print_quiet('Please request a new language at the OpenLP project on Transifex.')
|
||||||
'Transifex.')
|
webbrowser.open('https://www.transifex.net/projects/p/openlp/resource/ents/')
|
||||||
webbrowser.open('https://www.transifex.net/projects/p/openlp/'
|
|
||||||
'resource/ents/')
|
|
||||||
print_quiet('Opening browser to OpenLP project...')
|
print_quiet('Opening browser to OpenLP project...')
|
||||||
|
|
||||||
|
|
||||||
def process_stack(command_stack):
|
def process_stack(command_stack):
|
||||||
"""
|
"""
|
||||||
This method looks at the commands in the command stack, and processes them
|
This method looks at the commands in the command stack, and processes them
|
||||||
@ -323,6 +326,7 @@ def process_stack(command_stack):
|
|||||||
else:
|
else:
|
||||||
print_quiet('No commands to process.')
|
print_quiet('No commands to process.')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global verbose_mode, quiet_mode, username, password
|
global verbose_mode, quiet_mode, username, password
|
||||||
# Set up command line options.
|
# Set up command line options.
|
||||||
|
4
setup.py
4
setup.py
@ -123,7 +123,9 @@ setup(
|
|||||||
version=version_string,
|
version=version_string,
|
||||||
description="Open source Church presentation and lyrics projection application.",
|
description="Open source Church presentation and lyrics projection application.",
|
||||||
long_description="""\
|
long_description="""\
|
||||||
OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship using a computer and a data projector.""",
|
OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display
|
||||||
|
slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship
|
||||||
|
using a computer and a data projector.""",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'Environment :: MacOS X',
|
'Environment :: MacOS X',
|
||||||
|
@ -54,9 +54,9 @@ class TestAppLocation(TestCase):
|
|||||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
||||||
mocked_settings = mocked_class.return_value
|
mocked_settings = mocked_class.return_value
|
||||||
mocked_settings.contains.return_value = False
|
mocked_settings.contains.return_value = False
|
||||||
mocked_get_directory.return_value = os.path.join('test','dir')
|
mocked_get_directory.return_value = os.path.join('test', 'dir')
|
||||||
mocked_check_directory_exists.return_value = True
|
mocked_check_directory_exists.return_value = True
|
||||||
mocked_os.path.normpath.return_value = os.path.join('test','dir')
|
mocked_os.path.normpath.return_value = os.path.join('test', 'dir')
|
||||||
|
|
||||||
# WHEN: we call AppLocation.get_data_path()
|
# WHEN: we call AppLocation.get_data_path()
|
||||||
data_path = AppLocation.get_data_path()
|
data_path = AppLocation.get_data_path()
|
||||||
@ -64,8 +64,8 @@ class TestAppLocation(TestCase):
|
|||||||
# THEN: check that all the correct methods were called, and the result is correct
|
# THEN: check that all the correct methods were called, and the result is correct
|
||||||
mocked_settings.contains.assert_called_with('advanced/data path')
|
mocked_settings.contains.assert_called_with('advanced/data path')
|
||||||
mocked_get_directory.assert_called_with(AppLocation.DataDir)
|
mocked_get_directory.assert_called_with(AppLocation.DataDir)
|
||||||
mocked_check_directory_exists.assert_called_with(os.path.join('test','dir'))
|
mocked_check_directory_exists.assert_called_with(os.path.join('test', 'dir'))
|
||||||
self.assertEqual(os.path.join('test','dir'), data_path, 'Result should be "test/dir"')
|
self.assertEqual(os.path.join('test', 'dir'), data_path, 'Result should be "test/dir"')
|
||||||
|
|
||||||
def get_data_path_with_custom_location_test(self):
|
def get_data_path_with_custom_location_test(self):
|
||||||
"""
|
"""
|
||||||
@ -110,14 +110,14 @@ class TestAppLocation(TestCase):
|
|||||||
with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
|
with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
|
||||||
patch('openlp.core.common.applocation.os.listdir') as mocked_listdir:
|
patch('openlp.core.common.applocation.os.listdir') as mocked_listdir:
|
||||||
# GIVEN: Our mocked modules/methods.
|
# GIVEN: Our mocked modules/methods.
|
||||||
mocked_get_data_path.return_value = os.path.join('test','dir')
|
mocked_get_data_path.return_value = os.path.join('test', 'dir')
|
||||||
mocked_listdir.return_value = copy.deepcopy(FILE_LIST)
|
mocked_listdir.return_value = copy.deepcopy(FILE_LIST)
|
||||||
|
|
||||||
# When: Get the list of files.
|
# When: Get the list of files.
|
||||||
result = AppLocation.get_files('section', '.mp3')
|
result = AppLocation.get_files('section', '.mp3')
|
||||||
|
|
||||||
# Then: Check if the section parameter was used correctly.
|
# Then: Check if the section parameter was used correctly.
|
||||||
mocked_listdir.assert_called_with(os.path.join('test','dir','section'))
|
mocked_listdir.assert_called_with(os.path.join('test', 'dir', 'section'))
|
||||||
|
|
||||||
# Then: check if the file lists are identical.
|
# Then: check if the file lists are identical.
|
||||||
self.assertListEqual(['file5.mp3', 'file6.mp3'], result, 'The file lists should be identical.')
|
self.assertListEqual(['file5.mp3', 'file6.mp3'], result, 'The file lists should be identical.')
|
||||||
@ -129,15 +129,15 @@ class TestAppLocation(TestCase):
|
|||||||
with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
|
with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
|
||||||
patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists:
|
patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists:
|
||||||
# GIVEN: A mocked out AppLocation.get_data_path()
|
# GIVEN: A mocked out AppLocation.get_data_path()
|
||||||
mocked_get_data_path.return_value = os.path.join('test','dir')
|
mocked_get_data_path.return_value = os.path.join('test', 'dir')
|
||||||
mocked_check_directory_exists.return_value = True
|
mocked_check_directory_exists.return_value = True
|
||||||
|
|
||||||
# WHEN: we call AppLocation.get_data_path()
|
# WHEN: we call AppLocation.get_data_path()
|
||||||
data_path = AppLocation.get_section_data_path('section')
|
data_path = AppLocation.get_section_data_path('section')
|
||||||
|
|
||||||
# THEN: check that all the correct methods were called, and the result is correct
|
# THEN: check that all the correct methods were called, and the result is correct
|
||||||
mocked_check_directory_exists.assert_called_with(os.path.join('test','dir','section'))
|
mocked_check_directory_exists.assert_called_with(os.path.join('test', 'dir', 'section'))
|
||||||
self.assertEqual(os.path.join('test','dir','section'), data_path, 'Result should be "test/dir/section"')
|
self.assertEqual(os.path.join('test', 'dir', 'section'), data_path, 'Result should be "test/dir/section"')
|
||||||
|
|
||||||
def get_directory_for_app_dir_test(self):
|
def get_directory_for_app_dir_test(self):
|
||||||
"""
|
"""
|
||||||
@ -145,13 +145,13 @@ class TestAppLocation(TestCase):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: A mocked out _get_frozen_path function
|
# GIVEN: A mocked out _get_frozen_path function
|
||||||
with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path:
|
with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path:
|
||||||
mocked_get_frozen_path.return_value = os.path.join('app','dir')
|
mocked_get_frozen_path.return_value = os.path.join('app', 'dir')
|
||||||
|
|
||||||
# WHEN: We call AppLocation.get_directory
|
# WHEN: We call AppLocation.get_directory
|
||||||
directory = AppLocation.get_directory(AppLocation.AppDir)
|
directory = AppLocation.get_directory(AppLocation.AppDir)
|
||||||
|
|
||||||
# THEN: check that the correct directory is returned
|
# THEN: check that the correct directory is returned
|
||||||
self.assertEqual(os.path.join('app','dir'), directory, 'Directory should be "app/dir"')
|
self.assertEqual(os.path.join('app', 'dir'), directory, 'Directory should be "app/dir"')
|
||||||
|
|
||||||
def get_directory_for_plugins_dir_test(self):
|
def get_directory_for_plugins_dir_test(self):
|
||||||
"""
|
"""
|
||||||
|
@ -42,7 +42,8 @@ class TestFileDialog(TestCase):
|
|||||||
# THEN: The returned value should be an empty QStringList and os.path.exists should not have been called
|
# THEN: The returned value should be an empty QStringList and os.path.exists should not have been called
|
||||||
assert not self.mocked_os.path.exists.called
|
assert not self.mocked_os.path.exists.called
|
||||||
self.assertEqual(result, [],
|
self.assertEqual(result, [],
|
||||||
'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames is canceled')
|
'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames '
|
||||||
|
'is canceled')
|
||||||
|
|
||||||
def returned_file_list_test(self):
|
def returned_file_list_test(self):
|
||||||
"""
|
"""
|
||||||
|
@ -108,4 +108,3 @@ class TestFormattingTags(TestCase):
|
|||||||
|
|
||||||
# THEN: The lists should now be identical.
|
# THEN: The lists should now be identical.
|
||||||
assert old_tags_list == FormattingTags.get_html_tags(), 'The lists should be identical.'
|
assert old_tags_list == FormattingTags.get_html_tags(), 'The lists should be identical.'
|
||||||
|
|
||||||
|
@ -321,4 +321,3 @@ class Htmbuilder(TestCase):
|
|||||||
|
|
||||||
# THEN: THE css should be the same.
|
# THEN: THE css should be the same.
|
||||||
assert FOOTER_CSS == css, 'The footer strings should be equal.'
|
assert FOOTER_CSS == css, 'The footer strings should be equal.'
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ class TestLib(TestCase):
|
|||||||
mocked_buffer.open.assert_called_with('writeonly')
|
mocked_buffer.open.assert_called_with('writeonly')
|
||||||
mocked_image.save.assert_called_with(mocked_buffer, "PNG")
|
mocked_image.save.assert_called_with(mocked_buffer, "PNG")
|
||||||
mocked_byte_array.toBase64.assert_called_with()
|
mocked_byte_array.toBase64.assert_called_with()
|
||||||
self.assertEqual('base64mock', result,
|
self.assertEqual('base64mock', result, 'The result should be the return value of the mocked out '
|
||||||
'The result should be the return value of the mocked out base64 method')
|
'base64 method')
|
||||||
|
|
||||||
def create_thumb_with_size_test(self):
|
def create_thumb_with_size_test(self):
|
||||||
"""
|
"""
|
||||||
|
@ -69,4 +69,3 @@ class TestTheme(TestCase):
|
|||||||
'The theme should have a font_footer_name of Arial')
|
'The theme should have a font_footer_name of Arial')
|
||||||
self.assertTrue(default_theme.font_main_bold is False, 'The theme should have a font_main_bold of false')
|
self.assertTrue(default_theme.font_main_bold is False, 'The theme should have a font_main_bold of false')
|
||||||
self.assertTrue(len(default_theme.__dict__) == 47, 'The theme should have 47 variables')
|
self.assertTrue(len(default_theme.__dict__) == 47, 'The theme should have 47 variables')
|
||||||
|
|
||||||
|
@ -26,4 +26,3 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ class TestBSExtract(TestCase):
|
|||||||
self.mock_get_soup_for_bible_ref.assert_called_once_with(
|
self.mock_get_soup_for_bible_ref.assert_called_once_with(
|
||||||
'http://m.bibleserver.com/overlay/selectBook?translation=NIV')
|
'http://m.bibleserver.com/overlay/selectBook?translation=NIV')
|
||||||
self.assertIsNone(result,
|
self.assertIsNone(result,
|
||||||
'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a false value')
|
'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a '
|
||||||
|
'false value')
|
||||||
|
|
||||||
def get_books_from_http_no_content_test(self):
|
def get_books_from_http_no_content_test(self):
|
||||||
"""
|
"""
|
||||||
@ -146,7 +147,8 @@ class TestBSExtract(TestCase):
|
|||||||
self.mock_log.error.assert_called_once_with('No books found in the Bibleserver response.')
|
self.mock_log.error.assert_called_once_with('No books found in the Bibleserver response.')
|
||||||
self.mock_send_error_message.assert_called_once_with('parse')
|
self.mock_send_error_message.assert_called_once_with('parse')
|
||||||
self.assertIsNone(result,
|
self.assertIsNone(result,
|
||||||
'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a false value')
|
'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a '
|
||||||
|
'false value')
|
||||||
|
|
||||||
def get_books_from_http_content_test(self):
|
def get_books_from_http_content_test(self):
|
||||||
"""
|
"""
|
||||||
|
@ -85,5 +85,3 @@ class TestLib(TestCase):
|
|||||||
|
|
||||||
# THEN: It should be False
|
# THEN: It should be False
|
||||||
self.assertFalse(has_verse_list, 'The SearchResults object should have a verse list')
|
self.assertFalse(has_verse_list, 'The SearchResults object should have a verse list')
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class TestImageMediaItem(TestCase):
|
|||||||
Test that the save_new_images_list() saves all images in the list
|
Test that the save_new_images_list() saves all images in the list
|
||||||
"""
|
"""
|
||||||
# GIVEN: A list with 3 images
|
# GIVEN: A list with 3 images
|
||||||
image_list = [ 'test_image_1.jpg', 'test_image_2.jpg', 'test_image_3.jpg' ]
|
image_list = ['test_image_1.jpg', 'test_image_2.jpg', 'test_image_3.jpg']
|
||||||
with patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') as mocked_load_full_list:
|
with patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') as mocked_load_full_list:
|
||||||
self.media_item.manager = MagicMock()
|
self.media_item.manager = MagicMock()
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class TestImageMediaItem(TestCase):
|
|||||||
Test that the save_new_images_list() ignores everything in the provided list except strings
|
Test that the save_new_images_list() ignores everything in the provided list except strings
|
||||||
"""
|
"""
|
||||||
# GIVEN: A list with images and objects
|
# GIVEN: A list with images and objects
|
||||||
image_list = [ 'test_image_1.jpg', None, True, ImageFilenames(), 'test_image_2.jpg' ]
|
image_list = ['test_image_1.jpg', None, True, ImageFilenames(), 'test_image_2.jpg']
|
||||||
with patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') as mocked_load_full_list:
|
with patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') as mocked_load_full_list:
|
||||||
self.media_item.manager = MagicMock()
|
self.media_item.manager = MagicMock()
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class TestImageMediaItem(TestCase):
|
|||||||
assert self.media_item.manager.delete_object.call_count == 7, \
|
assert self.media_item.manager.delete_object.call_count == 7, \
|
||||||
'manager.delete_object() should be called exactly 7 times'
|
'manager.delete_object() should be called exactly 7 times'
|
||||||
|
|
||||||
# CLEANUP: Remove added attribute from ImageFilenames and ImageGroups
|
# CLEANUP: Remove added attribute from Image Filenames and ImageGroups
|
||||||
delattr(ImageFilenames, 'group_id')
|
delattr(ImageFilenames, 'group_id')
|
||||||
delattr(ImageGroups, 'parent_id')
|
delattr(ImageGroups, 'parent_id')
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ class TestSongShowPlusImport(TestCase):
|
|||||||
|
|
||||||
# THEN: do_import should return none and the progress bar setMaximum should be called with the length of
|
# THEN: do_import should return none and the progress bar setMaximum should be called with the length of
|
||||||
# import_source.
|
# import_source.
|
||||||
self.assertIsNone(importer.do_import(),
|
self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is a list '
|
||||||
'do_import should return None when import_source is a list and stop_import_flag is True')
|
'and stop_import_flag is True')
|
||||||
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
|
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
|
||||||
|
|
||||||
def to_openlp_verse_tag_test(self):
|
def to_openlp_verse_tag_test(self):
|
||||||
@ -143,8 +143,8 @@ class TestSongShowPlusImport(TestCase):
|
|||||||
# THEN: The returned value should should correlate with the input arguments
|
# THEN: The returned value should should correlate with the input arguments
|
||||||
for original_tag, openlp_tag in test_values:
|
for original_tag, openlp_tag in test_values:
|
||||||
self.assertEquals(importer.to_openlp_verse_tag(original_tag), openlp_tag,
|
self.assertEquals(importer.to_openlp_verse_tag(original_tag), openlp_tag,
|
||||||
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"'
|
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
|
||||||
% (openlp_tag, original_tag))
|
(openlp_tag, original_tag))
|
||||||
|
|
||||||
def to_openlp_verse_tag_verse_order_test(self):
|
def to_openlp_verse_tag_verse_order_test(self):
|
||||||
"""
|
"""
|
||||||
@ -171,5 +171,5 @@ class TestSongShowPlusImport(TestCase):
|
|||||||
# THEN: The returned value should should correlate with the input arguments
|
# THEN: The returned value should should correlate with the input arguments
|
||||||
for original_tag, openlp_tag in test_values:
|
for original_tag, openlp_tag in test_values:
|
||||||
self.assertEquals(importer.to_openlp_verse_tag(original_tag, ignore_unique=True), openlp_tag,
|
self.assertEquals(importer.to_openlp_verse_tag(original_tag, ignore_unique=True), openlp_tag,
|
||||||
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"'
|
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
|
||||||
% (openlp_tag, original_tag))
|
(openlp_tag, original_tag))
|
||||||
|
@ -73,7 +73,8 @@ class WorshipCenterProImportLogger(WorshipCenterProImport):
|
|||||||
|
|
||||||
|
|
||||||
RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
|
RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
|
||||||
TestRecord(1, 'LYRICS',
|
TestRecord(
|
||||||
|
1, 'LYRICS',
|
||||||
'Amazing grace! How&crlf;sweet the sound&crlf;That saved a wretch like me!&crlf;'
|
'Amazing grace! How&crlf;sweet the sound&crlf;That saved a wretch like me!&crlf;'
|
||||||
'I once was lost,&crlf;but now am found;&crlf;Was blind, but now I see.&crlf;&crlf;'
|
'I once was lost,&crlf;but now am found;&crlf;Was blind, but now I see.&crlf;&crlf;'
|
||||||
'\'Twas grace that&crlf;taught my heart to fear,&crlf;And grace my fears relieved;&crlf;'
|
'\'Twas grace that&crlf;taught my heart to fear,&crlf;And grace my fears relieved;&crlf;'
|
||||||
@ -90,7 +91,8 @@ RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
|
|||||||
'Bright shining as the sun,&crlf;We\'ve no less days to&crlf;sing God\'s praise&crlf;'
|
'Bright shining as the sun,&crlf;We\'ve no less days to&crlf;sing God\'s praise&crlf;'
|
||||||
'Than when we\'d first begun.&crlf;&crlf;'),
|
'Than when we\'d first begun.&crlf;&crlf;'),
|
||||||
TestRecord(2, 'TITLE', 'Beautiful Garden Of Prayer, The'),
|
TestRecord(2, 'TITLE', 'Beautiful Garden Of Prayer, The'),
|
||||||
TestRecord(2, 'LYRICS',
|
TestRecord(
|
||||||
|
2, 'LYRICS',
|
||||||
'There\'s a garden where&crlf;Jesus is waiting,&crlf;'
|
'There\'s a garden where&crlf;Jesus is waiting,&crlf;'
|
||||||
'There\'s a place that&crlf;is wondrously fair,&crlf;For it glows with the&crlf;'
|
'There\'s a place that&crlf;is wondrously fair,&crlf;For it glows with the&crlf;'
|
||||||
'light of His presence.&crlf;\'Tis the beautiful&crlf;garden of prayer.&crlf;&crlf;'
|
'light of His presence.&crlf;\'Tis the beautiful&crlf;garden of prayer.&crlf;&crlf;'
|
||||||
@ -129,6 +131,7 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace',
|
|||||||
('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n'
|
('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n'
|
||||||
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
|
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
|
||||||
|
|
||||||
|
|
||||||
class TestWorshipCenterProSongImport(TestCase):
|
class TestWorshipCenterProSongImport(TestCase):
|
||||||
"""
|
"""
|
||||||
Test the functions in the :mod:`worshipcenterproimport` module.
|
Test the functions in the :mod:`worshipcenterproimport` module.
|
||||||
@ -171,7 +174,7 @@ class TestWorshipCenterProSongImport(TestCase):
|
|||||||
|
|
||||||
# THEN: do_import should return None, and pyodbc, translate & log_error are called with known calls
|
# THEN: do_import should return None, and pyodbc, translate & log_error are called with known calls
|
||||||
self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
|
self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
|
||||||
mocked_pyodbc_connect.assert_called_with( 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source')
|
mocked_pyodbc_connect.assert_called_with('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source')
|
||||||
mocked_translate.assert_called_with('SongsPlugin.WorshipCenterProImport',
|
mocked_translate.assert_called_with('SongsPlugin.WorshipCenterProImport',
|
||||||
'Unable to connect the WorshipCenter Pro database.')
|
'Unable to connect the WorshipCenter Pro database.')
|
||||||
mocked_log_error.assert_called_with('import_source', 'Translated Text')
|
mocked_log_error.assert_called_with('import_source', 'Translated Text')
|
||||||
@ -201,7 +204,6 @@ class TestWorshipCenterProSongImport(TestCase):
|
|||||||
# WHEN: Calling the do_import method
|
# WHEN: Calling the do_import method
|
||||||
return_value = importer.do_import()
|
return_value = importer.do_import()
|
||||||
|
|
||||||
|
|
||||||
# THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called with
|
# THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called with
|
||||||
# known calls
|
# known calls
|
||||||
self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
|
self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
|
||||||
|
@ -26,3 +26,4 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -48,4 +48,3 @@ def convert_file_service_item(test_path, name, row=0):
|
|||||||
finally:
|
finally:
|
||||||
open_file.close()
|
open_file.close()
|
||||||
return first_line
|
return first_line
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user