forked from openlp/openlp
Head
This commit is contained in:
commit
ca2ceba972
nose2.cfgpylintrc
openlp
core
common
lib
__init__.pydb.pyhtmlbuilder.pypluginmanager.py
projector
renderer.pyserviceitem.pytheme.pywebpagereader.pyui
plugins
tests/functional
openlp_core
openlp_core_common
test_actions.pytest_applocation.pytest_common.pytest_db.pytest_init.pytest_languagemanager.pytest_projector_utilities.pytest_registry.pytest_registrymixin.pytest_registryproperties.pytest_settings.pytest_uistrings.pytest_versionchecker.py
openlp_core_lib
test_db.pytest_file_dialog.pytest_formattingtags.pytest_htmlbuilder.pytest_image_manager.pytest_lib.pytest_mediamanageritem.pytest_pluginmanager.pytest_projector_pjlink1.pytest_projectordb.pytest_renderer.pytest_screen.pytest_serviceitem.pytest_theme.pytest_ui.pytest_webpagereader.py
openlp_core_ui
17
nose2.cfg
Normal file
17
nose2.cfg
Normal file
@ -0,0 +1,17 @@
|
||||
[unittest]
|
||||
verbose = True
|
||||
|
||||
[log-capture]
|
||||
always-on = True
|
||||
clear-handlers = True
|
||||
filter = -nose
|
||||
log-level = ERROR
|
||||
|
||||
[test-result]
|
||||
always-on = True
|
||||
descriptions = True
|
||||
|
||||
[coverage]
|
||||
always-on = False
|
||||
coverage = openlp
|
||||
coverage-report = html
|
@ -195,7 +195,7 @@ def verify_ip_address(addr):
|
||||
return True if verify_ipv4(addr) else verify_ipv6(addr)
|
||||
|
||||
|
||||
def md5_hash(salt, data=None):
|
||||
def md5_hash(salt=None, data=None):
|
||||
"""
|
||||
Returns the hashed output of md5sum on salt,data
|
||||
using Python3 hashlib
|
||||
@ -205,8 +205,11 @@ def md5_hash(salt, data=None):
|
||||
:returns: str
|
||||
"""
|
||||
log.debug('md5_hash(salt="{text}")'.format(text=salt))
|
||||
if not salt and not data:
|
||||
return None
|
||||
hash_obj = hashlib.new('md5')
|
||||
hash_obj.update(salt)
|
||||
if salt:
|
||||
hash_obj.update(salt)
|
||||
if data:
|
||||
hash_obj.update(data)
|
||||
hash_value = hash_obj.hexdigest()
|
||||
@ -214,22 +217,30 @@ def md5_hash(salt, data=None):
|
||||
return hash_value
|
||||
|
||||
|
||||
def qmd5_hash(salt, data=None):
|
||||
def qmd5_hash(salt=None, data=None):
|
||||
"""
|
||||
Returns the hashed output of MD5Sum on salt, data
|
||||
using PyQt5.QCryptographicHash.
|
||||
using PyQt5.QCryptographicHash. Function returns a
|
||||
QByteArray instead of a text string.
|
||||
If you need a string instead, call with
|
||||
|
||||
result = str(qmd5_hash(salt=..., data=...), encoding='ascii')
|
||||
|
||||
:param salt: Initial salt
|
||||
:param data: OPTIONAL Data to hash
|
||||
:returns: str
|
||||
:returns: QByteArray
|
||||
"""
|
||||
log.debug('qmd5_hash(salt="{text}"'.format(text=salt))
|
||||
if salt is None and data is None:
|
||||
return None
|
||||
hash_obj = QHash(QHash.Md5)
|
||||
hash_obj.addData(salt)
|
||||
hash_obj.addData(data)
|
||||
if salt:
|
||||
hash_obj.addData(salt)
|
||||
if data:
|
||||
hash_obj.addData(data)
|
||||
hash_value = hash_obj.result().toHex()
|
||||
log.debug('qmd5_hash() returning "{text}"'.format(text=hash_value))
|
||||
return hash_value.data()
|
||||
log.debug('qmd5_hash() returning "{hash}"'.format(hash=hash_value))
|
||||
return hash_value
|
||||
|
||||
|
||||
def clean_button_text(button_text):
|
||||
|
@ -138,7 +138,7 @@ class CategoryList(object):
|
||||
for category in self.categories:
|
||||
if category.name == key:
|
||||
return category
|
||||
raise KeyError('Category "{keY}" does not exist.'.format(key=key))
|
||||
raise KeyError('Category "{key}" does not exist.'.format(key=key))
|
||||
|
||||
def __len__(self):
|
||||
"""
|
||||
|
@ -22,11 +22,12 @@
|
||||
"""
|
||||
The :mod:`db` module provides helper functions for database related methods.
|
||||
"""
|
||||
import sqlalchemy
|
||||
import logging
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -168,7 +168,7 @@ def format_time(text, local_time):
|
||||
"""
|
||||
return local_time.strftime(match.group())
|
||||
|
||||
return re.sub('\%[a-zA-Z]', match_formatting, text)
|
||||
return re.sub(r'\%[a-zA-Z]', match_formatting, text)
|
||||
|
||||
|
||||
def get_locale_key(string):
|
||||
|
@ -26,7 +26,7 @@ import datetime
|
||||
import logging
|
||||
import os
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
from PyQt5 import QtCore, QtGui
|
||||
|
||||
from openlp.core.common import ThemeLevel, SlideLimits, UiStrings, is_win, is_linux
|
||||
|
||||
@ -129,7 +129,7 @@ class Settings(QtCore.QSettings):
|
||||
'advanced/recent file count': 4,
|
||||
'advanced/save current plugin': False,
|
||||
'advanced/slide limits': SlideLimits.End,
|
||||
'advanced/slide max height': 0,
|
||||
'advanced/slide max height': -4,
|
||||
'advanced/single click preview': False,
|
||||
'advanced/single click service preview': False,
|
||||
'advanced/x11 bypass wm': X11_BYPASS_DEFAULT,
|
||||
|
@ -68,7 +68,7 @@ class UiStrings(object):
|
||||
self.Default = translate('OpenLP.Ui', 'Default')
|
||||
self.DefaultColor = translate('OpenLP.Ui', 'Default Color:')
|
||||
self.DefaultServiceName = translate('OpenLP.Ui', 'Service %Y-%m-%d %H-%M',
|
||||
'This may not contain any of the following characters: /\\?*|<>\[\]":+\n'
|
||||
'This may not contain any of the following characters: /\\?*|<>[]":+\n'
|
||||
'See http://docs.python.org/library/datetime'
|
||||
'.html#strftime-strptime-behavior for more information.')
|
||||
self.Delete = translate('OpenLP.Ui', '&Delete')
|
||||
|
@ -10,10 +10,10 @@ from datetime import datetime
|
||||
from distutils.version import LooseVersion
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from openlp.core.common import AppLocation, Settings
|
||||
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from openlp.core.common import AppLocation, Settings
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
APPLICATION_VERSION = {}
|
||||
|
@ -95,7 +95,7 @@ def get_text_file_string(text_file):
|
||||
content = None
|
||||
try:
|
||||
file_handle = open(text_file, 'r', encoding='utf-8')
|
||||
if not file_handle.read(3) == '\xEF\xBB\xBF':
|
||||
if file_handle.read(3) != '\xEF\xBB\xBF':
|
||||
# no BOM was found
|
||||
file_handle.seek(0)
|
||||
content = file_handle.read()
|
||||
|
@ -122,6 +122,21 @@ def get_upgrade_op(session):
|
||||
return Operations(context)
|
||||
|
||||
|
||||
class BaseModel(object):
|
||||
"""
|
||||
BaseModel provides a base object with a set of generic functions
|
||||
"""
|
||||
@classmethod
|
||||
def populate(cls, **kwargs):
|
||||
"""
|
||||
Creates an instance of a class and populates it, returning the instance
|
||||
"""
|
||||
instance = cls()
|
||||
for key, value in kwargs.items():
|
||||
instance.__setattr__(key, value)
|
||||
return instance
|
||||
|
||||
|
||||
def upgrade_db(url, upgrade):
|
||||
"""
|
||||
Upgrade a database.
|
||||
@ -178,9 +193,9 @@ def upgrade_db(url, upgrade):
|
||||
version_meta = Metadata.populate(key='version', value=int(upgrade.__version__))
|
||||
session.commit()
|
||||
upgrade_version = upgrade.__version__
|
||||
version_meta = int(version_meta.value)
|
||||
version = int(version_meta.value)
|
||||
session.close()
|
||||
return version_meta, upgrade_version
|
||||
return version, upgrade_version
|
||||
|
||||
|
||||
def delete_database(plugin_name, db_file_name=None):
|
||||
@ -197,21 +212,6 @@ def delete_database(plugin_name, db_file_name=None):
|
||||
return delete_file(db_file_path)
|
||||
|
||||
|
||||
class BaseModel(object):
|
||||
"""
|
||||
BaseModel provides a base object with a set of generic functions
|
||||
"""
|
||||
@classmethod
|
||||
def populate(cls, **kwargs):
|
||||
"""
|
||||
Creates an instance of a class and populates it, returning the instance
|
||||
"""
|
||||
instance = cls()
|
||||
for key, value in kwargs.items():
|
||||
instance.__setattr__(key, value)
|
||||
return instance
|
||||
|
||||
|
||||
class Manager(object):
|
||||
"""
|
||||
Provide generic object persistence management
|
||||
|
@ -389,6 +389,7 @@ is the function which has to be called from outside. The generated and returned
|
||||
"""
|
||||
import logging
|
||||
|
||||
from string import Template
|
||||
from PyQt5 import QtWebKit
|
||||
|
||||
from openlp.core.common import Settings
|
||||
@ -396,157 +397,200 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, Vertic
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# TODO: Verify where this is used before converting to python3
|
||||
HTMLSRC = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenLP Display</title>
|
||||
<style>
|
||||
*{
|
||||
HTML_SRC = Template("""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenLP Display</title>
|
||||
<style>
|
||||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
body {
|
||||
${bg_css};
|
||||
}
|
||||
.size {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#black {
|
||||
z-index: 8;
|
||||
background-color: black;
|
||||
display: none;
|
||||
}
|
||||
#bgimage {
|
||||
z-index: 1;
|
||||
}
|
||||
#image {
|
||||
z-index: 2;
|
||||
}
|
||||
${css_additions}
|
||||
#footer {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
${footer_css}
|
||||
}
|
||||
/* lyric css */${lyrics_css}
|
||||
sup {
|
||||
font-size: 0.6em;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
top: -0.3em;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var timer = null;
|
||||
var transition = ${transitions};
|
||||
${js_additions}
|
||||
|
||||
function show_image(src){
|
||||
var img = document.getElementById('image');
|
||||
img.src = src;
|
||||
if(src == '')
|
||||
img.style.display = 'none';
|
||||
else
|
||||
img.style.display = 'block';
|
||||
}
|
||||
|
||||
function show_blank(state){
|
||||
var black = 'none';
|
||||
var lyrics = '';
|
||||
switch(state){
|
||||
case 'theme':
|
||||
lyrics = 'hidden';
|
||||
break;
|
||||
case 'black':
|
||||
black = 'block';
|
||||
break;
|
||||
case 'desktop':
|
||||
break;
|
||||
}
|
||||
document.getElementById('black').style.display = black;
|
||||
document.getElementById('lyricsmain').style.visibility = lyrics;
|
||||
document.getElementById('image').style.visibility = lyrics;
|
||||
document.getElementById('footer').style.visibility = lyrics;
|
||||
}
|
||||
|
||||
function show_footer(footertext){
|
||||
document.getElementById('footer').innerHTML = footertext;
|
||||
}
|
||||
|
||||
function show_text(new_text){
|
||||
var match = /-webkit-text-fill-color:[^;\"]+/gi;
|
||||
if(timer != null)
|
||||
clearTimeout(timer);
|
||||
/*
|
||||
QtWebkit bug with outlines and justify causing outline alignment
|
||||
problems. (Bug 859950) Surround each word with a <span> to workaround,
|
||||
but only in this scenario.
|
||||
*/
|
||||
var txt = document.getElementById('lyricsmain');
|
||||
if(window.getComputedStyle(txt).textAlign == 'justify'){
|
||||
if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
|
||||
new_text = new_text.replace(/(\s| )+(?![^<]*>)/g,
|
||||
function(match) {
|
||||
return '</span>' + match + '<span>';
|
||||
});
|
||||
new_text = '<span>' + new_text + '</span>';
|
||||
}
|
||||
}
|
||||
text_fade('lyricsmain', new_text);
|
||||
}
|
||||
|
||||
function text_fade(id, new_text){
|
||||
/*
|
||||
Show the text.
|
||||
*/
|
||||
var text = document.getElementById(id);
|
||||
if(text == null) return;
|
||||
if(!transition){
|
||||
text.innerHTML = new_text;
|
||||
return;
|
||||
}
|
||||
// Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
|
||||
text.style.opacity = '0.1';
|
||||
// Fade new text in after the old text has finished fading out.
|
||||
timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);
|
||||
}
|
||||
|
||||
function _show_text(text, new_text) {
|
||||
/*
|
||||
Helper function to show the new_text delayed.
|
||||
*/
|
||||
text.innerHTML = new_text;
|
||||
text.style.opacity = '1';
|
||||
// Wait until the text is completely visible. We want to save the timer id, to be able to call
|
||||
// clearTimeout(timer) when the text has changed before finishing fading.
|
||||
timer = window.setTimeout(function(){timer = null;}, 400);
|
||||
}
|
||||
|
||||
function show_text_completed(){
|
||||
return (timer == null);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img id="bgimage" class="size" ${bg_image} />
|
||||
<img id="image" class="size" ${image} />
|
||||
${html_additions}
|
||||
<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
|
||||
<div id="footer" class="footer"></div>
|
||||
<div id="black" class="size"></div>
|
||||
</body>
|
||||
</html>
|
||||
""")
|
||||
|
||||
LYRICS_SRC = Template("""
|
||||
.lyricstable {
|
||||
z-index: 5;
|
||||
position: absolute;
|
||||
display: table;
|
||||
${stable}
|
||||
}
|
||||
.lyricscell {
|
||||
display: table-cell;
|
||||
word-wrap: break-word;
|
||||
-webkit-transition: opacity 0.4s ease;
|
||||
${lyrics}
|
||||
}
|
||||
.lyricsmain {
|
||||
${main}
|
||||
}
|
||||
""")
|
||||
|
||||
FOOTER_SRC = Template("""
|
||||
left: ${left}px;
|
||||
bottom: ${bottom}px;
|
||||
width: ${width}px;
|
||||
font-family: ${family};
|
||||
font-size: ${size}pt;
|
||||
color: ${color};
|
||||
text-align: left;
|
||||
white-space: ${space};
|
||||
""")
|
||||
|
||||
LYRICS_FORMAT_SRC = Template("""
|
||||
${justify}word-wrap: break-word;
|
||||
text-align: ${align};
|
||||
vertical-align: ${valign};
|
||||
font-family: ${font};
|
||||
font-size: ${size}pt;
|
||||
color: ${color};
|
||||
line-height: ${line}%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
body {
|
||||
%s;
|
||||
}
|
||||
.size {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%%;
|
||||
height: 100%%;
|
||||
}
|
||||
#black {
|
||||
z-index: 8;
|
||||
background-color: black;
|
||||
display: none;
|
||||
}
|
||||
#bgimage {
|
||||
z-index: 1;
|
||||
}
|
||||
#image {
|
||||
z-index: 2;
|
||||
}
|
||||
%s
|
||||
#footer {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
%s
|
||||
}
|
||||
/* lyric css */
|
||||
%s
|
||||
sup {
|
||||
font-size: 0.6em;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
top: -0.3em;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var timer = null;
|
||||
var transition = %s;
|
||||
%s
|
||||
|
||||
function show_image(src){
|
||||
var img = document.getElementById('image');
|
||||
img.src = src;
|
||||
if(src == '')
|
||||
img.style.display = 'none';
|
||||
else
|
||||
img.style.display = 'block';
|
||||
}
|
||||
|
||||
function show_blank(state){
|
||||
var black = 'none';
|
||||
var lyrics = '';
|
||||
switch(state){
|
||||
case 'theme':
|
||||
lyrics = 'hidden';
|
||||
break;
|
||||
case 'black':
|
||||
black = 'block';
|
||||
break;
|
||||
case 'desktop':
|
||||
break;
|
||||
}
|
||||
document.getElementById('black').style.display = black;
|
||||
document.getElementById('lyricsmain').style.visibility = lyrics;
|
||||
document.getElementById('image').style.visibility = lyrics;
|
||||
document.getElementById('footer').style.visibility = lyrics;
|
||||
}
|
||||
|
||||
function show_footer(footertext){
|
||||
document.getElementById('footer').innerHTML = footertext;
|
||||
}
|
||||
|
||||
function show_text(new_text){
|
||||
var match = /-webkit-text-fill-color:[^;\"]+/gi;
|
||||
if(timer != null)
|
||||
clearTimeout(timer);
|
||||
/*
|
||||
QtWebkit bug with outlines and justify causing outline alignment
|
||||
problems. (Bug 859950) Surround each word with a <span> to workaround,
|
||||
but only in this scenario.
|
||||
*/
|
||||
var txt = document.getElementById('lyricsmain');
|
||||
if(window.getComputedStyle(txt).textAlign == 'justify'){
|
||||
if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
|
||||
new_text = new_text.replace(/(\s| )+(?![^<]*>)/g,
|
||||
function(match) {
|
||||
return '</span>' + match + '<span>';
|
||||
});
|
||||
new_text = '<span>' + new_text + '</span>';
|
||||
}
|
||||
}
|
||||
text_fade('lyricsmain', new_text);
|
||||
}
|
||||
|
||||
function text_fade(id, new_text){
|
||||
/*
|
||||
Show the text.
|
||||
*/
|
||||
var text = document.getElementById(id);
|
||||
if(text == null) return;
|
||||
if(!transition){
|
||||
text.innerHTML = new_text;
|
||||
return;
|
||||
}
|
||||
// Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
|
||||
text.style.opacity = '0.1';
|
||||
// Fade new text in after the old text has finished fading out.
|
||||
timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);
|
||||
}
|
||||
|
||||
function _show_text(text, new_text) {
|
||||
/*
|
||||
Helper function to show the new_text delayed.
|
||||
*/
|
||||
text.innerHTML = new_text;
|
||||
text.style.opacity = '1';
|
||||
// Wait until the text is completely visible. We want to save the timer id, to be able to call
|
||||
// clearTimeout(timer) when the text has changed before finishing fading.
|
||||
timer = window.setTimeout(function(){timer = null;}, 400);
|
||||
}
|
||||
|
||||
function show_text_completed(){
|
||||
return (timer == null);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img id="bgimage" class="size" %s />
|
||||
<img id="image" class="size" %s />
|
||||
%s
|
||||
<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
|
||||
<div id="footer" class="footer"></div>
|
||||
<div id="black" class="size"></div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
padding-bottom: ${bottom};
|
||||
padding-left: ${left}px;
|
||||
width: ${width}px;
|
||||
height: ${height}px;${font_style}${font_weight}
|
||||
""")
|
||||
|
||||
|
||||
def build_html(item, screen, is_live, background, image=None, plugins=None):
|
||||
@ -582,18 +626,17 @@ def build_html(item, screen, is_live, background, image=None, plugins=None):
|
||||
css_additions += plugin.get_display_css()
|
||||
js_additions += plugin.get_display_javascript()
|
||||
html_additions += plugin.get_display_html()
|
||||
html = HTMLSRC % (
|
||||
build_background_css(item, width),
|
||||
css_additions,
|
||||
build_footer_css(item, height),
|
||||
build_lyrics_css(item),
|
||||
'true' if theme_data and theme_data.display_slide_transition and is_live else 'false',
|
||||
js_additions,
|
||||
bgimage_src,
|
||||
image_src,
|
||||
html_additions
|
||||
)
|
||||
return html
|
||||
return HTML_SRC.substitute(bg_css=build_background_css(item, width),
|
||||
css_additions=css_additions,
|
||||
footer_css=build_footer_css(item, height),
|
||||
lyrics_css=build_lyrics_css(item),
|
||||
transitions='true' if (theme_data and
|
||||
theme_data.display_slide_transition and
|
||||
is_live) else 'false',
|
||||
js_additions=js_additions,
|
||||
bg_image=bgimage_src,
|
||||
image=image_src,
|
||||
html_additions=html_additions)
|
||||
|
||||
|
||||
def webkit_version():
|
||||
@ -604,7 +647,7 @@ def webkit_version():
|
||||
webkit_ver = float(QtWebKit.qWebKitVersion())
|
||||
log.debug('Webkit version = {version}'.format(version=webkit_ver))
|
||||
except AttributeError:
|
||||
webkit_ver = 0
|
||||
webkit_ver = 0.0
|
||||
return webkit_ver
|
||||
|
||||
|
||||
@ -650,24 +693,6 @@ def build_lyrics_css(item):
|
||||
|
||||
:param item: Service Item containing theme and location information
|
||||
"""
|
||||
# TODO: Verify this before converting to python3
|
||||
style = """
|
||||
.lyricstable {
|
||||
z-index: 5;
|
||||
position: absolute;
|
||||
display: table;
|
||||
%s
|
||||
}
|
||||
.lyricscell {
|
||||
display: table-cell;
|
||||
word-wrap: break-word;
|
||||
-webkit-transition: opacity 0.4s ease;
|
||||
%s
|
||||
}
|
||||
.lyricsmain {
|
||||
%s
|
||||
}
|
||||
"""
|
||||
theme_data = item.theme_data
|
||||
lyricstable = ''
|
||||
lyrics = ''
|
||||
@ -680,8 +705,7 @@ def build_lyrics_css(item):
|
||||
lyricsmain += ' text-shadow: {theme} {shadow}px ' \
|
||||
'{shadow}px;'.format(theme=theme_data.font_main_shadow_color,
|
||||
shadow=theme_data.font_main_shadow_size)
|
||||
lyrics_css = style % (lyricstable, lyrics, lyricsmain)
|
||||
return lyrics_css
|
||||
return LYRICS_SRC.substitute(stable=lyricstable, lyrics=lyrics, main=lyricsmain)
|
||||
|
||||
|
||||
def build_lyrics_outline_css(theme_data):
|
||||
@ -710,38 +734,23 @@ def build_lyrics_format_css(theme_data, width, height):
|
||||
"""
|
||||
align = HorizontalType.Names[theme_data.display_horizontal_align]
|
||||
valign = VerticalType.Names[theme_data.display_vertical_align]
|
||||
if theme_data.font_main_outline:
|
||||
left_margin = int(theme_data.font_main_outline_size) * 2
|
||||
else:
|
||||
left_margin = 0
|
||||
justify = 'white-space:pre-wrap;'
|
||||
left_margin = (int(theme_data.font_main_outline_size) * 2) if theme_data.font_main_outline else 0
|
||||
# fix tag incompatibilities
|
||||
if theme_data.display_horizontal_align == HorizontalType.Justify:
|
||||
justify = ''
|
||||
if theme_data.display_vertical_align == VerticalType.Bottom:
|
||||
padding_bottom = '0.5em'
|
||||
else:
|
||||
padding_bottom = '0'
|
||||
lyrics = '{justify} word-wrap: break-word; ' \
|
||||
'text-align: {align}; vertical-align: {valign}; font-family: {font}; ' \
|
||||
'font-size: {size}pt; color: {color}; line-height: {line:d}%; margin: 0;' \
|
||||
'padding: 0; padding-bottom: {bottom}; padding-left: {left}px; width: {width}px; ' \
|
||||
'height: {height}px; '.format(justify=justify,
|
||||
align=align,
|
||||
valign=valign,
|
||||
font=theme_data.font_main_name,
|
||||
size=theme_data.font_main_size,
|
||||
color=theme_data.font_main_color,
|
||||
line=100 + int(theme_data.font_main_line_adjustment),
|
||||
bottom=padding_bottom,
|
||||
left=left_margin,
|
||||
width=width,
|
||||
height=height)
|
||||
if theme_data.font_main_italics:
|
||||
lyrics += 'font-style:italic; '
|
||||
if theme_data.font_main_bold:
|
||||
lyrics += 'font-weight:bold; '
|
||||
return lyrics
|
||||
justify = '' if (theme_data.display_horizontal_align == HorizontalType.Justify) else ' white-space: pre-wrap;\n'
|
||||
padding_bottom = '0.5em' if (theme_data.display_vertical_align == VerticalType.Bottom) else '0'
|
||||
return LYRICS_FORMAT_SRC.substitute(justify=justify,
|
||||
align=align,
|
||||
valign=valign,
|
||||
font=theme_data.font_main_name,
|
||||
size=theme_data.font_main_size,
|
||||
color=theme_data.font_main_color,
|
||||
line='{line:d}'.format(line=100 + int(theme_data.font_main_line_adjustment)),
|
||||
bottom=padding_bottom,
|
||||
left=left_margin,
|
||||
width=width,
|
||||
height=height,
|
||||
font_style='\n font-style: italic;' if theme_data.font_main_italics else '',
|
||||
font_weight='\n font-weight: bold;' if theme_data.font_main_bold else '')
|
||||
|
||||
|
||||
def build_footer_css(item, height):
|
||||
@ -751,22 +760,11 @@ def build_footer_css(item, height):
|
||||
:param item: Service Item to be processed.
|
||||
:param height:
|
||||
"""
|
||||
style = """
|
||||
left: {left}px;
|
||||
bottom: {bottom}px;
|
||||
width: {width}px;
|
||||
font-family: {family};
|
||||
font-size: {size}pt;
|
||||
color: {color};
|
||||
text-align: left;
|
||||
white-space: {space};
|
||||
"""
|
||||
theme = item.theme_data
|
||||
if not theme or not item.footer:
|
||||
return ''
|
||||
bottom = height - int(item.footer.y()) - int(item.footer.height())
|
||||
whitespace = 'normal' if Settings().value('themes/wrap footer') else 'nowrap'
|
||||
lyrics_html = style.format(left=item.footer.x(), bottom=bottom, width=item.footer.width(),
|
||||
family=theme.font_footer_name, size=theme.font_footer_size,
|
||||
color=theme.font_footer_color, space=whitespace)
|
||||
return lyrics_html
|
||||
return FOOTER_SRC.substitute(left=item.footer.x(), bottom=bottom, width=item.footer.width(),
|
||||
family=theme.font_footer_name, size=theme.font_footer_size,
|
||||
color=theme.font_footer_color, space=whitespace)
|
||||
|
@ -23,7 +23,6 @@
|
||||
Provide plugin management
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import imp
|
||||
|
||||
from openlp.core.lib import Plugin, PluginStatus
|
||||
|
@ -40,13 +40,12 @@ log.debug('projector.lib.db module loaded')
|
||||
|
||||
from sqlalchemy import Column, ForeignKey, Integer, MetaData, String, and_
|
||||
from sqlalchemy.ext.declarative import declarative_base, declared_attr
|
||||
from sqlalchemy.orm import backref, relationship
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from openlp.core.lib.db import Manager, init_db, init_url
|
||||
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES
|
||||
|
||||
metadata = MetaData()
|
||||
Base = declarative_base(metadata)
|
||||
Base = declarative_base(MetaData())
|
||||
|
||||
|
||||
class CommonBase(object):
|
||||
@ -54,8 +53,8 @@ class CommonBase(object):
|
||||
Base class to automate table name and ID column.
|
||||
"""
|
||||
@declared_attr
|
||||
def __tablename__(cls):
|
||||
return cls.__name__.lower()
|
||||
def __tablename__(self):
|
||||
return self.__name__.lower()
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
@ -257,7 +256,7 @@ class ProjectorDB(Manager):
|
||||
projector = self.get_object_filtered(Projector, Projector.id == dbid)
|
||||
if projector is None:
|
||||
# Not found
|
||||
log.warn('get_projector_by_id() did not find {data}'.format(data=id))
|
||||
log.warning('get_projector_by_id() did not find {data}'.format(data=id))
|
||||
return None
|
||||
log.debug('get_projectorby_id() returning 1 entry for "{entry}" id="{data}"'.format(entry=dbid,
|
||||
data=projector.id))
|
||||
@ -290,7 +289,7 @@ class ProjectorDB(Manager):
|
||||
projector = self.get_object_filtered(Projector, Projector.ip == ip)
|
||||
if projector is None:
|
||||
# Not found
|
||||
log.warn('get_projector_by_ip() did not find {ip}'.format(ip=ip))
|
||||
log.warning('get_projector_by_ip() did not find {ip}'.format(ip=ip))
|
||||
return None
|
||||
log.debug('get_projectorby_ip() returning 1 entry for "{ip}" id="{data}"'.format(ip=ip,
|
||||
data=projector.id))
|
||||
@ -307,7 +306,7 @@ class ProjectorDB(Manager):
|
||||
projector = self.get_object_filtered(Projector, Projector.name == name)
|
||||
if projector is None:
|
||||
# Not found
|
||||
log.warn('get_projector_by_name() did not find "{name}"'.format(name=name))
|
||||
log.warning('get_projector_by_name() did not find "{name}"'.format(name=name))
|
||||
return None
|
||||
log.debug('get_projector_by_name() returning one entry for "{name}" id="{data}"'.format(name=name,
|
||||
data=projector.id))
|
||||
@ -324,7 +323,7 @@ class ProjectorDB(Manager):
|
||||
"""
|
||||
old_projector = self.get_object_filtered(Projector, Projector.ip == projector.ip)
|
||||
if old_projector is not None:
|
||||
log.warn('add_new() skipping entry ip="{ip}" (Already saved)'.format(ip=old_projector.ip))
|
||||
log.warning('add_new() skipping entry ip="{ip}" (Already saved)'.format(ip=old_projector.ip))
|
||||
return False
|
||||
log.debug('add_new() saving new entry')
|
||||
log.debug('ip="{ip}", name="{name}", location="{location}"'.format(ip=projector.ip,
|
||||
@ -408,10 +407,10 @@ class ProjectorDB(Manager):
|
||||
:param source: ProjectorSource id
|
||||
:returns: ProjetorSource instance or None
|
||||
"""
|
||||
source_entry = self.get_object_filtered(ProjetorSource, ProjectorSource.id == source)
|
||||
source_entry = self.get_object_filtered(ProjectorSource, ProjectorSource.id == source)
|
||||
if source_entry is None:
|
||||
# Not found
|
||||
log.warn('get_source_by_id() did not find "{source}"'.format(source=source))
|
||||
log.warning('get_source_by_id() did not find "{source}"'.format(source=source))
|
||||
return None
|
||||
log.debug('get_source_by_id() returning one entry for "{source}""'.format(source=source))
|
||||
return source_entry
|
||||
@ -430,8 +429,8 @@ class ProjectorDB(Manager):
|
||||
|
||||
if source_entry is None:
|
||||
# Not found
|
||||
log.warn('get_source_by_id() not found')
|
||||
log.warn('code="{code}" projector_id="{data}"'.format(code=code, data=projector_id))
|
||||
log.warning('get_source_by_id() not found')
|
||||
log.warning('code="{code}" projector_id="{data}"'.format(code=code, data=projector_id))
|
||||
return None
|
||||
log.debug('get_source_by_id() returning one entry')
|
||||
log.debug('code="{code}" projector_id="{data}"'.format(code=code, data=projector_id))
|
||||
|
@ -297,6 +297,8 @@ class PJLink1(QTcpSocket):
|
||||
Processes the initial connection and authentication (if needed).
|
||||
Starts poll timer if connection is established.
|
||||
|
||||
NOTE: Qt md5 hash function doesn't work with projector authentication. Use the python md5 hash function.
|
||||
|
||||
:param data: Optional data if called from another routine
|
||||
"""
|
||||
log.debug('({ip}) check_login(data="{data}")'.format(ip=self.ip, data=data))
|
||||
@ -310,10 +312,10 @@ class PJLink1(QTcpSocket):
|
||||
read = self.readLine(self.maxSize)
|
||||
dontcare = self.readLine(self.maxSize) # Clean out the trailing \r\n
|
||||
if read is None:
|
||||
log.warn('({ip}) read is None - socket error?'.format(ip=self.ip))
|
||||
log.warning('({ip}) read is None - socket error?'.format(ip=self.ip))
|
||||
return
|
||||
elif len(read) < 8:
|
||||
log.warn('({ip}) Not enough data read)'.format(ip=self.ip))
|
||||
log.warning('({ip}) Not enough data read)'.format(ip=self.ip))
|
||||
return
|
||||
data = decode(read, 'ascii')
|
||||
# Possibility of extraneous data on input when reading.
|
||||
@ -344,23 +346,33 @@ class PJLink1(QTcpSocket):
|
||||
return
|
||||
elif data_check[1] == '0' and self.pin is not None:
|
||||
# Pin set and no authentication needed
|
||||
log.warning('({ip}) Regular connection but PIN set'.format(ip=self.name))
|
||||
self.disconnect_from_host()
|
||||
self.change_status(E_AUTHENTICATION)
|
||||
log.debug('({ip}) emitting projectorNoAuthentication() signal'.format(ip=self.name))
|
||||
log.debug('({ip}) Emitting projectorNoAuthentication() signal'.format(ip=self.name))
|
||||
self.projectorNoAuthentication.emit(self.name)
|
||||
return
|
||||
elif data_check[1] == '1':
|
||||
# Authenticated login with salt
|
||||
log.debug('({ip}) Setting hash with salt="{data}"'.format(ip=self.ip, data=data_check[2]))
|
||||
log.debug('({ip}) pin="{data}"'.format(ip=self.ip, data=self.pin))
|
||||
salt = qmd5_hash(salt=data_check[2].encode('ascii'), data=self.pin.encode('ascii'))
|
||||
if self.pin is None:
|
||||
log.warning('({ip}) Authenticated connection but no pin set'.format(ip=self.name))
|
||||
self.disconnect_from_host()
|
||||
self.change_status(E_AUTHENTICATION)
|
||||
log.debug('({ip}) Emitting projectorAuthentication() signal'.format(ip=self.name))
|
||||
self.projectorAuthentication.emit(self.name)
|
||||
return
|
||||
else:
|
||||
log.debug('({ip}) Setting hash with salt="{data}"'.format(ip=self.ip, data=data_check[2]))
|
||||
log.debug('({ip}) pin="{data}"'.format(ip=self.ip, data=self.pin))
|
||||
data_hash = str(qmd5_hash(salt=data_check[2].encode('utf-8'), data=self.pin.encode('utf-8')),
|
||||
encoding='ascii')
|
||||
else:
|
||||
salt = None
|
||||
# We're connected at this point, so go ahead and do regular I/O
|
||||
data_hash = None
|
||||
# We're connected at this point, so go ahead and setup regular I/O
|
||||
self.readyRead.connect(self.get_data)
|
||||
self.projectorReceivedData.connect(self._send_command)
|
||||
# Initial data we should know about
|
||||
self.send_command(cmd='CLSS', salt=salt)
|
||||
self.send_command(cmd='CLSS', salt=data_hash)
|
||||
self.waitForReadyRead()
|
||||
if (not self.no_poll) and (self.state() == self.ConnectedState):
|
||||
log.debug('({ip}) Starting timer'.format(ip=self.ip))
|
||||
@ -402,7 +414,7 @@ class PJLink1(QTcpSocket):
|
||||
self.projectorReceivedData.emit()
|
||||
return
|
||||
elif '=' not in data:
|
||||
log.warn('({ip}) get_data(): Invalid packet received'.format(ip=self.ip))
|
||||
log.warning('({ip}) get_data(): Invalid packet received'.format(ip=self.ip))
|
||||
self.send_busy = False
|
||||
self.projectorReceivedData.emit()
|
||||
return
|
||||
@ -410,15 +422,15 @@ class PJLink1(QTcpSocket):
|
||||
try:
|
||||
(prefix, class_, cmd, data) = (data_split[0][0], data_split[0][1], data_split[0][2:], data_split[1])
|
||||
except ValueError as e:
|
||||
log.warn('({ip}) get_data(): Invalid packet - expected header + command + data'.format(ip=self.ip))
|
||||
log.warn('({ip}) get_data(): Received data: "{data}"'.format(ip=self.ip, data=data_in.strip()))
|
||||
log.warning('({ip}) get_data(): Invalid packet - expected header + command + data'.format(ip=self.ip))
|
||||
log.warning('({ip}) get_data(): Received data: "{data}"'.format(ip=self.ip, data=data_in.strip()))
|
||||
self.change_status(E_INVALID_DATA)
|
||||
self.send_busy = False
|
||||
self.projectorReceivedData.emit()
|
||||
return
|
||||
|
||||
if not (self.pjlink_class in PJLINK_VALID_CMD and cmd in PJLINK_VALID_CMD[self.pjlink_class]):
|
||||
log.warn('({ip}) get_data(): Invalid packet - unknown command "{data}"'.format(ip=self.ip, data=cmd))
|
||||
log.warning('({ip}) get_data(): Invalid packet - unknown command "{data}"'.format(ip=self.ip, data=cmd))
|
||||
self.send_busy = False
|
||||
self.projectorReceivedData.emit()
|
||||
return
|
||||
@ -461,7 +473,7 @@ class PJLink1(QTcpSocket):
|
||||
:param queue: Option to force add to queue rather than sending directly
|
||||
"""
|
||||
if self.state() != self.ConnectedState:
|
||||
log.warn('({ip}) send_command(): Not connected - returning'.format(ip=self.ip))
|
||||
log.warning('({ip}) send_command(): Not connected - returning'.format(ip=self.ip))
|
||||
self.send_queue = []
|
||||
return
|
||||
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
||||
@ -577,7 +589,7 @@ class PJLink1(QTcpSocket):
|
||||
if cmd in self.PJLINK1_FUNC:
|
||||
self.PJLINK1_FUNC[cmd](data)
|
||||
else:
|
||||
log.warn('({ip}) Invalid command {data}'.format(ip=self.ip, data=cmd))
|
||||
log.warning('({ip}) Invalid command {data}'.format(ip=self.ip, data=cmd))
|
||||
self.send_busy = False
|
||||
self.projectorReceivedData.emit()
|
||||
|
||||
@ -596,7 +608,7 @@ class PJLink1(QTcpSocket):
|
||||
fill = {'Hours': int(data_dict[0]), 'On': False if data_dict[1] == '0' else True}
|
||||
except ValueError:
|
||||
# In case of invalid entry
|
||||
log.warn('({ip}) process_lamp(): Invalid data "{data}"'.format(ip=self.ip, data=data))
|
||||
log.warning('({ip}) process_lamp(): Invalid data "{data}"'.format(ip=self.ip, data=data))
|
||||
return
|
||||
lamps.append(fill)
|
||||
data_dict.pop(0) # Remove lamp hours
|
||||
@ -623,7 +635,7 @@ class PJLink1(QTcpSocket):
|
||||
self.send_command('INST')
|
||||
else:
|
||||
# Log unknown status response
|
||||
log.warn('({ip}) Unknown power response: {data}'.format(ip=self.ip, data=data))
|
||||
log.warning('({ip}) Unknown power response: {data}'.format(ip=self.ip, data=data))
|
||||
return
|
||||
|
||||
def process_avmt(self, data):
|
||||
@ -648,7 +660,7 @@ class PJLink1(QTcpSocket):
|
||||
shutter = True
|
||||
mute = True
|
||||
else:
|
||||
log.warn('({ip}) Unknown shutter response: {data}'.format(ip=self.ip, data=data))
|
||||
log.warning('({ip}) Unknown shutter response: {data}'.format(ip=self.ip, data=data))
|
||||
update_icons = shutter != self.shutter
|
||||
update_icons = update_icons or mute != self.mute
|
||||
self.shutter = shutter
|
||||
@ -797,7 +809,7 @@ class PJLink1(QTcpSocket):
|
||||
Initiate connection to projector.
|
||||
"""
|
||||
if self.state() == self.ConnectedState:
|
||||
log.warn('({ip}) connect_to_host(): Already connected - returning'.format(ip=self.ip))
|
||||
log.warning('({ip}) connect_to_host(): Already connected - returning'.format(ip=self.ip))
|
||||
return
|
||||
self.change_status(S_CONNECTING)
|
||||
self.connectToHost(self.ip, self.port if type(self.port) is int else int(self.port))
|
||||
@ -809,9 +821,9 @@ class PJLink1(QTcpSocket):
|
||||
"""
|
||||
if abort or self.state() != self.ConnectedState:
|
||||
if abort:
|
||||
log.warn('({ip}) disconnect_from_host(): Aborting connection'.format(ip=self.ip))
|
||||
log.warning('({ip}) disconnect_from_host(): Aborting connection'.format(ip=self.ip))
|
||||
else:
|
||||
log.warn('({ip}) disconnect_from_host(): Not connected - returning'.format(ip=self.ip))
|
||||
log.warning('({ip}) disconnect_from_host(): Not connected - returning'.format(ip=self.ip))
|
||||
self.reset_information()
|
||||
self.disconnectFromHost()
|
||||
try:
|
||||
|
@ -531,7 +531,7 @@ def words_split(line):
|
||||
:param line: Line to be split
|
||||
"""
|
||||
# this parse we are to be wordy
|
||||
return re.split('\s+', line)
|
||||
return re.split(r'\s+', line)
|
||||
|
||||
|
||||
def get_start_tags(raw_text):
|
||||
|
@ -34,7 +34,7 @@ import ntpath
|
||||
from PyQt5 import QtGui
|
||||
|
||||
from openlp.core.common import RegistryProperties, Settings, translate, AppLocation, md5_hash
|
||||
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, create_thumb
|
||||
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
Provide the theme XML and handling functions for OpenLP v2 themes.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import logging
|
||||
import json
|
||||
|
||||
@ -165,6 +164,7 @@ class ThemeXML(object):
|
||||
jsn = get_text_file_string(json_file)
|
||||
jsn = json.loads(jsn)
|
||||
self.expand_json(jsn)
|
||||
self.background_filename = None
|
||||
|
||||
def expand_json(self, var, prev=None):
|
||||
"""
|
||||
@ -477,12 +477,12 @@ class ThemeXML(object):
|
||||
if element == 'weight':
|
||||
element = 'bold'
|
||||
if value == 'Normal':
|
||||
value = False
|
||||
ret_value = False
|
||||
else:
|
||||
value = True
|
||||
ret_value = True
|
||||
if element == 'proportion':
|
||||
element = 'size'
|
||||
return False, master, element, value
|
||||
return False, master, element, ret_value
|
||||
|
||||
def _create_attr(self, master, element, value):
|
||||
"""
|
||||
|
@ -179,5 +179,4 @@ def get_web_page(url, header=None, update_openlp=False):
|
||||
return page
|
||||
|
||||
|
||||
__all__ = ['get_application_version', 'check_latest_version',
|
||||
'get_web_page']
|
||||
__all__ = ['get_web_page']
|
||||
|
@ -87,11 +87,14 @@ class AdvancedTab(SettingsTab):
|
||||
self.ui_layout.addRow(self.expand_service_item_check_box)
|
||||
self.slide_max_height_label = QtWidgets.QLabel(self.ui_group_box)
|
||||
self.slide_max_height_label.setObjectName('slide_max_height_label')
|
||||
self.slide_max_height_spin_box = QtWidgets.QSpinBox(self.ui_group_box)
|
||||
self.slide_max_height_spin_box.setObjectName('slide_max_height_spin_box')
|
||||
self.slide_max_height_spin_box.setRange(0, 1000)
|
||||
self.slide_max_height_spin_box.setSingleStep(20)
|
||||
self.ui_layout.addRow(self.slide_max_height_label, self.slide_max_height_spin_box)
|
||||
self.slide_max_height_combo_box = QtWidgets.QComboBox(self.ui_group_box)
|
||||
self.slide_max_height_combo_box.addItem('', userData=0)
|
||||
self.slide_max_height_combo_box.addItem('', userData=-4)
|
||||
# Generate numeric values for combo box dynamically
|
||||
for px in range(60, 801, 5):
|
||||
self.slide_max_height_combo_box.addItem(str(px) + 'px', userData=px)
|
||||
self.slide_max_height_combo_box.setObjectName('slide_max_height_combo_box')
|
||||
self.ui_layout.addRow(self.slide_max_height_label, self.slide_max_height_combo_box)
|
||||
self.autoscroll_label = QtWidgets.QLabel(self.ui_group_box)
|
||||
self.autoscroll_label.setObjectName('autoscroll_label')
|
||||
self.autoscroll_combo_box = QtWidgets.QComboBox(self.ui_group_box)
|
||||
@ -265,7 +268,8 @@ class AdvancedTab(SettingsTab):
|
||||
'Expand new service items on creation'))
|
||||
self.slide_max_height_label.setText(translate('OpenLP.AdvancedTab',
|
||||
'Max height for non-text slides\nin slide controller:'))
|
||||
self.slide_max_height_spin_box.setSpecialValueText(translate('OpenLP.AdvancedTab', 'Disabled'))
|
||||
self.slide_max_height_combo_box.setItemText(0, translate('OpenLP.AdvancedTab', 'Disabled'))
|
||||
self.slide_max_height_combo_box.setItemText(1, translate('OpenLP.AdvancedTab', 'Automatic'))
|
||||
self.autoscroll_label.setText(translate('OpenLP.AdvancedTab',
|
||||
'When changing slides:'))
|
||||
self.autoscroll_combo_box.setItemText(0, translate('OpenLP.AdvancedTab', 'Do not auto-scroll'))
|
||||
@ -355,10 +359,13 @@ class AdvancedTab(SettingsTab):
|
||||
self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
|
||||
self.single_click_service_preview_check_box.setChecked(settings.value('single click service preview'))
|
||||
self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
|
||||
self.slide_max_height_spin_box.setValue(settings.value('slide max height'))
|
||||
slide_max_height_value = settings.value('slide max height')
|
||||
for i in range(0, self.slide_max_height_combo_box.count()):
|
||||
if self.slide_max_height_combo_box.itemData(i) == slide_max_height_value:
|
||||
self.slide_max_height_combo_box.setCurrentIndex(i)
|
||||
autoscroll_value = settings.value('autoscrolling')
|
||||
for i in range(0, len(self.autoscroll_map)):
|
||||
if self.autoscroll_map[i] == autoscroll_value:
|
||||
if self.autoscroll_map[i] == autoscroll_value and i < self.autoscroll_combo_box.count():
|
||||
self.autoscroll_combo_box.setCurrentIndex(i)
|
||||
self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
|
||||
self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
|
||||
@ -439,7 +446,9 @@ class AdvancedTab(SettingsTab):
|
||||
settings.setValue('single click preview', self.single_click_preview_check_box.isChecked())
|
||||
settings.setValue('single click service preview', self.single_click_service_preview_check_box.isChecked())
|
||||
settings.setValue('expand service item', self.expand_service_item_check_box.isChecked())
|
||||
settings.setValue('slide max height', self.slide_max_height_spin_box.value())
|
||||
slide_max_height_index = self.slide_max_height_combo_box.currentIndex()
|
||||
slide_max_height_value = self.slide_max_height_combo_box.itemData(slide_max_height_index)
|
||||
settings.setValue('slide max height', slide_max_height_value)
|
||||
settings.setValue('autoscrolling', self.autoscroll_map[self.autoscroll_combo_box.currentIndex()])
|
||||
settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked())
|
||||
settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
|
||||
|
@ -32,8 +32,6 @@ import sqlalchemy
|
||||
from PyQt5 import Qt, QtCore, QtGui, QtWebKit, QtWidgets
|
||||
from lxml import etree
|
||||
|
||||
from openlp.core.common import RegistryProperties, is_linux
|
||||
|
||||
try:
|
||||
import migrate
|
||||
MIGRATE_VERSION = getattr(migrate, '__version__', '< 0.7')
|
||||
@ -74,6 +72,7 @@ except ImportError:
|
||||
|
||||
from openlp.core.common import Settings, UiStrings, translate
|
||||
from openlp.core.common.versionchecker import get_application_version
|
||||
from openlp.core.common import RegistryProperties, is_linux
|
||||
|
||||
from .exceptiondialog import Ui_ExceptionDialog
|
||||
|
||||
|
@ -564,13 +564,13 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
|
||||
if self.has_run_wizard:
|
||||
text = translate('OpenLP.FirstTimeWizard',
|
||||
'Download complete. Click the {button} button to return to OpenLP.'
|
||||
).format(text=clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton)))
|
||||
).format(button=clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton)))
|
||||
self.progress_label.setText(text)
|
||||
else:
|
||||
text = translate('OpenLP.FirstTimeWizard',
|
||||
'Download complete. Click the {button} button to start OpenLP.'
|
||||
).format(button=clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton)))
|
||||
self.progress_label.setText()
|
||||
self.progress_label.setText(text)
|
||||
else:
|
||||
if self.has_run_wizard:
|
||||
text = translate('OpenLP.FirstTimeWizard',
|
||||
@ -581,7 +581,7 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
|
||||
text = translate('OpenLP.FirstTimeWizard',
|
||||
'Click the {button} button to start OpenLP.'
|
||||
).format(button=clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton)))
|
||||
self.progress_label.setText()
|
||||
self.progress_label.setText(text)
|
||||
self.finish_button.setVisible(True)
|
||||
self.finish_button.setEnabled(True)
|
||||
self.cancel_button.setVisible(False)
|
||||
@ -664,14 +664,14 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
|
||||
if missed_files:
|
||||
file_list = ''
|
||||
for entry in missed_files:
|
||||
file_list += '{text}<br \>'.format(text=entry)
|
||||
file_list += '{text}<br \\>'.format(text=entry)
|
||||
msg = QtWidgets.QMessageBox()
|
||||
msg.setIcon(QtWidgets.QMessageBox.Warning)
|
||||
msg.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'Network Error'))
|
||||
msg.setText(translate('OpenLP.FirstTimeWizard', 'Unable to download some files'))
|
||||
msg.setInformativeText(translate('OpenLP.FirstTimeWizard',
|
||||
'The following files were not able to be '
|
||||
'downloaded:<br \>{text}'.format(text=file_list)))
|
||||
'downloaded:<br \\>{text}'.format(text=file_list)))
|
||||
msg.setStandardButtons(msg.Ok)
|
||||
ans = msg.exec()
|
||||
return True
|
||||
|
@ -84,7 +84,7 @@ class FormattingTagController(object):
|
||||
'desc': desc,
|
||||
'start tag': '{{{tag}}}'.format(tag=tag),
|
||||
'start html': start_html,
|
||||
'end tag': '{/{tag}}}'.format(tag=tag),
|
||||
'end tag': '{{{tag}}}'.format(tag=tag),
|
||||
'end html': end_html,
|
||||
'protected': False,
|
||||
'temporary': False
|
||||
|
@ -63,6 +63,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
# Initialize variables.
|
||||
self.service_item = ServiceItem()
|
||||
self.screen_ratio = screen_ratio
|
||||
self.auto_row_height = 100
|
||||
# Connect signals
|
||||
self.verticalHeader().sectionResized.connect(self.row_resized)
|
||||
|
||||
@ -87,8 +88,14 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
height = self.viewport().width() // self.screen_ratio
|
||||
max_img_row_height = Settings().value('advanced/slide max height')
|
||||
# Adjust for row height cap if in use.
|
||||
if isinstance(max_img_row_height, int) and max_img_row_height > 0 and height > max_img_row_height:
|
||||
height = max_img_row_height
|
||||
if isinstance(max_img_row_height, int):
|
||||
if max_img_row_height > 0 and height > max_img_row_height:
|
||||
height = max_img_row_height
|
||||
elif max_img_row_height < 0:
|
||||
# If auto setting, show that number of slides, or if the resulting slides too small, 100px.
|
||||
# E.g. If setting is -4, 4 slides will be visible, unless those slides are < 100px high.
|
||||
self.auto_row_height = max(self.viewport().height() / (-1 * max_img_row_height), 100)
|
||||
height = min(height, self.auto_row_height)
|
||||
# Apply new height to slides
|
||||
for frame_number in range(len(self.service_item.get_frames())):
|
||||
self.setRowHeight(frame_number, height)
|
||||
@ -99,7 +106,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
"""
|
||||
# Only for non-text slides when row height cap in use
|
||||
max_img_row_height = Settings().value('advanced/slide max height')
|
||||
if self.service_item.is_text() or not isinstance(max_img_row_height, int) or max_img_row_height <= 0:
|
||||
if self.service_item.is_text() or not isinstance(max_img_row_height, int) or max_img_row_height == 0:
|
||||
return
|
||||
# Get and validate label widget containing slide & adjust max width
|
||||
try:
|
||||
@ -165,11 +172,15 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
slide_height = width // self.screen_ratio
|
||||
# Setup and validate row height cap if in use.
|
||||
max_img_row_height = Settings().value('advanced/slide max height')
|
||||
if isinstance(max_img_row_height, int) and max_img_row_height > 0:
|
||||
if slide_height > max_img_row_height:
|
||||
if isinstance(max_img_row_height, int) and max_img_row_height != 0:
|
||||
if max_img_row_height > 0 and slide_height > max_img_row_height:
|
||||
# Manual Setting
|
||||
slide_height = max_img_row_height
|
||||
label.setMaximumWidth(max_img_row_height * self.screen_ratio)
|
||||
label.resize(max_img_row_height * self.screen_ratio, max_img_row_height)
|
||||
elif max_img_row_height < 0 and slide_height > self.auto_row_height:
|
||||
# Auto Setting
|
||||
slide_height = self.auto_row_height
|
||||
label.setMaximumWidth(slide_height * self.screen_ratio)
|
||||
label.resize(slide_height * self.screen_ratio, slide_height)
|
||||
# Build widget with stretch padding
|
||||
container = QtWidgets.QWidget()
|
||||
hbox = QtWidgets.QHBoxLayout()
|
||||
|
@ -164,7 +164,7 @@ class Highlighter(QtGui.QSyntaxHighlighter):
|
||||
"""
|
||||
Provides a text highlighter for pointing out spelling errors in text.
|
||||
"""
|
||||
WORDS = '(?iu)[\w\']+'
|
||||
WORDS = r'(?iu)[\w\']+'
|
||||
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import html
|
||||
import logging
|
||||
import os
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtOpenGL, QtGui, QtMultimedia
|
||||
from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtGui, QtMultimedia
|
||||
|
||||
from openlp.core.common import AppLocation, Registry, RegistryProperties, OpenLPMixin, Settings, translate,\
|
||||
is_macosx, is_win
|
||||
@ -468,9 +468,9 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
||||
self.service_item.theme_data.background_filename, ImageSource.Theme)
|
||||
if image_path:
|
||||
image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin)
|
||||
html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes,
|
||||
plugins=self.plugin_manager.plugins)
|
||||
self.web_view.setHtml(html)
|
||||
created_html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes,
|
||||
plugins=self.plugin_manager.plugins)
|
||||
self.web_view.setHtml(created_html)
|
||||
if service_item.foot_text:
|
||||
self.footer(service_item.foot_text)
|
||||
# if was hidden keep it hidden
|
||||
|
@ -44,11 +44,12 @@ from openlp.core.lib.ui import UiStrings, create_action
|
||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, LiveController, PluginForm, \
|
||||
ShortcutListForm, FormattingTagForm, PreviewController
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
from openlp.core.ui.lib.dockwidget import OpenLPDockWidget
|
||||
from openlp.core.ui.lib.mediadockmanager import MediaDockManager
|
||||
from openlp.core.ui.media import MediaController
|
||||
from openlp.core.ui.printserviceform import PrintServiceForm
|
||||
from openlp.core.ui.projector.manager import ProjectorManager
|
||||
from openlp.core.ui.lib.dockwidget import OpenLPDockWidget
|
||||
from openlp.core.ui.lib.mediadockmanager import MediaDockManager
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -24,10 +24,10 @@ The :mod:`~openlp.core.ui.media` module contains classes and objects for media p
|
||||
"""
|
||||
import logging
|
||||
|
||||
from openlp.core.common import Settings
|
||||
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from openlp.core.common import Settings
|
||||
|
||||
log = logging.getLogger(__name__ + '.__init__')
|
||||
|
||||
|
||||
|
@ -174,7 +174,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
log.debug('_check_available_media_players')
|
||||
controller_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'core', 'ui', 'media')
|
||||
for filename in os.listdir(controller_dir):
|
||||
if filename.endswith('player.py') and not filename == 'mediaplayer.py':
|
||||
if filename.endswith('player.py') and filename != 'mediaplayer.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
module_name = 'openlp.core.ui.media.' + os.path.splitext(filename)[0]
|
||||
@ -553,7 +553,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
default_player = [used_players[0]]
|
||||
if service_item.processor and service_item.processor != UiStrings().Automatic:
|
||||
# check to see if the player is usable else use the default one.
|
||||
if not service_item.processor.lower() in used_players:
|
||||
if service_item.processor.lower() not in used_players:
|
||||
used_players = default_player
|
||||
else:
|
||||
used_players = [service_item.processor.lower()]
|
||||
|
@ -224,9 +224,11 @@ class PlayerTab(SettingsTab):
|
||||
self.settings_form.register_post_process('mediaitem_media_rebuild')
|
||||
self.settings_form.register_post_process('config_screen_changed')
|
||||
|
||||
def post_set_up(self):
|
||||
def post_set_up(self, post_update=False):
|
||||
"""
|
||||
Late setup for players as the MediaController has to be initialised first.
|
||||
|
||||
:param post_update: Indicates if called before or after updates.
|
||||
"""
|
||||
for key, player in self.media_players.items():
|
||||
player = self.media_players[key]
|
||||
|
@ -112,7 +112,6 @@ def get_vlc():
|
||||
# This needs to happen on module load and not in get_vlc(), otherwise it can cause crashes on some DE on some setups
|
||||
# (reported on Gnome3, Unity, Cinnamon, all GTK+ based) when using native filedialogs...
|
||||
if is_linux() and 'nose' not in sys.argv[0] and get_vlc():
|
||||
import ctypes
|
||||
try:
|
||||
try:
|
||||
x11 = ctypes.cdll.LoadLibrary('libX11.so.6')
|
||||
@ -233,7 +232,7 @@ class VlcPlayer(MediaPlayer):
|
||||
"""
|
||||
vlc = get_vlc()
|
||||
start = datetime.now()
|
||||
while not media_state == display.vlc_media.get_state():
|
||||
while media_state != display.vlc_media.get_state():
|
||||
if display.vlc_media.get_state() == vlc.State.Error:
|
||||
return False
|
||||
self.application.process_events()
|
||||
|
@ -22,10 +22,10 @@
|
||||
"""
|
||||
The :mod:`~openlp.core.ui.media.webkit` module contains our WebKit video player
|
||||
"""
|
||||
from PyQt5 import QtGui, QtWebKitWidgets
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5 import QtGui, QtWebKitWidgets
|
||||
|
||||
from openlp.core.common import Settings
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.ui.media import MediaState
|
||||
|
@ -141,23 +141,23 @@ def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
|
||||
return widget, button_count, buttonchecked
|
||||
|
||||
|
||||
def set_button_tooltip(bar):
|
||||
def set_button_tooltip(button_bar):
|
||||
"""
|
||||
Set the toolip for the standard buttons used
|
||||
|
||||
:param bar: QDialogButtonBar instance to update
|
||||
:param button_bar: QDialogButtonBar instance to update
|
||||
"""
|
||||
for button in bar.buttons():
|
||||
if bar.standardButton(button) == QDialogButtonBox.Cancel:
|
||||
for button in button_bar.buttons():
|
||||
if button_bar.standardButton(button) == QDialogButtonBox.Cancel:
|
||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||
'Ignoring current changes and return to OpenLP'))
|
||||
elif bar.standardButton(button) == QDialogButtonBox.Reset:
|
||||
elif button_bar.standardButton(button) == QDialogButtonBox.Reset:
|
||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||
'Delete all user-defined text and revert to PJLink default text'))
|
||||
elif bar.standardButton(button) == QDialogButtonBox.Discard:
|
||||
elif button_bar.standardButton(button) == QDialogButtonBox.Discard:
|
||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||
'Discard changes and reset to previous user-defined text'))
|
||||
elif bar.standardButton(button) == QDialogButtonBox.Ok:
|
||||
elif button_bar.standardButton(button) == QDialogButtonBox.Ok:
|
||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||
'Save changes and return to OpenLP'))
|
||||
else:
|
||||
|
@ -133,7 +133,7 @@ class ProjectorTab(SettingsTab):
|
||||
settings.setValue('socket timeout', self.socket_timeout_spin_box.value())
|
||||
settings.setValue('poll time', self.socket_poll_spin_box.value())
|
||||
settings.setValue('source dialog type', self.dialog_type_combo_box.currentIndex())
|
||||
settings.endGroup
|
||||
settings.endGroup()
|
||||
|
||||
def on_dialog_type_combo_box_changed(self):
|
||||
self.dialog_type = self.dialog_type_combo_box.currentIndex()
|
||||
|
@ -480,9 +480,10 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
:return: service array
|
||||
"""
|
||||
service = []
|
||||
core = {'lite-service': self._save_lite,
|
||||
'service-theme': self.service_theme
|
||||
}
|
||||
core = {
|
||||
'lite-service': self._save_lite,
|
||||
'service-theme': self.service_theme
|
||||
}
|
||||
service.append({'openlp_core': core})
|
||||
return service
|
||||
|
||||
@ -597,7 +598,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
if success:
|
||||
try:
|
||||
shutil.copy(temp_file_name, path_file_name)
|
||||
except shutil.Error:
|
||||
except (shutil.Error, PermissionError):
|
||||
return self.save_file_as()
|
||||
except OSError as ose:
|
||||
QtWidgets.QMessageBox.critical(self, translate('OpenLP.ServiceManager', 'Error Saving File'),
|
||||
@ -658,7 +659,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
if success:
|
||||
try:
|
||||
shutil.copy(temp_file_name, path_file_name)
|
||||
except shutil.Error:
|
||||
except (shutil.Error, PermissionError):
|
||||
return self.save_file_as()
|
||||
self.main_window.add_recent_file(path_file_name)
|
||||
self.set_modified(False)
|
||||
@ -774,7 +775,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
else:
|
||||
critical_error_message_box(message=translate('OpenLP.ServiceManager', 'File is not a valid service.'))
|
||||
self.log_error('File contains no service data')
|
||||
except (IOError, NameError, zipfile.BadZipfile):
|
||||
except (IOError, NameError):
|
||||
self.log_exception('Problem loading service file {name}'.format(name=file_name))
|
||||
critical_error_message_box(message=translate('OpenLP.ServiceManager',
|
||||
'File could not be opened because it is corrupt.'))
|
||||
@ -1327,7 +1328,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
"""
|
||||
The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
|
||||
"""
|
||||
visible = not self.renderer.theme_level == ThemeLevel.Global
|
||||
visible = self.renderer.theme_level != ThemeLevel.Global
|
||||
self.toolbar.actions['theme_combo_box'].setVisible(visible)
|
||||
self.toolbar.actions['theme_label'].setVisible(visible)
|
||||
self.regenerate_service_items()
|
||||
|
@ -37,7 +37,6 @@ from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceI
|
||||
build_html
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.ui.lib.toolbar import OpenLPToolbar
|
||||
from openlp.core.ui.lib.dockwidget import OpenLPDockWidget
|
||||
from openlp.core.ui.lib.listpreviewwidget import ListPreviewWidget
|
||||
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
|
||||
|
||||
|
@ -249,7 +249,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
||||
NOTE the font_main_override is the inverse of the check box value
|
||||
"""
|
||||
if self.update_theme_allowed:
|
||||
self.theme.font_main_override = not (value == QtCore.Qt.Checked)
|
||||
self.theme.font_main_override = (value != QtCore.Qt.Checked)
|
||||
|
||||
def on_footer_position_check_box_state_changed(self, value):
|
||||
"""
|
||||
@ -257,7 +257,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
||||
NOTE the font_footer_override is the inverse of the check box value
|
||||
"""
|
||||
if self.update_theme_allowed:
|
||||
self.theme.font_footer_override = not (value == QtCore.Qt.Checked)
|
||||
self.theme.font_footer_override = (value != QtCore.Qt.Checked)
|
||||
|
||||
def exec(self, edit=False):
|
||||
"""
|
||||
|
@ -583,7 +583,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
|
||||
out_file.write(theme_zip.read(name))
|
||||
out_file.close()
|
||||
except (IOError, zipfile.BadZipfile):
|
||||
self.log_exception('Importing theme from zip failed {name|'.format(name=file_name))
|
||||
self.log_exception('Importing theme from zip failed {name}'.format(name=file_name))
|
||||
raise ValidationError
|
||||
except ValidationError:
|
||||
critical_error_message_box(translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||
|
@ -104,7 +104,7 @@ class Ui_EditBibleDialog(object):
|
||||
for book in BiblesResourcesDB.get_books():
|
||||
self.book_name_label[book['abbreviation']] = QtWidgets.QLabel(self.book_name_widget)
|
||||
self.book_name_label[book['abbreviation']].setObjectName(
|
||||
'book_name_label[{name}]'.format(book=book['abbreviation']))
|
||||
'book_name_label[{book}]'.format(book=book['abbreviation']))
|
||||
self.book_name_edit[book['abbreviation']] = QtWidgets.QLineEdit(self.book_name_widget)
|
||||
self.book_name_edit[book['abbreviation']].setObjectName(
|
||||
'book_name_edit[{name}]'.format(name=book['abbreviation']))
|
||||
|
@ -370,7 +370,7 @@ class BibleManager(RegistryProperties):
|
||||
"""
|
||||
log.debug('save_meta data {bible}, {version}, {copyright}, {perms}'.format(bible=bible,
|
||||
version=version,
|
||||
cr=copyright,
|
||||
copyright=copyright,
|
||||
perms=permissions))
|
||||
self.db_cache[bible].save_meta('name', version)
|
||||
self.db_cache[bible].save_meta('copyright', copyright)
|
||||
|
@ -117,7 +117,7 @@ class OpenSongBible(BibleDB):
|
||||
if len(verse_parts) > 1:
|
||||
number = int(verse_parts[0])
|
||||
except TypeError:
|
||||
log.warning('Illegal verse number: {verse:d}'.format(verse.attrib['n']))
|
||||
log.warning('Illegal verse number: {verse:d}'.format(verse=verse.attrib['n']))
|
||||
verse_number = number
|
||||
else:
|
||||
verse_number += 1
|
||||
|
@ -126,8 +126,6 @@ class OSISBible(BibleDB):
|
||||
# Remove div-tags in the book
|
||||
etree.strip_tags(book, ('{http://www.bibletechnologies.net/2003/OSIS/namespace}div'))
|
||||
book_ref_id = self.get_book_ref_id_by_name(book.get('osisID'), num_books, language_id)
|
||||
if not book_ref_id:
|
||||
book_ref_id = self.get_book_ref_id_by_localised_name(book.get('osisID'))
|
||||
if not book_ref_id:
|
||||
log.error('Importing books from "{name}" failed'.format(name=self.filename))
|
||||
return False
|
||||
|
@ -86,8 +86,6 @@ class ZefaniaBible(BibleDB):
|
||||
continue
|
||||
if bname:
|
||||
book_ref_id = self.get_book_ref_id_by_name(bname, num_books, language_id)
|
||||
if not book_ref_id:
|
||||
book_ref_id = self.get_book_ref_id_by_localised_name(bname)
|
||||
else:
|
||||
log.debug('Could not find a name, will use number, basically a guess.')
|
||||
book_ref_id = int(bnumber)
|
||||
|
@ -28,7 +28,7 @@ from PyQt5 import QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.ui import HideMode
|
||||
from openlp.core.lib import ServiceItemContext, ServiceItem
|
||||
from openlp.core.lib import ServiceItemContext
|
||||
from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -80,7 +80,7 @@ class PdfController(PresentationController):
|
||||
found_mutool = re.search('usage: mutool.*', decoded_line, re.IGNORECASE)
|
||||
if found_mutool:
|
||||
# Test that mutool contains mudraw
|
||||
if re.search('draw\s+--\s+convert document.*', runlog.decode(), re.IGNORECASE | re.MULTILINE):
|
||||
if re.search(r'draw\s+--\s+convert document.*', runlog.decode(), re.IGNORECASE | re.MULTILINE):
|
||||
program_type = 'mutool'
|
||||
break
|
||||
found_gs = re.search('GPL Ghostscript.*', decoded_line, re.IGNORECASE)
|
||||
@ -215,8 +215,8 @@ class PdfDocument(PresentationDocument):
|
||||
height = 0.0
|
||||
for line in runlog.splitlines():
|
||||
try:
|
||||
width = float(re.search('.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
|
||||
height = float(re.search('.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
|
||||
width = float(re.search(r'.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
|
||||
height = float(re.search(r'.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
|
||||
break
|
||||
except AttributeError:
|
||||
continue
|
||||
|
@ -362,7 +362,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
# it is the powerpoint presentation window.
|
||||
(left, top, right, bottom) = win32gui.GetWindowRect(hwnd)
|
||||
window_title = win32gui.GetWindowText(hwnd)
|
||||
log.debug('window size: left=left:d}, top={top:d}, '
|
||||
log.debug('window size: left={left:d}, top={top:d}, '
|
||||
'right={right:d}, bottom={bottom:d}'.format(left=left, top=top, right=right, bottom=bottom))
|
||||
log.debug('compare size: {y:d} and {top:d}, {height:d} and {vertical:d}, '
|
||||
'{x:d} and {left}, {width:d} and {horizontal:d}'.format(y=size.y(),
|
||||
|
@ -181,13 +181,13 @@ class PptviewDocument(PresentationDocument):
|
||||
index = -1
|
||||
list_to_add = None
|
||||
# check if it is a slide
|
||||
match = re.search("slides/slide(.+)\.xml", zip_info.filename)
|
||||
match = re.search(r'slides/slide(.+)\.xml', zip_info.filename)
|
||||
if match:
|
||||
index = int(match.group(1)) - 1
|
||||
node_type = 'ctrTitle'
|
||||
list_to_add = titles
|
||||
# or a note
|
||||
match = re.search("notesSlides/notesSlide(.+)\.xml", zip_info.filename)
|
||||
match = re.search(r'notesSlides/notesSlide(.+)\.xml', zip_info.filename)
|
||||
if match:
|
||||
index = int(match.group(1)) - 1
|
||||
node_type = 'body'
|
||||
|
@ -124,7 +124,7 @@ class PresentationPlugin(Plugin):
|
||||
log.debug('check_pre_conditions')
|
||||
controller_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), 'presentations', 'lib')
|
||||
for filename in os.listdir(controller_dir):
|
||||
if filename.endswith('controller.py') and not filename == 'presentationcontroller.py':
|
||||
if filename.endswith('controller.py') and filename != 'presentationcontroller.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
module_name = 'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
|
||||
|
@ -255,6 +255,7 @@ class CCLIFileImport(SongImport):
|
||||
song_author = ''
|
||||
verse_start = False
|
||||
for line in text_list:
|
||||
verse_type = 'v'
|
||||
clean_line = line.strip()
|
||||
if not clean_line:
|
||||
if line_number == 0:
|
||||
|
@ -124,8 +124,8 @@ class DreamBeamImport(SongImport):
|
||||
if hasattr(song_xml, 'Sequence'):
|
||||
for lyrics_sequence_item in (song_xml.Sequence.iterchildren()):
|
||||
item = lyrics_sequence_item.get('Type')[:1]
|
||||
self.verse_order_list.append("{item}{number}".format(item=item),
|
||||
lyrics_sequence_item.get('Number'))
|
||||
number = lyrics_sequence_item.get('Number')
|
||||
self.verse_order_list.append("{item}{number}".format(item=item, number=number))
|
||||
if hasattr(song_xml, 'Notes'):
|
||||
self.comments = str(song_xml.Notes.text)
|
||||
else:
|
||||
|
@ -27,6 +27,7 @@ import os
|
||||
import struct
|
||||
import re
|
||||
import zlib
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
@ -38,6 +39,8 @@ SLIDE_BREAK_REGEX = re.compile(r'\n *?\n[\n ]*')
|
||||
NUMBER_REGEX = re.compile(r'[0-9]+')
|
||||
NOTE_REGEX = re.compile(r'\(.*?\)')
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FieldDescEntry:
|
||||
def __init__(self, name, field_type, size):
|
||||
|
@ -24,15 +24,17 @@ The :mod:`mediashout` module provides the functionality for importing
|
||||
a MediaShout database into the OpenLP database.
|
||||
"""
|
||||
|
||||
# WARNING: See https://docs.python.org/2/library/sqlite3.html for value substitution
|
||||
# WARNING: See https://docs.python.org/3/library/sqlite3.html for value substitution
|
||||
# in SQL statements
|
||||
|
||||
import pyodbc
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
VERSE_TAGS = ['V', 'C', 'B', 'O', 'P', 'I', 'E']
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MediaShoutImport(SongImport):
|
||||
@ -44,17 +46,18 @@ class MediaShoutImport(SongImport):
|
||||
"""
|
||||
Initialise the MediaShout importer.
|
||||
"""
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
super(MediaShoutImport, self).__init__(manager, **kwargs)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
Receive a single file to import.
|
||||
"""
|
||||
try:
|
||||
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ={source};'
|
||||
'PWD=6NOZ4eHK7k'.format(sorce=self.import_source))
|
||||
except:
|
||||
conn = pyodbc.connect('DRIVER={{Microsoft Access Driver (*.mdb)}};DBQ={source};'
|
||||
'PWD=6NOZ4eHK7k'.format(source=self.import_source))
|
||||
except Exception as e:
|
||||
# Unfortunately no specific exception type
|
||||
log.exception(e)
|
||||
self.log_error(self.import_source, translate('SongsPlugin.MediaShoutImport',
|
||||
'Unable to open the MediaShout database.'))
|
||||
return
|
||||
@ -63,17 +66,21 @@ class MediaShoutImport(SongImport):
|
||||
songs = cursor.fetchall()
|
||||
self.import_wizard.progress_bar.setMaximum(len(songs))
|
||||
for song in songs:
|
||||
topics = []
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
cursor.execute('SELECT Type, Number, Text FROM Verses WHERE Record = ? ORDER BY Type, Number', song.Record)
|
||||
cursor.execute('SELECT Type, Number, Text FROM Verses WHERE Record = ? ORDER BY Type, Number',
|
||||
float(song.Record))
|
||||
verses = cursor.fetchall()
|
||||
cursor.execute('SELECT Type, Number, POrder FROM PlayOrder WHERE Record = ? ORDER BY POrder', song.Record)
|
||||
cursor.execute('SELECT Type, Number, POrder FROM PlayOrder WHERE Record = ? ORDER BY POrder',
|
||||
float(song.Record))
|
||||
verse_order = cursor.fetchall()
|
||||
cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
|
||||
'WHERE SongThemes.Record = ?', song.Record)
|
||||
topics = cursor.fetchall()
|
||||
if cursor.tables(table='TableName', tableType='TABLE').fetchone():
|
||||
cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
|
||||
'WHERE SongThemes.Record = ?', float(song.Record))
|
||||
topics = cursor.fetchall()
|
||||
cursor.execute('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId '
|
||||
'WHERE SongGroups.Record = ?', song.Record)
|
||||
'WHERE SongGroups.Record = ?', float(song.Record))
|
||||
topics += cursor.fetchall()
|
||||
self.process_song(song, verses, verse_order, topics)
|
||||
|
||||
|
@ -67,7 +67,7 @@ class OpenLyricsImport(SongImport):
|
||||
xml = etree.tostring(parsed_file).decode()
|
||||
self.open_lyrics.xml_to_song(xml)
|
||||
except etree.XMLSyntaxError:
|
||||
log.exception('XML syntax error in file {path}'.format(file_path))
|
||||
log.exception('XML syntax error in file {path}'.format(path=file_path))
|
||||
self.log_error(file_path, SongStrings.XMLSyntaxError)
|
||||
except OpenLyricsError as exception:
|
||||
log.exception('OpenLyricsException {error:d} in file {name}: {text}'.format(error=exception.type,
|
||||
|
@ -156,8 +156,8 @@ class OpenSongImport(SongImport):
|
||||
ustring = str(root.__getattr__(attr))
|
||||
if isinstance(fn_or_string, str):
|
||||
if attr in ['ccli']:
|
||||
ustring = ''.join(re.findall('\d+', ustring))
|
||||
if ustring:
|
||||
ustring = ''.join(re.findall('\d+', ustring))
|
||||
setattr(self, fn_or_string, int(ustring))
|
||||
else:
|
||||
setattr(self, fn_or_string, None)
|
||||
|
@ -55,7 +55,7 @@ class OPSProImport(SongImport):
|
||||
"""
|
||||
password = self.extract_mdb_password()
|
||||
try:
|
||||
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ={source};'
|
||||
conn = pyodbc.connect('DRIVER={{Microsoft Access Driver (*.mdb)}};DBQ={source};'
|
||||
'PWD={password}'.format(source=self.import_source, password=password))
|
||||
except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e:
|
||||
log.warning('Unable to connect the OPS Pro database {source}. {error}'.format(source=self.import_source,
|
||||
@ -74,11 +74,11 @@ class OPSProImport(SongImport):
|
||||
break
|
||||
# Type means: 0=Original, 1=Projection, 2=Own
|
||||
cursor.execute('SELECT Lyrics, Type, IsDualLanguage FROM Lyrics WHERE SongID = ? AND Type < 2 '
|
||||
'ORDER BY Type DESC', song.ID)
|
||||
'ORDER BY Type DESC', float(song.ID))
|
||||
lyrics = cursor.fetchone()
|
||||
cursor.execute('SELECT CategoryName FROM Category INNER JOIN SongCategory '
|
||||
'ON Category.ID = SongCategory.CategoryID WHERE SongCategory.SongID = ? '
|
||||
'ORDER BY CategoryName', song.ID)
|
||||
'ORDER BY CategoryName', float(song.ID))
|
||||
topics = cursor.fetchall()
|
||||
try:
|
||||
self.process_song(song, lyrics, topics)
|
||||
|
@ -30,6 +30,7 @@ import re
|
||||
import chardet
|
||||
from lxml import objectify, etree
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.core.ui.lib.wizard import WizardStrings
|
||||
from .songimport import SongImport
|
||||
|
||||
@ -56,7 +57,13 @@ class PresentationManagerImport(SongImport):
|
||||
# Open file with detected encoding and remove encoding declaration
|
||||
text = open(file_path, mode='r', encoding=encoding).read()
|
||||
text = re.sub('.+\?>\n', '', text)
|
||||
tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
|
||||
try:
|
||||
tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
|
||||
except ValueError:
|
||||
self.log_error(file_path,
|
||||
translate('SongsPlugin.PresentationManagerImport',
|
||||
'File is not in XML-format, which is the only format supported.'))
|
||||
continue
|
||||
root = objectify.fromstring(etree.tostring(tree))
|
||||
self.process_song(root)
|
||||
|
||||
|
@ -72,7 +72,7 @@ class SongProImport(SongImport):
|
||||
Receive a single file or a list of files to import.
|
||||
"""
|
||||
self.encoding = None
|
||||
with open(self.import_source, 'rt') as songs_file:
|
||||
with open(self.import_source, 'rt', errors='ignore') as songs_file:
|
||||
self.import_wizard.progress_bar.setMaximum(0)
|
||||
tag = ''
|
||||
text = ''
|
||||
|
@ -106,6 +106,7 @@ class SongShowPlusImport(SongImport):
|
||||
song_data = open(file, 'rb')
|
||||
while True:
|
||||
block_key, = struct.unpack("I", song_data.read(4))
|
||||
log.debug('block_key: %d' % block_key)
|
||||
# The file ends with 4 NULL's
|
||||
if block_key == 0:
|
||||
break
|
||||
@ -117,7 +118,13 @@ class SongShowPlusImport(SongImport):
|
||||
null, verse_name_length, = struct.unpack("BB", song_data.read(2))
|
||||
verse_name = self.decode(song_data.read(verse_name_length))
|
||||
length_descriptor_size, = struct.unpack("B", song_data.read(1))
|
||||
log.debug(length_descriptor_size)
|
||||
log.debug('length_descriptor_size: %d' % length_descriptor_size)
|
||||
# In the case of song_numbers the number is in the data from the
|
||||
# current position to the next block starts
|
||||
if block_key == SONG_NUMBER:
|
||||
sn_bytes = song_data.read(length_descriptor_size - 1)
|
||||
self.song_number = int.from_bytes(sn_bytes, byteorder='little')
|
||||
continue
|
||||
# Detect if/how long the length descriptor is
|
||||
if length_descriptor_size == 12 or length_descriptor_size == 20:
|
||||
length_descriptor, = struct.unpack("I", song_data.read(4))
|
||||
@ -127,8 +134,9 @@ class SongShowPlusImport(SongImport):
|
||||
length_descriptor = 0
|
||||
else:
|
||||
length_descriptor, = struct.unpack("B", song_data.read(1))
|
||||
log.debug(length_descriptor_size)
|
||||
log.debug('length_descriptor: %d' % length_descriptor)
|
||||
data = song_data.read(length_descriptor)
|
||||
log.debug(data)
|
||||
if block_key == TITLE:
|
||||
self.title = self.decode(data)
|
||||
elif block_key == AUTHOR:
|
||||
@ -168,8 +176,6 @@ class SongShowPlusImport(SongImport):
|
||||
self.ssp_verse_order_list.append(verse_tag)
|
||||
elif block_key == SONG_BOOK:
|
||||
self.song_book_name = self.decode(data)
|
||||
elif block_key == SONG_NUMBER:
|
||||
self.song_number = ord(data)
|
||||
elif block_key == CUSTOM_VERSE:
|
||||
verse_tag = self.to_openlp_verse_tag(verse_name)
|
||||
self.add_verse(self.decode(data), verse_tag)
|
||||
|
@ -117,6 +117,4 @@ class VideoPsalmImport(SongImport):
|
||||
if not self.finish():
|
||||
self.log_error('Could not import {title}'.format(title=self.title))
|
||||
except Exception as e:
|
||||
self.log_error(translate('SongsPlugin.VideoPsalmImport', 'File {name}').format(name=file.name),
|
||||
translate('SongsPlugin.VideoPsalmImport', 'Error: {error}').format(error=e))
|
||||
song_file.close()
|
||||
self.log_error(song_file.name, translate('SongsPlugin.VideoPsalmImport', 'Error: {error}').format(error=e))
|
||||
|
@ -49,7 +49,7 @@ class WorshipCenterProImport(SongImport):
|
||||
Receive a single file to import.
|
||||
"""
|
||||
try:
|
||||
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};'
|
||||
conn = pyodbc.connect('DRIVER={{Microsoft Access Driver (*.mdb)}};'
|
||||
'DBQ={source}'.format(source=self.import_source))
|
||||
except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e:
|
||||
log.warning('Unable to connect the WorshipCenter Pro '
|
||||
|
379
pylintrc
Normal file
379
pylintrc
Normal file
@ -0,0 +1,379 @@
|
||||
[MASTER]
|
||||
|
||||
# Specify a configuration file.
|
||||
#rcfile=
|
||||
|
||||
# Python code to execute, usually for sys.path manipulation such as
|
||||
# pygtk.require().
|
||||
#init-hook=
|
||||
|
||||
# Add files or directories to the blacklist. They should be base names, not
|
||||
# paths.
|
||||
ignore=vlc.py
|
||||
|
||||
# Pickle collected data for later comparisons.
|
||||
persistent=yes
|
||||
|
||||
# List of plugins (as comma separated values of python modules names) to load,
|
||||
# usually to register additional checkers.
|
||||
load-plugins=
|
||||
|
||||
# Use multiple processes to speed up Pylint.
|
||||
#jobs=4
|
||||
|
||||
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||
# active Python interpreter and may run arbitrary code.
|
||||
unsafe-load-any-extension=no
|
||||
|
||||
# A comma-separated list of package or module names from where C extensions may
|
||||
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||
# run arbitrary code
|
||||
extension-pkg-whitelist=
|
||||
|
||||
# Allow optimization of some AST trees. This will activate a peephole AST
|
||||
# optimizer, which will apply various small optimizations. For instance, it can
|
||||
# be used to obtain the result of joining multiple strings with the addition
|
||||
# operator. Joining a lot of strings can lead to a maximum recursion error in
|
||||
# Pylint and this flag can prevent that. It has one side effect, the resulting
|
||||
# AST will be different than the one from reality.
|
||||
optimize-ast=no
|
||||
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||
confidence=
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
# multiple time. See also the "--disable" option for examples.
|
||||
#enable=
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s). You
|
||||
# can either give multiple identifiers separated by comma (,) or put this
|
||||
# option multiple times (only on the command line, not in the configuration
|
||||
# file where it should appear only once).You can also use "--disable=all" to
|
||||
# disable everything first and then reenable specific checks. For example, if
|
||||
# you want to run only the similarities checker, you can use "--disable=all
|
||||
# --enable=similarities". If you want to run only the classes checker, but have
|
||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||
# --disable=W"
|
||||
disable=reload-builtin,too-many-locals,no-name-in-module,hex-method,bad-builtin,old-raise-syntax,bad-continuation,reduce-builtin,unicode-builtin,unused-wildcard-import,apply-builtin,no-member,filter-builtin-not-iterating,execfile-builtin,import-star-module-level,input-builtin,duplicate-code,old-division,print-statement,cmp-method,fixme,no-absolute-import,cmp-builtin,no-self-use,too-many-nested-blocks,standarderror-builtin,long-builtin,raising-string,delslice-method,metaclass-assignment,coerce-builtin,old-octal-literal,basestring-builtin,xrange-builtin,line-too-long,suppressed-message,unused-variable,round-builtin,raw_input-builtin,too-many-instance-attributes,unused-argument,next-method-called,oct-method,attribute-defined-outside-init,too-many-public-methods,too-many-statements,logging-format-interpolation,map-builtin-not-iterating,buffer-builtin,parameter-unpacking,range-builtin-not-iterating,intern-builtin,wrong-import-position,coerce-method,useless-suppression,using-cmp-argument,dict-view-method,backtick,old-ne-operator,missing-docstring,setslice-method,access-member-before-definition,long-suffix,too-few-public-methods,file-builtin,zip-builtin-not-iterating,invalid-name,getslice-method,unpacking-in-except,too-many-arguments,dict-iter-method,unichr-builtin,too-many-lines,too-many-branches,wildcard-import,indexing-exception,nonzero-method
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Set the output format. Available formats are text, parseable, colorized, msvs
|
||||
# (visual studio) and html. You can also give a reporter class, eg
|
||||
# mypackage.mymodule.MyReporterClass.
|
||||
output-format=text
|
||||
|
||||
# Put messages in a separate file for each module / package specified on the
|
||||
# command line instead of printing them on stdout. Reports (if any) will be
|
||||
# written in a file name "pylint_global.[txt|html]".
|
||||
files-output=no
|
||||
|
||||
# Tells whether to display a full report or only the messages
|
||||
reports=no
|
||||
|
||||
# Python expression which should return a note less than 10 (10 is the highest
|
||||
# note). You have access to the variables errors warning, statement which
|
||||
# respectively contain the number of errors / warnings messages and the total
|
||||
# number of statements analyzed. This is used by the global evaluation report
|
||||
# (RP0004).
|
||||
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
||||
|
||||
# Template used to display messages. This is a python new-style format string
|
||||
# used to format the message information. See doc for all details
|
||||
#msg-template=
|
||||
|
||||
|
||||
[SPELLING]
|
||||
|
||||
# Spelling dictionary name. Available dictionaries: en_ZA (myspell), en_US
|
||||
# (myspell), en_GB (myspell), en_AU (myspell), da_DK (myspell), en (aspell),
|
||||
# en_CA (aspell).
|
||||
spelling-dict=
|
||||
|
||||
# List of comma separated words that should not be checked.
|
||||
spelling-ignore-words=
|
||||
|
||||
# A path to a file that contains private dictionary; one word per line.
|
||||
spelling-private-dict-file=
|
||||
|
||||
# Tells whether to store unknown words to indicated private dictionary in
|
||||
# --spelling-private-dict-file option instead of raising a message.
|
||||
spelling-store-unknown-words=no
|
||||
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
# Minimum lines number of a similarity.
|
||||
min-similarity-lines=4
|
||||
|
||||
# Ignore comments when computing similarities.
|
||||
ignore-comments=yes
|
||||
|
||||
# Ignore docstrings when computing similarities.
|
||||
ignore-docstrings=yes
|
||||
|
||||
# Ignore imports when computing similarities.
|
||||
ignore-imports=no
|
||||
|
||||
|
||||
[LOGGING]
|
||||
|
||||
# Logging modules to check that the string format arguments are in logging
|
||||
# function parameter format
|
||||
logging-modules=logging
|
||||
|
||||
|
||||
[BASIC]
|
||||
|
||||
# List of builtins function names that should not be used, separated by a comma
|
||||
bad-functions=map,filter
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
good-names=i,j,k,ex,Run,_
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma
|
||||
bad-names=foo,bar,baz,toto,tutu,tata
|
||||
|
||||
# Colon-delimited sets of names that determine each other's naming style when
|
||||
# the name regexes allow several styles.
|
||||
name-group=
|
||||
|
||||
# Include a hint for the correct naming format with invalid-name
|
||||
include-naming-hint=no
|
||||
|
||||
# Regular expression matching correct class attribute names
|
||||
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Naming hint for class attribute names
|
||||
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Regular expression matching correct attribute names
|
||||
attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for attribute names
|
||||
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct variable names
|
||||
variable-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for variable names
|
||||
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct argument names
|
||||
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for argument names
|
||||
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct function names
|
||||
function-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for function names
|
||||
function-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct method names
|
||||
method-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Naming hint for method names
|
||||
method-name-hint=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression matching correct class names
|
||||
class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
# Naming hint for class names
|
||||
class-name-hint=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
# Regular expression matching correct module names
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Naming hint for module names
|
||||
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Regular expression matching correct inline iteration names
|
||||
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Naming hint for inline iteration names
|
||||
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Regular expression matching correct constant names
|
||||
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Naming hint for constant names
|
||||
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Regular expression which should only match function or class names that do
|
||||
# not require a docstring.
|
||||
no-docstring-rgx=^_
|
||||
|
||||
# Minimum line length for functions/classes that require docstrings, shorter
|
||||
# ones are exempt.
|
||||
docstring-min-length=-1
|
||||
|
||||
|
||||
[ELIF]
|
||||
|
||||
# Maximum number of nested blocks for function / method body
|
||||
max-nested-blocks=5
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=100
|
||||
|
||||
# Regexp for a line that is allowed to be longer than the limit.
|
||||
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
|
||||
|
||||
# Allow the body of an if to be on the same line as the test if there is no
|
||||
# else.
|
||||
single-line-if-stmt=no
|
||||
|
||||
# List of optional constructs for which whitespace checking is disabled. `dict-
|
||||
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
|
||||
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
|
||||
# `empty-line` allows space-only lines.
|
||||
no-space-check=trailing-comma,dict-separator
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=1000
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
indent-string=' '
|
||||
|
||||
# Number of spaces of indent required inside a hanging or continued line.
|
||||
indent-after-paren=4
|
||||
|
||||
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||
expected-line-ending-format=
|
||||
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,XXX,TODO
|
||||
|
||||
|
||||
[VARIABLES]
|
||||
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=no
|
||||
|
||||
# A regular expression matching the name of dummy variables (i.e. expectedly
|
||||
# not used).
|
||||
dummy-variables-rgx=_$|dummy
|
||||
|
||||
# List of additional names supposed to be defined in builtins. Remember that
|
||||
# you should avoid to define new builtins when possible.
|
||||
additional-builtins=
|
||||
|
||||
# List of strings which can identify a callback function by name. A callback
|
||||
# name must start or end with one of those strings.
|
||||
callbacks=cb_,_cb
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||
ignore-mixin-members=yes
|
||||
|
||||
# List of module names for which member attributes should not be checked
|
||||
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||
# and thus existing member attributes cannot be deduced by static analysis. It
|
||||
# supports qualified module names, as well as Unix pattern matching.
|
||||
ignored-modules=
|
||||
|
||||
# List of classes names for which member attributes should not be checked
|
||||
# (useful for classes with attributes dynamically set). This supports can work
|
||||
# with qualified names.
|
||||
ignored-classes=
|
||||
|
||||
# List of members which are set dynamically and missed by pylint inference
|
||||
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||
# expressions are accepted.
|
||||
generated-members=
|
||||
|
||||
|
||||
[DESIGN]
|
||||
|
||||
# Maximum number of arguments for function / method
|
||||
max-args=5
|
||||
|
||||
# Argument names that match this expression will be ignored. Default to name
|
||||
# with leading underscore
|
||||
ignored-argument-names=_.*
|
||||
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals=15
|
||||
|
||||
# Maximum number of return / yield for function / method body
|
||||
max-returns=6
|
||||
|
||||
# Maximum number of branch for function / method body
|
||||
max-branches=12
|
||||
|
||||
# Maximum number of statements in function / method body
|
||||
max-statements=50
|
||||
|
||||
# Maximum number of parents for a class (see R0901).
|
||||
max-parents=7
|
||||
|
||||
# Maximum number of attributes for a class (see R0902).
|
||||
max-attributes=7
|
||||
|
||||
# Minimum number of public methods for a class (see R0903).
|
||||
min-public-methods=2
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
||||
# Maximum number of boolean expressions in a if statement
|
||||
max-bool-expr=5
|
||||
|
||||
|
||||
[IMPORTS]
|
||||
|
||||
# Deprecated modules which should not be used, separated by a comma
|
||||
deprecated-modules=optparse
|
||||
|
||||
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||
# given file (report RP0402 must not be disabled)
|
||||
import-graph=
|
||||
|
||||
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
ext-import-graph=
|
||||
|
||||
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
int-import-graph=
|
||||
|
||||
|
||||
[CLASSES]
|
||||
|
||||
# List of method names used to declare (i.e. assign) instance attributes.
|
||||
defining-attr-methods=__init__,__new__,setUp
|
||||
|
||||
# List of valid names for the first argument in a class method.
|
||||
valid-classmethod-first-arg=cls
|
||||
|
||||
# List of valid names for the first argument in a metaclass class method.
|
||||
valid-metaclass-classmethod-first-arg=mcs
|
||||
|
||||
# List of member names, which should be excluded from the protected access
|
||||
# warning.
|
||||
exclude-protected=_asdict,_fields,_replace,_source,_make
|
||||
|
||||
|
||||
[EXCEPTIONS]
|
||||
|
||||
# Exceptions that will emit a warning when being caught. Defaults to
|
||||
# "Exception"
|
||||
overgeneral-exceptions=Exception
|
@ -29,7 +29,7 @@ from tests.helpers.testmixin import TestMixin
|
||||
|
||||
class TestInitFunctions(TestMixin, TestCase):
|
||||
|
||||
def parse_options_basic_test(self):
|
||||
def test_parse_options_basic(self):
|
||||
"""
|
||||
Test the parse options process works
|
||||
|
||||
@ -46,7 +46,7 @@ class TestInitFunctions(TestMixin, TestCase):
|
||||
self.assertEquals(args.style, None, 'There are no style flags to be processed')
|
||||
self.assertEquals(args.rargs, [], 'The service file should be blank')
|
||||
|
||||
def parse_options_debug_test(self):
|
||||
def test_parse_options_debug(self):
|
||||
"""
|
||||
Test the parse options process works for debug only
|
||||
|
||||
@ -63,7 +63,7 @@ class TestInitFunctions(TestMixin, TestCase):
|
||||
self.assertEquals(args.style, None, 'There are no style flags to be processed')
|
||||
self.assertEquals(args.rargs, [], 'The service file should be blank')
|
||||
|
||||
def parse_options_debug_and_portable_test(self):
|
||||
def test_parse_options_debug_and_portable(self):
|
||||
"""
|
||||
Test the parse options process works for debug and portable
|
||||
|
||||
@ -80,7 +80,7 @@ class TestInitFunctions(TestMixin, TestCase):
|
||||
self.assertEquals(args.style, None, 'There are no style flags to be processed')
|
||||
self.assertEquals(args.rargs, [], 'The service file should be blank')
|
||||
|
||||
def parse_options_all_no_file_test(self):
|
||||
def test_parse_options_all_no_file(self):
|
||||
"""
|
||||
Test the parse options process works with two options
|
||||
|
||||
@ -97,7 +97,7 @@ class TestInitFunctions(TestMixin, TestCase):
|
||||
self.assertEquals(args.style, None, 'There are no style flags to be processed')
|
||||
self.assertEquals(args.rargs, [], 'The service file should be blank')
|
||||
|
||||
def parse_options_file_test(self):
|
||||
def test_parse_options_file(self):
|
||||
"""
|
||||
Test the parse options process works with a file
|
||||
|
||||
@ -114,7 +114,7 @@ class TestInitFunctions(TestMixin, TestCase):
|
||||
self.assertEquals(args.style, None, 'There are no style flags to be processed')
|
||||
self.assertEquals(args.rargs, 'dummy_temp', 'The service file should not be blank')
|
||||
|
||||
def parse_options_file_and_debug_test(self):
|
||||
def test_parse_options_file_and_debug(self):
|
||||
"""
|
||||
Test the parse options process works with a file
|
||||
|
||||
|
@ -49,7 +49,7 @@ class TestCategoryActionList(TestCase):
|
||||
"""
|
||||
del self.list
|
||||
|
||||
def contains_test(self):
|
||||
def test_contains(self):
|
||||
"""
|
||||
Test the __contains__() method
|
||||
"""
|
||||
@ -61,7 +61,7 @@ class TestCategoryActionList(TestCase):
|
||||
self.assertTrue(self.action1 in self.list)
|
||||
self.assertFalse(self.action2 in self.list)
|
||||
|
||||
def len_test(self):
|
||||
def test_len(self):
|
||||
"""
|
||||
Test the __len__ method
|
||||
"""
|
||||
@ -77,7 +77,7 @@ class TestCategoryActionList(TestCase):
|
||||
# THEN: Check the length.
|
||||
self.assertEqual(len(self.list), 1, "The length should be 1.")
|
||||
|
||||
def append_test(self):
|
||||
def test_append(self):
|
||||
"""
|
||||
Test the append() method
|
||||
"""
|
||||
@ -92,7 +92,7 @@ class TestCategoryActionList(TestCase):
|
||||
self.assertEqual(self.list.actions[0], (0, self.action1))
|
||||
self.assertEqual(self.list.actions[1], (1, self.action2))
|
||||
|
||||
def add_test(self):
|
||||
def test_add(self):
|
||||
"""
|
||||
Test the add() method
|
||||
"""
|
||||
@ -111,7 +111,7 @@ class TestCategoryActionList(TestCase):
|
||||
self.assertEqual(self.list.actions[0], (41, self.action2))
|
||||
self.assertEqual(self.list.actions[1], (42, self.action1))
|
||||
|
||||
def iterator_test(self):
|
||||
def test_iterator(self):
|
||||
"""
|
||||
Test the __iter__ and __next__ methods
|
||||
"""
|
||||
@ -126,7 +126,7 @@ class TestCategoryActionList(TestCase):
|
||||
self.assertIs(l[0], self.action1)
|
||||
self.assertIs(l[1], self.action2)
|
||||
|
||||
def remove_test(self):
|
||||
def test_remove(self):
|
||||
"""
|
||||
Test the remove() method
|
||||
"""
|
||||
|
@ -36,7 +36,7 @@ class TestAppLocation(TestCase):
|
||||
"""
|
||||
A test suite to test out various methods around the AppLocation class.
|
||||
"""
|
||||
def get_data_path_test(self):
|
||||
def test_get_data_path(self):
|
||||
"""
|
||||
Test the AppLocation.get_data_path() method
|
||||
"""
|
||||
@ -60,7 +60,7 @@ class TestAppLocation(TestCase):
|
||||
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"')
|
||||
|
||||
def get_data_path_with_custom_location_test(self):
|
||||
def test_get_data_path_with_custom_location(self):
|
||||
"""
|
||||
Test the AppLocation.get_data_path() method when a custom location is set in the settings
|
||||
"""
|
||||
@ -80,7 +80,7 @@ class TestAppLocation(TestCase):
|
||||
mocked_settings.value.assert_called_with('advanced/data path')
|
||||
self.assertEqual('custom/dir', data_path, 'Result should be "custom/dir"')
|
||||
|
||||
def get_files_no_section_no_extension_test(self):
|
||||
def test_get_files_no_section_no_extension(self):
|
||||
"""
|
||||
Test the AppLocation.get_files() method with no parameters passed.
|
||||
"""
|
||||
@ -96,7 +96,7 @@ class TestAppLocation(TestCase):
|
||||
# Then: check if the file lists are identical.
|
||||
self.assertListEqual(FILE_LIST, result, 'The file lists should be identical.')
|
||||
|
||||
def get_files_test(self):
|
||||
def test_get_files(self):
|
||||
"""
|
||||
Test the AppLocation.get_files() method with all parameters passed.
|
||||
"""
|
||||
@ -115,7 +115,7 @@ class TestAppLocation(TestCase):
|
||||
# Then: check if the file lists are identical.
|
||||
self.assertListEqual(['file5.mp3', 'file6.mp3'], result, 'The file lists should be identical.')
|
||||
|
||||
def get_section_data_path_test(self):
|
||||
def test_get_section_data_path(self):
|
||||
"""
|
||||
Test the AppLocation.get_section_data_path() method
|
||||
"""
|
||||
@ -132,7 +132,7 @@ class TestAppLocation(TestCase):
|
||||
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"')
|
||||
|
||||
def get_directory_for_app_dir_test(self):
|
||||
def test_get_directory_for_app_dir(self):
|
||||
"""
|
||||
Test the AppLocation.get_directory() method for AppLocation.AppDir
|
||||
"""
|
||||
@ -146,7 +146,7 @@ class TestAppLocation(TestCase):
|
||||
# THEN: check that the correct directory is returned
|
||||
self.assertEqual(os.path.join('app', 'dir'), directory, 'Directory should be "app/dir"')
|
||||
|
||||
def get_directory_for_plugins_dir_test(self):
|
||||
def test_get_directory_for_plugins_dir(self):
|
||||
"""
|
||||
Test the AppLocation.get_directory() method for AppLocation.PluginsDir
|
||||
"""
|
||||
@ -167,7 +167,7 @@ class TestAppLocation(TestCase):
|
||||
# THEN: The correct directory should be returned
|
||||
self.assertEqual(os.path.join('plugins', 'dir'), directory, 'Directory should be "plugins/dir"')
|
||||
|
||||
def get_frozen_path_in_unfrozen_app_test(self):
|
||||
def test_get_frozen_path_in_unfrozen_app(self):
|
||||
"""
|
||||
Test the _get_frozen_path() function when the application is not frozen (compiled by PyInstaller)
|
||||
"""
|
||||
@ -181,7 +181,7 @@ class TestAppLocation(TestCase):
|
||||
# THEN: The non-frozen parameter is returned
|
||||
self.assertEqual('not frozen', frozen_path, '_get_frozen_path should return "not frozen"')
|
||||
|
||||
def get_frozen_path_in_frozen_app_test(self):
|
||||
def test_get_frozen_path_in_frozen_app(self):
|
||||
"""
|
||||
Test the get_frozen_path() function when the application is frozen (compiled by PyInstaller)
|
||||
"""
|
||||
|
@ -34,7 +34,7 @@ class TestCommonFunctions(TestCase):
|
||||
"""
|
||||
A test suite to test out various functions in the openlp.core.common module.
|
||||
"""
|
||||
def check_directory_exists_test(self):
|
||||
def test_check_directory_exists(self):
|
||||
"""
|
||||
Test the check_directory_exists() function
|
||||
"""
|
||||
@ -73,7 +73,7 @@ class TestCommonFunctions(TestCase):
|
||||
mocked_exists.assert_called_with(directory_to_check)
|
||||
self.assertRaises(ValueError, check_directory_exists, directory_to_check)
|
||||
|
||||
def de_hump_conversion_test(self):
|
||||
def test_de_hump_conversion(self):
|
||||
"""
|
||||
Test the de_hump function with a class name
|
||||
"""
|
||||
@ -86,7 +86,7 @@ class TestCommonFunctions(TestCase):
|
||||
# THEN: the new string should be converted to python format
|
||||
self.assertTrue(new_string == "my_class", 'The class name should have been converted')
|
||||
|
||||
def de_hump_static_test(self):
|
||||
def test_de_hump_static(self):
|
||||
"""
|
||||
Test the de_hump function with a python string
|
||||
"""
|
||||
@ -99,7 +99,7 @@ class TestCommonFunctions(TestCase):
|
||||
# THEN: the new string should be converted to python format
|
||||
self.assertTrue(new_string == "my_class", 'The class name should have been preserved')
|
||||
|
||||
def trace_error_handler_test(self):
|
||||
def test_trace_error_handler(self):
|
||||
"""
|
||||
Test the trace_error_handler() method
|
||||
"""
|
||||
@ -115,7 +115,7 @@ class TestCommonFunctions(TestCase):
|
||||
mocked_logger.error.assert_called_with(
|
||||
'OpenLP Error trace\n File openlp.fake at line 56 \n\t called trace_error_handler_test')
|
||||
|
||||
def translate_test(self):
|
||||
def test_translate(self):
|
||||
"""
|
||||
Test the translate() function
|
||||
"""
|
||||
@ -132,7 +132,7 @@ class TestCommonFunctions(TestCase):
|
||||
mocked_translate.assert_called_with(context, text, comment)
|
||||
self.assertEqual('Translated string', result, 'The translated string should have been returned')
|
||||
|
||||
def is_win_test(self):
|
||||
def test_is_win(self):
|
||||
"""
|
||||
Test the is_win() function
|
||||
"""
|
||||
@ -148,7 +148,7 @@ class TestCommonFunctions(TestCase):
|
||||
self.assertFalse(is_macosx(), 'is_macosx() should return False')
|
||||
self.assertFalse(is_linux(), 'is_linux() should return False')
|
||||
|
||||
def is_macosx_test(self):
|
||||
def test_is_macosx(self):
|
||||
"""
|
||||
Test the is_macosx() function
|
||||
"""
|
||||
@ -164,7 +164,7 @@ class TestCommonFunctions(TestCase):
|
||||
self.assertFalse(is_win(), 'is_win() should return False')
|
||||
self.assertFalse(is_linux(), 'is_linux() should return False')
|
||||
|
||||
def is_linux_test(self):
|
||||
def test_is_linux(self):
|
||||
"""
|
||||
Test the is_linux() function
|
||||
"""
|
||||
@ -180,7 +180,7 @@ class TestCommonFunctions(TestCase):
|
||||
self.assertFalse(is_win(), 'is_win() should return False')
|
||||
self.assertFalse(is_macosx(), 'is_macosx() should return False')
|
||||
|
||||
def clean_button_text_test(self):
|
||||
def test_clean_button_text(self):
|
||||
"""
|
||||
Test the clean_button_text() function.
|
||||
"""
|
||||
|
@ -67,7 +67,7 @@ class TestUtilsDBFunctions(TestCase):
|
||||
time.sleep(1)
|
||||
retries += 1
|
||||
|
||||
def delete_column_test(self):
|
||||
def test_delete_column(self):
|
||||
"""
|
||||
Test deleting a single column in a table
|
||||
"""
|
||||
@ -85,7 +85,7 @@ class TestUtilsDBFunctions(TestCase):
|
||||
if column.name == 'song_book_id':
|
||||
self.fail("The column 'song_book_id' should have been deleted.")
|
||||
|
||||
def delete_columns_test(self):
|
||||
def test_delete_columns(self):
|
||||
"""
|
||||
Test deleting multiple columns in a table
|
||||
"""
|
||||
|
@ -48,7 +48,7 @@ class TestInit(TestCase, TestMixin):
|
||||
"""
|
||||
self.destroy_settings()
|
||||
|
||||
def add_actions_empty_list_test(self):
|
||||
def test_add_actions_empty_list(self):
|
||||
"""
|
||||
Test that no actions are added when the list is empty
|
||||
"""
|
||||
@ -63,7 +63,7 @@ class TestInit(TestCase, TestMixin):
|
||||
self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
|
||||
self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
|
||||
|
||||
def add_actions_none_action_test(self):
|
||||
def test_add_actions_none_action(self):
|
||||
"""
|
||||
Test that a separator is added when a None action is in the list
|
||||
"""
|
||||
@ -78,7 +78,7 @@ class TestInit(TestCase, TestMixin):
|
||||
mocked_target.addSeparator.assert_called_with()
|
||||
self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
|
||||
|
||||
def add_actions_add_action_test(self):
|
||||
def test_add_actions_add_action(self):
|
||||
"""
|
||||
Test that an action is added when a valid action is in the list
|
||||
"""
|
||||
@ -93,7 +93,7 @@ class TestInit(TestCase, TestMixin):
|
||||
self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
|
||||
mocked_target.addAction.assert_called_with('action')
|
||||
|
||||
def add_actions_action_and_none_test(self):
|
||||
def test_add_actions_action_and_none(self):
|
||||
"""
|
||||
Test that an action and a separator are added when a valid action and None are in the list
|
||||
"""
|
||||
@ -108,7 +108,7 @@ class TestInit(TestCase, TestMixin):
|
||||
mocked_target.addSeparator.assert_called_with()
|
||||
mocked_target.addAction.assert_called_with('action')
|
||||
|
||||
def get_uno_instance_pipe_test(self):
|
||||
def test_get_uno_instance_pipe(self):
|
||||
"""
|
||||
Test that when the UNO connection type is "pipe" the resolver is given the "pipe" URI
|
||||
"""
|
||||
@ -121,7 +121,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: the resolve method is called with the correct argument
|
||||
mock_resolver.resolve.assert_called_with('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext')
|
||||
|
||||
def get_uno_instance_socket_test(self):
|
||||
def test_get_uno_instance_socket(self):
|
||||
"""
|
||||
Test that when the UNO connection type is other than "pipe" the resolver is given the "socket" URI
|
||||
"""
|
||||
@ -134,7 +134,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: the resolve method is called with the correct argument
|
||||
mock_resolver.resolve.assert_called_with('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
|
||||
|
||||
def get_uno_command_libreoffice_command_exists_test(self):
|
||||
def test_get_uno_command_libreoffice_command_exists(self):
|
||||
"""
|
||||
Test the ``get_uno_command`` function uses the libreoffice command when available.
|
||||
:return:
|
||||
@ -151,7 +151,7 @@ class TestInit(TestCase, TestMixin):
|
||||
'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
|
||||
' "--accept=pipe,name=openlp_pipe;urp;"')
|
||||
|
||||
def get_uno_command_only_soffice_command_exists_test(self):
|
||||
def test_get_uno_command_only_soffice_command_exists(self):
|
||||
"""
|
||||
Test the ``get_uno_command`` function uses the soffice command when the libreoffice command is not available.
|
||||
:return:
|
||||
@ -169,7 +169,7 @@ class TestInit(TestCase, TestMixin):
|
||||
self.assertEquals(result, 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
|
||||
' "--accept=pipe,name=openlp_pipe;urp;"')
|
||||
|
||||
def get_uno_command_when_no_command_exists_test(self):
|
||||
def test_get_uno_command_when_no_command_exists(self):
|
||||
"""
|
||||
Test the ``get_uno_command`` function raises an FileNotFoundError when neither the libreoffice or soffice
|
||||
commands are available.
|
||||
@ -183,7 +183,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: a FileNotFoundError exception should be raised
|
||||
self.assertRaises(FileNotFoundError, get_uno_command)
|
||||
|
||||
def get_uno_command_connection_type_test(self):
|
||||
def test_get_uno_command_connection_type(self):
|
||||
"""
|
||||
Test the ``get_uno_command`` function when the connection type is anything other than pipe.
|
||||
:return:
|
||||
@ -198,7 +198,7 @@ class TestInit(TestCase, TestMixin):
|
||||
self.assertEqual(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
|
||||
' "--accept=socket,host=localhost,port=2002;urp;"')
|
||||
|
||||
def get_filesystem_encoding_sys_function_not_called_test(self):
|
||||
def test_get_filesystem_encoding_sys_function_not_called(self):
|
||||
"""
|
||||
Test the get_filesystem_encoding() function does not call the sys.getdefaultencoding() function
|
||||
"""
|
||||
@ -215,7 +215,7 @@ class TestInit(TestCase, TestMixin):
|
||||
self.assertEqual(0, mocked_getdefaultencoding.called, 'getdefaultencoding should not have been called')
|
||||
self.assertEqual('cp1252', result, 'The result should be "cp1252"')
|
||||
|
||||
def get_filesystem_encoding_sys_function_is_called_test(self):
|
||||
def test_get_filesystem_encoding_sys_function_is_called(self):
|
||||
"""
|
||||
Test the get_filesystem_encoding() function calls the sys.getdefaultencoding() function
|
||||
"""
|
||||
@ -233,7 +233,7 @@ class TestInit(TestCase, TestMixin):
|
||||
mocked_getdefaultencoding.assert_called_with()
|
||||
self.assertEqual('utf-8', result, 'The result should be "utf-8"')
|
||||
|
||||
def split_filename_with_file_path_test(self):
|
||||
def test_split_filename_with_file_path(self):
|
||||
"""
|
||||
Test the split_filename() function with a path to a file
|
||||
"""
|
||||
@ -253,7 +253,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: A tuple should be returned.
|
||||
self.assertEqual(wanted_result, result, 'A tuple with the dir and file name should have been returned')
|
||||
|
||||
def split_filename_with_dir_path_test(self):
|
||||
def test_split_filename_with_dir_path(self):
|
||||
"""
|
||||
Test the split_filename() function with a path to a directory
|
||||
"""
|
||||
@ -274,7 +274,7 @@ class TestInit(TestCase, TestMixin):
|
||||
self.assertEqual(wanted_result, result,
|
||||
'A two-entry tuple with the directory and file name (empty) should have been returned.')
|
||||
|
||||
def clean_filename_test(self):
|
||||
def test_clean_filename(self):
|
||||
"""
|
||||
Test the clean_filename() function
|
||||
"""
|
||||
@ -288,7 +288,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: The file name should be cleaned.
|
||||
self.assertEqual(wanted_name, result, 'The file name should not contain any special characters.')
|
||||
|
||||
def delete_file_no_path_test(self):
|
||||
def test_delete_file_no_path(self):
|
||||
"""
|
||||
Test the delete_file function when called with out a valid path
|
||||
"""
|
||||
@ -299,7 +299,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: delete_file should return False
|
||||
self.assertFalse(result, "delete_file should return False when called with ''")
|
||||
|
||||
def delete_file_path_success_test(self):
|
||||
def test_delete_file_path_success(self):
|
||||
"""
|
||||
Test the delete_file function when it successfully deletes a file
|
||||
"""
|
||||
@ -312,7 +312,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: delete_file should return True
|
||||
self.assertTrue(result, 'delete_file should return True when it successfully deletes a file')
|
||||
|
||||
def delete_file_path_no_file_exists_test(self):
|
||||
def test_delete_file_path_no_file_exists(self):
|
||||
"""
|
||||
Test the delete_file function when the file to remove does not exist
|
||||
"""
|
||||
@ -325,7 +325,7 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: delete_file should return True
|
||||
self.assertTrue(result, 'delete_file should return True when the file doesnt exist')
|
||||
|
||||
def delete_file_path_exception_test(self):
|
||||
def test_delete_file_path_exception(self):
|
||||
"""
|
||||
Test the delete_file function when os.remove raises an exception
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ class TestLanguageManager(TestCase):
|
||||
A test suite to test out various methods around the common __init__ class.
|
||||
"""
|
||||
|
||||
def get_locale_key_test(self):
|
||||
def test_get_locale_key(self):
|
||||
"""
|
||||
Test the get_locale_key(string) function
|
||||
"""
|
||||
@ -50,7 +50,7 @@ class TestLanguageManager(TestCase):
|
||||
self.assertEqual(['Aushang', '\u00C4u\u00DFerung', 'Auszug'], sorted_list,
|
||||
'Strings should be sorted properly')
|
||||
|
||||
def get_natural_key_test(self):
|
||||
def test_get_natural_key(self):
|
||||
"""
|
||||
Test the get_natural_key(string) function
|
||||
"""
|
||||
|
@ -124,7 +124,7 @@ class testProjectorUtilities(TestCase):
|
||||
Test MD5 hash from salt+data pass (python)
|
||||
"""
|
||||
# WHEN: Given a known salt+data
|
||||
hash_ = md5_hash(salt=salt.encode('ascii'), data=pin.encode('ascii'))
|
||||
hash_ = md5_hash(salt=salt.encode('utf-8'), data=pin.encode('utf-8'))
|
||||
|
||||
# THEN: Validate return has is same
|
||||
self.assertEquals(hash_, test_hash, 'MD5 should have returned a good hash')
|
||||
@ -134,7 +134,7 @@ class testProjectorUtilities(TestCase):
|
||||
Test MD5 hash from salt+data fail (python)
|
||||
"""
|
||||
# WHEN: Given a different salt+hash
|
||||
hash_ = md5_hash(salt=pin.encode('ascii'), data=salt.encode('ascii'))
|
||||
hash_ = md5_hash(salt=pin.encode('utf-8'), data=salt.encode('utf-8'))
|
||||
|
||||
# THEN: return data is different
|
||||
self.assertNotEquals(hash_, test_hash, 'MD5 should have returned a bad hash')
|
||||
@ -144,20 +144,20 @@ class testProjectorUtilities(TestCase):
|
||||
Test MD5 hash from salt+data pass (Qt)
|
||||
"""
|
||||
# WHEN: Given a known salt+data
|
||||
hash_ = qmd5_hash(salt=salt.encode('ascii'), data=pin.encode('ascii'))
|
||||
hash_ = qmd5_hash(salt=salt.encode('utf-8'), data=pin.encode('utf-8'))
|
||||
|
||||
# THEN: Validate return has is same
|
||||
self.assertEquals(hash_.decode('ascii'), test_hash, 'Qt-MD5 should have returned a good hash')
|
||||
self.assertEquals(hash_, test_hash, 'Qt-MD5 should have returned a good hash')
|
||||
|
||||
def test_qmd5_hash_bad(self):
|
||||
"""
|
||||
Test MD5 hash from salt+hash fail (Qt)
|
||||
"""
|
||||
# WHEN: Given a different salt+hash
|
||||
hash_ = qmd5_hash(salt=pin.encode('ascii'), data=salt.encode('ascii'))
|
||||
hash_ = qmd5_hash(salt=pin.encode('utf-8'), data=salt.encode('utf-8'))
|
||||
|
||||
# THEN: return data is different
|
||||
self.assertNotEquals(hash_.decode('ascii'), test_hash, 'Qt-MD5 should have returned a bad hash')
|
||||
self.assertNotEquals(hash_, test_hash, 'Qt-MD5 should have returned a bad hash')
|
||||
|
||||
def test_md5_non_ascii_string(self):
|
||||
"""
|
||||
@ -174,7 +174,7 @@ class testProjectorUtilities(TestCase):
|
||||
Test MD5 hash with non-ascii string - bug 1417809
|
||||
"""
|
||||
# WHEN: Non-ascii string is hashed
|
||||
hash_ = md5_hash(salt=test_non_ascii_string.encode('utf-8'), data=None)
|
||||
hash_ = md5_hash(data=test_non_ascii_string.encode('utf-8'))
|
||||
|
||||
# THEN: Valid MD5 hash should be returned
|
||||
self.assertEqual(hash_, test_non_ascii_hash, 'Qt-MD5 should have returned a valid hash')
|
||||
|
@ -33,7 +33,7 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..',
|
||||
|
||||
class TestRegistry(TestCase):
|
||||
|
||||
def registry_service_test(self):
|
||||
def test_registry_service(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
"""
|
||||
@ -65,7 +65,7 @@ class TestRegistry(TestCase):
|
||||
temp = Registry().get('test1')
|
||||
self.assertEqual(temp, None, 'None should have been returned for deleted service')
|
||||
|
||||
def registry_function_test(self):
|
||||
def test_registry_function(self):
|
||||
"""
|
||||
Test the registry function creation and their usages
|
||||
"""
|
||||
@ -93,7 +93,7 @@ class TestRegistry(TestCase):
|
||||
# THEN: I expect then function to have been called and a return given
|
||||
self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
|
||||
|
||||
def registry_working_flags_test(self):
|
||||
def test_registry_working_flags(self):
|
||||
"""
|
||||
Test the registry working flags creation and its usage
|
||||
"""
|
||||
@ -130,7 +130,7 @@ class TestRegistry(TestCase):
|
||||
self.assertEqual(context.exception.args[0], 'Working Flag test1 not found in list',
|
||||
'KeyError exception should have been thrown for duplicate working flag')
|
||||
|
||||
def remove_function_test(self):
|
||||
def test_remove_function(self):
|
||||
"""
|
||||
Test the remove_function() method
|
||||
"""
|
||||
|
@ -32,7 +32,7 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..',
|
||||
|
||||
class TestRegistryMixin(TestCase):
|
||||
|
||||
def registry_mixin_missing_test(self):
|
||||
def test_registry_mixin_missing(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
"""
|
||||
@ -45,7 +45,7 @@ class TestRegistryMixin(TestCase):
|
||||
# THEN: The following methods are missing
|
||||
self.assertEqual(len(Registry().functions_list), 0), 'The function should not be in the dict anymore.'
|
||||
|
||||
def registry_mixin_present_test(self):
|
||||
def test_registry_mixin_present(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
"""
|
||||
|
@ -39,7 +39,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
||||
"""
|
||||
Registry.create()
|
||||
|
||||
def no_application_test(self):
|
||||
def test_no_application(self):
|
||||
"""
|
||||
Test property if no registry value assigned
|
||||
"""
|
||||
@ -48,7 +48,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
||||
# THEN the application should be none
|
||||
self.assertEqual(self.application, None, 'The application value should be None')
|
||||
|
||||
def application_test(self):
|
||||
def test_application(self):
|
||||
"""
|
||||
Test property if registry value assigned
|
||||
"""
|
||||
@ -62,7 +62,7 @@ class TestRegistryProperties(TestCase, RegistryProperties):
|
||||
self.assertEqual(self.application, application, 'The application value should match')
|
||||
|
||||
@patch('openlp.core.common.registryproperties.is_win')
|
||||
def application_on_windows_test(self, mocked_is_win):
|
||||
def test_application_on_windows(self, mocked_is_win):
|
||||
"""
|
||||
Test property if registry value assigned on Windows
|
||||
"""
|
||||
|
@ -47,7 +47,7 @@ class TestSettings(TestCase, TestMixin):
|
||||
"""
|
||||
self.destroy_settings()
|
||||
|
||||
def recent_files_conv_test(self):
|
||||
def test_recent_files_conv(self):
|
||||
"""
|
||||
Test that recent_files_conv, converts various possible types of values correctly.
|
||||
"""
|
||||
@ -66,7 +66,7 @@ class TestSettings(TestCase, TestMixin):
|
||||
# THEN: The actual result should be the same as the expected result
|
||||
self.assertEqual(actual_result, expected_result)
|
||||
|
||||
def settings_basic_test(self):
|
||||
def test_settings_basic(self):
|
||||
"""
|
||||
Test the Settings creation and its default usage
|
||||
"""
|
||||
@ -84,7 +84,7 @@ class TestSettings(TestCase, TestMixin):
|
||||
# THEN the new value is returned when re-read
|
||||
self.assertTrue(Settings().value('core/has run wizard'), 'The saved value should have been returned')
|
||||
|
||||
def settings_override_test(self):
|
||||
def test_settings_override(self):
|
||||
"""
|
||||
Test the Settings creation and its override usage
|
||||
"""
|
||||
@ -106,7 +106,7 @@ class TestSettings(TestCase, TestMixin):
|
||||
# THEN the new value is returned when re-read
|
||||
self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
|
||||
|
||||
def settings_override_with_group_test(self):
|
||||
def test_settings_override_with_group(self):
|
||||
"""
|
||||
Test the Settings creation and its override usage - with groups
|
||||
"""
|
||||
@ -130,7 +130,7 @@ class TestSettings(TestCase, TestMixin):
|
||||
# THEN the new value is returned when re-read
|
||||
self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
|
||||
|
||||
def settings_nonexisting_test(self):
|
||||
def test_settings_nonexisting(self):
|
||||
"""
|
||||
Test the Settings on query for non-existing value
|
||||
"""
|
||||
@ -142,7 +142,7 @@ class TestSettings(TestCase, TestMixin):
|
||||
# THEN: An exception with the non-existing key should be thrown
|
||||
self.assertEqual(str(cm.exception), "'core/does not exists'", 'We should get an exception')
|
||||
|
||||
def extend_default_settings_test(self):
|
||||
def test_extend_default_settings(self):
|
||||
"""
|
||||
Test that the extend_default_settings method extends the default settings
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ from openlp.core.common import UiStrings
|
||||
|
||||
class TestUiStrings(TestCase):
|
||||
|
||||
def check_same_instance_test(self):
|
||||
def test_check_same_instance(self):
|
||||
"""
|
||||
Test the UiStrings class - we always should have only one instance of the UiStrings class.
|
||||
"""
|
||||
|
@ -44,7 +44,7 @@ class TestVersionchecker(TestMixin, TestCase):
|
||||
"""
|
||||
self.destroy_settings()
|
||||
|
||||
def version_thread_triggered_test(self):
|
||||
def test_version_thread_triggered(self):
|
||||
"""
|
||||
Test the version thread call does not trigger UI
|
||||
:return:
|
||||
|
@ -37,7 +37,7 @@ class TestDB(TestCase):
|
||||
"""
|
||||
A test case for all the tests for the :mod:`~openlp.core.lib.db` module.
|
||||
"""
|
||||
def init_db_calls_correct_functions_test(self):
|
||||
def test_init_db_calls_correct_functions(self):
|
||||
"""
|
||||
Test that the init_db function makes the correct function calls
|
||||
"""
|
||||
@ -67,7 +67,7 @@ class TestDB(TestCase):
|
||||
self.assertIs(session, mocked_scoped_session_object, 'The ``session`` object should be the mock')
|
||||
self.assertIs(metadata, mocked_metadata, 'The ``metadata`` object should be the mock')
|
||||
|
||||
def init_db_defaults_test(self):
|
||||
def test_init_db_defaults(self):
|
||||
"""
|
||||
Test that initialising an in-memory SQLite database via ``init_db`` uses the defaults
|
||||
"""
|
||||
@ -81,7 +81,7 @@ class TestDB(TestCase):
|
||||
self.assertIsInstance(session, ScopedSession, 'The ``session`` object should be a ``ScopedSession`` instance')
|
||||
self.assertIsInstance(metadata, MetaData, 'The ``metadata`` object should be a ``MetaData`` instance')
|
||||
|
||||
def get_upgrade_op_test(self):
|
||||
def test_get_upgrade_op(self):
|
||||
"""
|
||||
Test that the ``get_upgrade_op`` function creates a MigrationContext and an Operations object
|
||||
"""
|
||||
@ -105,7 +105,7 @@ class TestDB(TestCase):
|
||||
MockedMigrationContext.configure.assert_called_with(mocked_connection)
|
||||
MockedOperations.assert_called_with(mocked_context)
|
||||
|
||||
def delete_database_without_db_file_name_test(self):
|
||||
def test_delete_database_without_db_file_name(self):
|
||||
"""
|
||||
Test that the ``delete_database`` function removes a database file, without the file name parameter
|
||||
"""
|
||||
@ -125,7 +125,7 @@ class TestDB(TestCase):
|
||||
mocked_delete_file.assert_called_with(test_location)
|
||||
self.assertTrue(result, 'The result of delete_file should be True (was rigged that way)')
|
||||
|
||||
def delete_database_with_db_file_name_test(self):
|
||||
def test_delete_database_with_db_file_name(self):
|
||||
"""
|
||||
Test that the ``delete_database`` function removes a database file, with the file name supplied
|
||||
"""
|
||||
|
@ -26,7 +26,7 @@ class TestFileDialog(TestCase):
|
||||
self.qt_gui_patcher.stop()
|
||||
self.ui_strings_patcher.stop()
|
||||
|
||||
def get_open_file_names_canceled_test(self):
|
||||
def test_get_open_file_names_canceled(self):
|
||||
"""
|
||||
Test that FileDialog.getOpenFileNames() returns and empty QStringList when QFileDialog is canceled
|
||||
(returns an empty QStringList)
|
||||
@ -45,7 +45,7 @@ class TestFileDialog(TestCase):
|
||||
'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames '
|
||||
'is canceled')
|
||||
|
||||
def returned_file_list_test(self):
|
||||
def test_returned_file_list(self):
|
||||
"""
|
||||
Test that FileDialog.getOpenFileNames handles a list of files properly when QFileList.getOpenFileNames
|
||||
returns a good file name, a url encoded file name and a non-existing file
|
||||
|
@ -47,7 +47,7 @@ class TestFormattingTags(TestCase):
|
||||
"""
|
||||
FormattingTags.html_expands = []
|
||||
|
||||
def get_html_tags_no_user_tags_test(self):
|
||||
def test_get_html_tags_no_user_tags(self):
|
||||
"""
|
||||
Test the FormattingTags class' get_html_tags static method.
|
||||
"""
|
||||
@ -68,7 +68,7 @@ class TestFormattingTags(TestCase):
|
||||
# THEN: Lists should be identical.
|
||||
assert old_tags_list == new_tags_list, 'The formatting tag lists should be identical.'
|
||||
|
||||
def get_html_tags_with_user_tags_test(self):
|
||||
def test_get_html_tags_with_user_tags(self):
|
||||
"""
|
||||
FormattingTags class - test the get_html_tags(), add_html_tags() and remove_html_tag() methods.
|
||||
"""
|
||||
|
@ -14,177 +14,190 @@ from tests.functional import MagicMock, patch
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
|
||||
HTML = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenLP Display</title>
|
||||
<style>
|
||||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
body {
|
||||
;
|
||||
}
|
||||
.size {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#black {
|
||||
z-index: 8;
|
||||
background-color: black;
|
||||
display: none;
|
||||
}
|
||||
#bgimage {
|
||||
z-index: 1;
|
||||
}
|
||||
#image {
|
||||
z-index: 2;
|
||||
}
|
||||
plugin CSS
|
||||
#footer {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
dummy: dummy;
|
||||
}
|
||||
/* lyric css */
|
||||
|
||||
sup {
|
||||
font-size: 0.6em;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
top: -0.3em;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var timer = null;
|
||||
var transition = false;
|
||||
plugin JS
|
||||
|
||||
function show_image(src){
|
||||
var img = document.getElementById('image');
|
||||
img.src = src;
|
||||
if(src == '')
|
||||
img.style.display = 'none';
|
||||
else
|
||||
img.style.display = 'block';
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenLP Display</title>
|
||||
<style>
|
||||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
body {
|
||||
;
|
||||
}
|
||||
.size {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#black {
|
||||
z-index: 8;
|
||||
background-color: black;
|
||||
display: none;
|
||||
}
|
||||
#bgimage {
|
||||
z-index: 1;
|
||||
}
|
||||
#image {
|
||||
z-index: 2;
|
||||
}
|
||||
plugin CSS
|
||||
#footer {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
dummy: dummy;
|
||||
}
|
||||
/* lyric css */
|
||||
sup {
|
||||
font-size: 0.6em;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
top: -0.3em;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var timer = null;
|
||||
var transition = false;
|
||||
plugin JS
|
||||
|
||||
function show_blank(state){
|
||||
var black = 'none';
|
||||
var lyrics = '';
|
||||
switch(state){
|
||||
case 'theme':
|
||||
lyrics = 'hidden';
|
||||
break;
|
||||
case 'black':
|
||||
black = 'block';
|
||||
break;
|
||||
case 'desktop':
|
||||
break;
|
||||
function show_image(src){
|
||||
var img = document.getElementById('image');
|
||||
img.src = src;
|
||||
if(src == '')
|
||||
img.style.display = 'none';
|
||||
else
|
||||
img.style.display = 'block';
|
||||
}
|
||||
document.getElementById('black').style.display = black;
|
||||
document.getElementById('lyricsmain').style.visibility = lyrics;
|
||||
document.getElementById('image').style.visibility = lyrics;
|
||||
document.getElementById('footer').style.visibility = lyrics;
|
||||
}
|
||||
|
||||
function show_footer(footertext){
|
||||
document.getElementById('footer').innerHTML = footertext;
|
||||
}
|
||||
|
||||
function show_text(new_text){
|
||||
var match = /-webkit-text-fill-color:[^;"]+/gi;
|
||||
if(timer != null)
|
||||
clearTimeout(timer);
|
||||
/*
|
||||
QtWebkit bug with outlines and justify causing outline alignment
|
||||
problems. (Bug 859950) Surround each word with a <span> to workaround,
|
||||
but only in this scenario.
|
||||
*/
|
||||
var txt = document.getElementById('lyricsmain');
|
||||
if(window.getComputedStyle(txt).textAlign == 'justify'){
|
||||
if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
|
||||
new_text = new_text.replace(/(\s| )+(?![^<]*>)/g,
|
||||
function(match) {
|
||||
return '</span>' + match + '<span>';
|
||||
});
|
||||
new_text = '<span>' + new_text + '</span>';
|
||||
function show_blank(state){
|
||||
var black = 'none';
|
||||
var lyrics = '';
|
||||
switch(state){
|
||||
case 'theme':
|
||||
lyrics = 'hidden';
|
||||
break;
|
||||
case 'black':
|
||||
black = 'block';
|
||||
break;
|
||||
case 'desktop':
|
||||
break;
|
||||
}
|
||||
document.getElementById('black').style.display = black;
|
||||
document.getElementById('lyricsmain').style.visibility = lyrics;
|
||||
document.getElementById('image').style.visibility = lyrics;
|
||||
document.getElementById('footer').style.visibility = lyrics;
|
||||
}
|
||||
text_fade('lyricsmain', new_text);
|
||||
}
|
||||
|
||||
function text_fade(id, new_text){
|
||||
/*
|
||||
Show the text.
|
||||
*/
|
||||
var text = document.getElementById(id);
|
||||
if(text == null) return;
|
||||
if(!transition){
|
||||
function show_footer(footertext){
|
||||
document.getElementById('footer').innerHTML = footertext;
|
||||
}
|
||||
|
||||
function show_text(new_text){
|
||||
var match = /-webkit-text-fill-color:[^;"]+/gi;
|
||||
if(timer != null)
|
||||
clearTimeout(timer);
|
||||
/*
|
||||
QtWebkit bug with outlines and justify causing outline alignment
|
||||
problems. (Bug 859950) Surround each word with a <span> to workaround,
|
||||
but only in this scenario.
|
||||
*/
|
||||
var txt = document.getElementById('lyricsmain');
|
||||
if(window.getComputedStyle(txt).textAlign == 'justify'){
|
||||
if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
|
||||
new_text = new_text.replace(/(\s| )+(?![^<]*>)/g,
|
||||
function(match) {
|
||||
return '</span>' + match + '<span>';
|
||||
});
|
||||
new_text = '<span>' + new_text + '</span>';
|
||||
}
|
||||
}
|
||||
text_fade('lyricsmain', new_text);
|
||||
}
|
||||
|
||||
function text_fade(id, new_text){
|
||||
/*
|
||||
Show the text.
|
||||
*/
|
||||
var text = document.getElementById(id);
|
||||
if(text == null) return;
|
||||
if(!transition){
|
||||
text.innerHTML = new_text;
|
||||
return;
|
||||
}
|
||||
// Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
|
||||
text.style.opacity = '0.1';
|
||||
// Fade new text in after the old text has finished fading out.
|
||||
timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);
|
||||
}
|
||||
|
||||
function _show_text(text, new_text) {
|
||||
/*
|
||||
Helper function to show the new_text delayed.
|
||||
*/
|
||||
text.innerHTML = new_text;
|
||||
return;
|
||||
text.style.opacity = '1';
|
||||
// Wait until the text is completely visible. We want to save the timer id, to be able to call
|
||||
// clearTimeout(timer) when the text has changed before finishing fading.
|
||||
timer = window.setTimeout(function(){timer = null;}, 400);
|
||||
}
|
||||
// Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
|
||||
text.style.opacity = '0.1';
|
||||
// Fade new text in after the old text has finished fading out.
|
||||
timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);
|
||||
}
|
||||
|
||||
function _show_text(text, new_text) {
|
||||
/*
|
||||
Helper function to show the new_text delayed.
|
||||
*/
|
||||
text.innerHTML = new_text;
|
||||
text.style.opacity = '1';
|
||||
// Wait until the text is completely visible. We want to save the timer id, to be able to call
|
||||
// clearTimeout(timer) when the text has changed before finishing fading.
|
||||
timer = window.setTimeout(function(){timer = null;}, 400);
|
||||
}
|
||||
|
||||
function show_text_completed(){
|
||||
return (timer == null);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img id="bgimage" class="size" style="display:none;" />
|
||||
<img id="image" class="size" style="display:none;" />
|
||||
plugin HTML
|
||||
<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
|
||||
<div id="footer" class="footer"></div>
|
||||
<div id="black" class="size"></div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
function show_text_completed(){
|
||||
return (timer == null);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img id="bgimage" class="size" style="display:none;" />
|
||||
<img id="image" class="size" style="display:none;" />
|
||||
plugin HTML
|
||||
<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
|
||||
<div id="footer" class="footer"></div>
|
||||
<div id="black" class="size"></div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
BACKGROUND_CSS_RADIAL = 'background: -webkit-gradient(radial, 5 50%, 100, 5 50%, 5, from(#000000), to(#FFFFFF)) fixed'
|
||||
LYRICS_CSS = """
|
||||
.lyricstable {
|
||||
z-index: 5;
|
||||
position: absolute;
|
||||
display: table;
|
||||
left: 10px; top: 20px;
|
||||
}
|
||||
.lyricscell {
|
||||
display: table-cell;
|
||||
word-wrap: break-word;
|
||||
-webkit-transition: opacity 0.4s ease;
|
||||
lyrics_format_css
|
||||
}
|
||||
.lyricsmain {
|
||||
text-shadow: #000000 5px 5px;
|
||||
}
|
||||
"""
|
||||
.lyricstable {
|
||||
z-index: 5;
|
||||
position: absolute;
|
||||
display: table;
|
||||
left: 10px; top: 20px;
|
||||
}
|
||||
.lyricscell {
|
||||
display: table-cell;
|
||||
word-wrap: break-word;
|
||||
-webkit-transition: opacity 0.4s ease;
|
||||
lyrics_format_css
|
||||
}
|
||||
.lyricsmain {
|
||||
text-shadow: #000000 5px 5px;
|
||||
}
|
||||
"""
|
||||
LYRICS_OUTLINE_CSS = ' -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-color: #FFFFFF; '
|
||||
LYRICS_FORMAT_CSS = ' word-wrap: break-word; text-align: justify; vertical-align: bottom; ' + \
|
||||
'font-family: Arial; font-size: 40pt; color: #FFFFFF; line-height: 108%; margin: 0;padding: 0; ' + \
|
||||
'padding-bottom: 0.5em; padding-left: 2px; width: 1580px; height: 810px; font-style:italic; font-weight:bold; '
|
||||
LYRICS_FORMAT_CSS = """
|
||||
word-wrap: break-word;
|
||||
text-align: justify;
|
||||
vertical-align: bottom;
|
||||
font-family: Arial;
|
||||
font-size: 40pt;
|
||||
color: #FFFFFF;
|
||||
line-height: 108%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-bottom: 0.5em;
|
||||
padding-left: 2px;
|
||||
width: 1580px;
|
||||
height: 810px;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
"""
|
||||
FOOTER_CSS_BASE = """
|
||||
left: 10px;
|
||||
bottom: 0px;
|
||||
@ -216,7 +229,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
"""
|
||||
self.destroy_settings()
|
||||
|
||||
def build_html_test(self):
|
||||
def test_build_html(self):
|
||||
"""
|
||||
Test the build_html() function
|
||||
"""
|
||||
@ -246,7 +259,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: The returned html should match.
|
||||
self.assertEqual(html, HTML, 'The returned html should match')
|
||||
|
||||
def build_background_css_radial_test(self):
|
||||
def test_build_background_css_radial(self):
|
||||
"""
|
||||
Test the build_background_css() function with a radial background
|
||||
"""
|
||||
@ -262,7 +275,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: The returned css should match.
|
||||
self.assertEqual(BACKGROUND_CSS_RADIAL, css, 'The background css should be equal.')
|
||||
|
||||
def build_lyrics_css_test(self):
|
||||
def test_build_lyrics_css(self):
|
||||
"""
|
||||
Test the build_lyrics_css() function
|
||||
"""
|
||||
@ -283,7 +296,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: The css should be equal.
|
||||
self.assertEqual(LYRICS_CSS, css, 'The lyrics css should be equal.')
|
||||
|
||||
def build_lyrics_outline_css_test(self):
|
||||
def test_build_lyrics_outline_css(self):
|
||||
"""
|
||||
Test the build_lyrics_outline_css() function
|
||||
"""
|
||||
@ -300,7 +313,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: The css should be equal.
|
||||
self.assertEqual(LYRICS_OUTLINE_CSS, css, 'The outline css should be equal.')
|
||||
|
||||
def build_lyrics_format_css_test(self):
|
||||
def test_build_lyrics_format_css(self):
|
||||
"""
|
||||
Test the build_lyrics_format_css() function
|
||||
"""
|
||||
@ -323,7 +336,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: They should be equal.
|
||||
self.assertEqual(LYRICS_FORMAT_CSS, css, 'The lyrics format css should be equal.')
|
||||
|
||||
def build_footer_css_test(self):
|
||||
def test_build_footer_css(self):
|
||||
"""
|
||||
Test the build_footer_css() function
|
||||
"""
|
||||
@ -341,7 +354,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: THE css should be the same.
|
||||
self.assertEqual(FOOTER_CSS, css, 'The footer strings should be equal.')
|
||||
|
||||
def build_footer_css_wrap_test(self):
|
||||
def test_build_footer_css_wrap(self):
|
||||
"""
|
||||
Test the build_footer_css() function
|
||||
"""
|
||||
@ -360,7 +373,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# THEN: Footer should wrap
|
||||
self.assertEqual(FOOTER_CSS_WRAP, css, 'The footer strings should be equal.')
|
||||
|
||||
def build_footer_invalid_test(self):
|
||||
def test_build_footer_invalid(self):
|
||||
"""
|
||||
Test the build_footer_css() function
|
||||
"""
|
||||
@ -381,7 +394,7 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
self.assertEqual(FOOTER_CSS_INVALID, css[0], 'The footer strings should be blank.')
|
||||
self.assertEqual(FOOTER_CSS_INVALID, css[1], 'The footer strings should be blank.')
|
||||
|
||||
def webkit_version_test(self):
|
||||
def test_webkit_version(self):
|
||||
"""
|
||||
Test the webkit_version() function
|
||||
"""
|
||||
|
@ -57,7 +57,7 @@ class TestImageManager(TestCase, TestMixin):
|
||||
"""
|
||||
del self.app
|
||||
|
||||
def basic_image_manager_test(self):
|
||||
def test_basic_image_manager(self):
|
||||
"""
|
||||
Test the Image Manager setup basic functionality
|
||||
"""
|
||||
@ -83,7 +83,7 @@ class TestImageManager(TestCase, TestMixin):
|
||||
self.image_manager.get_image(TEST_PATH, 'church1.jpg')
|
||||
self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing image')
|
||||
|
||||
def different_dimension_image_test(self):
|
||||
def test_different_dimension_image(self):
|
||||
"""
|
||||
Test the Image Manager with dimensions
|
||||
"""
|
||||
@ -115,7 +115,7 @@ class TestImageManager(TestCase, TestMixin):
|
||||
self.image_manager.get_image(full_path, 'church.jpg', 120, 120)
|
||||
self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing dimension')
|
||||
|
||||
def process_cache_test(self):
|
||||
def test_process_cache(self):
|
||||
"""
|
||||
Test the process_cache method
|
||||
"""
|
||||
|
@ -38,7 +38,7 @@ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..',
|
||||
|
||||
class TestLib(TestCase):
|
||||
|
||||
def str_to_bool_with_bool_true_test(self):
|
||||
def test_str_to_bool_with_bool_true(self):
|
||||
"""
|
||||
Test the str_to_bool function with boolean input of True
|
||||
"""
|
||||
@ -52,7 +52,7 @@ class TestLib(TestCase):
|
||||
self.assertIsInstance(true_result, bool, 'The result should be a boolean')
|
||||
self.assertTrue(true_result, 'The result should be True')
|
||||
|
||||
def str_to_bool_with_bool_false_test(self):
|
||||
def test_str_to_bool_with_bool_false(self):
|
||||
"""
|
||||
Test the str_to_bool function with boolean input of False
|
||||
"""
|
||||
@ -66,7 +66,7 @@ class TestLib(TestCase):
|
||||
self.assertIsInstance(false_result, bool, 'The result should be a boolean')
|
||||
self.assertFalse(false_result, 'The result should be True')
|
||||
|
||||
def str_to_bool_with_integer_test(self):
|
||||
def test_str_to_bool_with_integer(self):
|
||||
"""
|
||||
Test the str_to_bool function with an integer input
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(int_result, 'The result should be False')
|
||||
|
||||
def str_to_bool_with_invalid_string_test(self):
|
||||
def test_str_to_bool_with_invalid_string(self):
|
||||
"""
|
||||
Test the str_to_bool function with an invalid string
|
||||
"""
|
||||
@ -92,7 +92,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(str_result, 'The result should be False')
|
||||
|
||||
def str_to_bool_with_string_false_test(self):
|
||||
def test_str_to_bool_with_string_false(self):
|
||||
"""
|
||||
Test the str_to_bool function with a string saying "false"
|
||||
"""
|
||||
@ -105,7 +105,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(false_result, 'The result should be False')
|
||||
|
||||
def str_to_bool_with_string_no_test(self):
|
||||
def test_str_to_bool_with_string_no(self):
|
||||
"""
|
||||
Test the str_to_bool function with a string saying "NO"
|
||||
"""
|
||||
@ -118,7 +118,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should get back a false
|
||||
self.assertFalse(str_result, 'The result should be False')
|
||||
|
||||
def str_to_bool_with_true_string_value_test(self):
|
||||
def test_str_to_bool_with_true_string_value(self):
|
||||
"""
|
||||
Test the str_to_bool function with a string set to "True"
|
||||
"""
|
||||
@ -131,7 +131,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should get back a true
|
||||
self.assertTrue(true_result, 'The result should be True')
|
||||
|
||||
def str_to_bool_with_yes_string_value_test(self):
|
||||
def test_str_to_bool_with_yes_string_value(self):
|
||||
"""
|
||||
Test the str_to_bool function with a string set to "yes"
|
||||
"""
|
||||
@ -144,7 +144,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should get back a true
|
||||
self.assertTrue(str_result, 'The result should be True')
|
||||
|
||||
def get_text_file_string_no_file_test(self):
|
||||
def test_get_text_file_string_no_file(self):
|
||||
"""
|
||||
Test the get_text_file_string() function when a file does not exist
|
||||
"""
|
||||
@ -160,7 +160,7 @@ class TestLib(TestCase):
|
||||
mocked_isfile.assert_called_with(filename)
|
||||
self.assertFalse(result, 'False should be returned if no file exists')
|
||||
|
||||
def get_text_file_string_read_error_test(self):
|
||||
def test_get_text_file_string_read_error(self):
|
||||
"""
|
||||
Test the get_text_file_string() method when a read error happens
|
||||
"""
|
||||
@ -179,13 +179,13 @@ class TestLib(TestCase):
|
||||
mocked_open.assert_called_with(filename, 'r', encoding='utf-8')
|
||||
self.assertIsNone(result, 'None should be returned if the file cannot be opened')
|
||||
|
||||
def get_text_file_string_decode_error_test(self):
|
||||
def test_get_text_file_string_decode_error(self):
|
||||
"""
|
||||
Test the get_text_file_string() method when the contents cannot be decoded
|
||||
"""
|
||||
self.skipTest('Impossible to test due to conflicts when mocking out the "open" function')
|
||||
|
||||
def build_icon_with_qicon_test(self):
|
||||
def test_build_icon_with_qicon(self):
|
||||
"""
|
||||
Test the build_icon() function with a QIcon instance
|
||||
"""
|
||||
@ -200,7 +200,7 @@ class TestLib(TestCase):
|
||||
# THEN: The result should be our mocked QIcon
|
||||
self.assertIs(mocked_icon, result, 'The result should be the mocked QIcon')
|
||||
|
||||
def build_icon_with_resource_test(self):
|
||||
def test_build_icon_with_resource(self):
|
||||
"""
|
||||
Test the build_icon() function with a resource URI
|
||||
"""
|
||||
@ -222,7 +222,7 @@ class TestLib(TestCase):
|
||||
# best we can do is to assert that we get back a MagicMock object.
|
||||
self.assertIsInstance(result, MagicMock, 'The result should be a MagicMock, because we mocked it out')
|
||||
|
||||
def image_to_byte_test(self):
|
||||
def test_image_to_byte(self):
|
||||
"""
|
||||
Test the image_to_byte() function
|
||||
"""
|
||||
@ -248,7 +248,7 @@ class TestLib(TestCase):
|
||||
self.assertEqual('base64mock', result, 'The result should be the return value of the mocked out '
|
||||
'base64 method')
|
||||
|
||||
def create_thumb_with_size_test(self):
|
||||
def test_create_thumb_with_size(self):
|
||||
"""
|
||||
Test the create_thumb() function with a given size.
|
||||
"""
|
||||
@ -282,7 +282,7 @@ class TestLib(TestCase):
|
||||
except:
|
||||
pass
|
||||
|
||||
def create_thumb_no_size_test(self):
|
||||
def test_create_thumb_no_size(self):
|
||||
"""
|
||||
Test the create_thumb() function with no size specified.
|
||||
"""
|
||||
@ -316,7 +316,7 @@ class TestLib(TestCase):
|
||||
except:
|
||||
pass
|
||||
|
||||
def create_thumb_invalid_size_test(self):
|
||||
def test_create_thumb_invalid_size(self):
|
||||
"""
|
||||
Test the create_thumb() function with invalid size specified.
|
||||
"""
|
||||
@ -351,7 +351,7 @@ class TestLib(TestCase):
|
||||
except:
|
||||
pass
|
||||
|
||||
def create_thumb_width_only_test(self):
|
||||
def test_create_thumb_width_only(self):
|
||||
"""
|
||||
Test the create_thumb() function with a size of only width specified.
|
||||
"""
|
||||
@ -386,7 +386,7 @@ class TestLib(TestCase):
|
||||
except:
|
||||
pass
|
||||
|
||||
def create_thumb_height_only_test(self):
|
||||
def test_create_thumb_height_only(self):
|
||||
"""
|
||||
Test the create_thumb() function with a size of only height specified.
|
||||
"""
|
||||
@ -421,7 +421,7 @@ class TestLib(TestCase):
|
||||
except:
|
||||
pass
|
||||
|
||||
def create_thumb_empty_img_test(self):
|
||||
def test_create_thumb_empty_img(self):
|
||||
"""
|
||||
Test the create_thumb() function with a size of only height specified.
|
||||
"""
|
||||
@ -469,7 +469,7 @@ class TestLib(TestCase):
|
||||
except:
|
||||
pass
|
||||
|
||||
def check_item_selected_true_test(self):
|
||||
def test_check_item_selected_true(self):
|
||||
"""
|
||||
Test that the check_item_selected() function returns True when there are selected indexes
|
||||
"""
|
||||
@ -486,7 +486,7 @@ class TestLib(TestCase):
|
||||
mocked_list_widget.selectedIndexes.assert_called_with()
|
||||
self.assertTrue(result, 'The result should be True')
|
||||
|
||||
def check_item_selected_false_test(self):
|
||||
def test_check_item_selected_false(self):
|
||||
"""
|
||||
Test that the check_item_selected() function returns False when there are no selected indexes.
|
||||
"""
|
||||
@ -507,7 +507,7 @@ class TestLib(TestCase):
|
||||
MockedQtWidgets.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message')
|
||||
self.assertFalse(result, 'The result should be False')
|
||||
|
||||
def clean_tags_test(self):
|
||||
def test_clean_tags(self):
|
||||
"""
|
||||
Test clean_tags() method.
|
||||
"""
|
||||
@ -529,7 +529,7 @@ class TestLib(TestCase):
|
||||
# THEN: The strings should be identical.
|
||||
self.assertEqual(wanted_string, result_string, 'The strings should be identical')
|
||||
|
||||
def expand_tags_test(self):
|
||||
def test_expand_tags(self):
|
||||
"""
|
||||
Test the expand_tags() method.
|
||||
"""
|
||||
@ -568,7 +568,7 @@ class TestLib(TestCase):
|
||||
# THEN: The strings should be identical.
|
||||
self.assertEqual(wanted_string, result_string, 'The strings should be identical.')
|
||||
|
||||
def validate_thumb_file_does_not_exist_test(self):
|
||||
def test_validate_thumb_file_does_not_exist(self):
|
||||
"""
|
||||
Test the validate_thumb() function when the thumbnail does not exist
|
||||
"""
|
||||
@ -585,7 +585,7 @@ class TestLib(TestCase):
|
||||
mocked_os.path.exists.assert_called_with(thumb_path)
|
||||
assert result is False, 'The result should be False'
|
||||
|
||||
def validate_thumb_file_exists_and_newer_test(self):
|
||||
def test_validate_thumb_file_exists_and_newer(self):
|
||||
"""
|
||||
Test the validate_thumb() function when the thumbnail exists and has a newer timestamp than the file
|
||||
"""
|
||||
@ -605,7 +605,7 @@ class TestLib(TestCase):
|
||||
# THEN: we should have called a few functions, and the result should be True
|
||||
# mocked_os.path.exists.assert_called_with(thumb_path)
|
||||
|
||||
def validate_thumb_file_exists_and_older_test(self):
|
||||
def test_validate_thumb_file_exists_and_older(self):
|
||||
"""
|
||||
Test the validate_thumb() function when the thumbnail exists but is older than the file
|
||||
"""
|
||||
@ -629,7 +629,7 @@ class TestLib(TestCase):
|
||||
mocked_os.stat.assert_any_call(thumb_path)
|
||||
assert result is False, 'The result should be False'
|
||||
|
||||
def resize_thumb_test(self):
|
||||
def test_resize_thumb(self):
|
||||
"""
|
||||
Test the resize_thumb() function
|
||||
"""
|
||||
@ -650,7 +650,7 @@ class TestLib(TestCase):
|
||||
self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.')
|
||||
self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.')
|
||||
|
||||
def create_separated_list_qlocate_test(self):
|
||||
def test_create_separated_list_qlocate(self):
|
||||
"""
|
||||
Test the create_separated_list function using the Qt provided method
|
||||
"""
|
||||
@ -669,7 +669,7 @@ class TestLib(TestCase):
|
||||
assert string_result == 'Author 1, Author 2, and Author 3', 'The string should be u\'Author 1, ' \
|
||||
'Author 2, and Author 3\'.'
|
||||
|
||||
def create_separated_list_empty_list_test(self):
|
||||
def test_create_separated_list_empty_list(self):
|
||||
"""
|
||||
Test the create_separated_list function with an empty list
|
||||
"""
|
||||
@ -685,7 +685,7 @@ class TestLib(TestCase):
|
||||
# THEN: We shoud have an emptry string.
|
||||
assert string_result == '', 'The string sould be empty.'
|
||||
|
||||
def create_separated_list_with_one_item_test(self):
|
||||
def test_create_separated_list_with_one_item(self):
|
||||
"""
|
||||
Test the create_separated_list function with a list consisting of only one entry
|
||||
"""
|
||||
@ -701,7 +701,7 @@ class TestLib(TestCase):
|
||||
# THEN: We should have "Author 1"
|
||||
assert string_result == 'Author 1', 'The string should be u\'Author 1\'.'
|
||||
|
||||
def create_separated_list_with_two_items_test(self):
|
||||
def test_create_separated_list_with_two_items(self):
|
||||
"""
|
||||
Test the create_separated_list function with a list of two entries
|
||||
"""
|
||||
@ -718,7 +718,7 @@ class TestLib(TestCase):
|
||||
# THEN: We should have "Author 1 and Author 2"
|
||||
assert string_result == 'Author 1 and Author 2', 'The string should be u\'Author 1 and Author 2\'.'
|
||||
|
||||
def create_separated_list_with_three_items_test(self):
|
||||
def test_create_separated_list_with_three_items(self):
|
||||
"""
|
||||
Test the create_separated_list function with a list of three items
|
||||
"""
|
||||
|
@ -44,7 +44,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
||||
|
||||
@patch(u'openlp.core.lib.mediamanageritem.Settings')
|
||||
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
|
||||
def on_double_clicked_test(self, mocked_on_preview_click, MockedSettings):
|
||||
def test_on_double_clicked(self, mocked_on_preview_click, MockedSettings):
|
||||
"""
|
||||
Test that when an item is double-clicked then the item is previewed
|
||||
"""
|
||||
@ -60,7 +60,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
||||
# THEN: on_preview_click() should have been called
|
||||
mocked_on_preview_click.assert_called_with()
|
||||
|
||||
def required_icons_test(self):
|
||||
def test_required_icons(self):
|
||||
"""
|
||||
Test the default icons for plugins
|
||||
"""
|
||||
@ -77,7 +77,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
||||
|
||||
@patch(u'openlp.core.lib.mediamanageritem.Settings')
|
||||
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
|
||||
def on_double_clicked_go_live_test(self, mocked_on_live_click, MockedSettings):
|
||||
def test_on_double_clicked_go_live(self, mocked_on_live_click, MockedSettings):
|
||||
"""
|
||||
Test that when "Double-click to go live" is enabled that the item goes live
|
||||
"""
|
||||
@ -96,7 +96,7 @@ class TestMediaManagerItem(TestCase, TestMixin):
|
||||
@patch(u'openlp.core.lib.mediamanageritem.Settings')
|
||||
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
|
||||
@patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
|
||||
def on_double_clicked_single_click_preview_test(self, mocked_on_preview_click, mocked_on_live_click,
|
||||
def test_on_double_clicked_single_click_preview(self, mocked_on_preview_click, mocked_on_live_click,
|
||||
MockedSettings):
|
||||
"""
|
||||
Test that when "Single-click preview" is enabled then nothing happens on double-click
|
||||
|
@ -49,7 +49,7 @@ class TestPluginManager(TestCase):
|
||||
Registry().register('main_window', self.mocked_main_window)
|
||||
Registry().register('settings_form', self.mocked_settings_form)
|
||||
|
||||
def hook_media_manager_with_disabled_plugin_test(self):
|
||||
def test_hook_media_manager_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the hook_media_manager() method with a disabled plugin
|
||||
"""
|
||||
@ -66,7 +66,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
|
||||
'The create_media_manager_item() method should not have been called.')
|
||||
|
||||
def hook_media_manager_with_active_plugin_test(self):
|
||||
def test_hook_media_manager_with_active_plugin(self):
|
||||
"""
|
||||
Test running the hook_media_manager() method with an active plugin
|
||||
"""
|
||||
@ -82,7 +82,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The create_media_manager_item() method should have been called
|
||||
mocked_plugin.create_media_manager_item.assert_called_with()
|
||||
|
||||
def hook_settings_tabs_with_disabled_plugin_and_no_form_test(self):
|
||||
def test_hook_settings_tabs_with_disabled_plugin_and_no_form(self):
|
||||
"""
|
||||
Test running the hook_settings_tabs() method with a disabled plugin and no form
|
||||
"""
|
||||
@ -99,7 +99,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count,
|
||||
'The create_media_manager_item() method should not have been called.')
|
||||
|
||||
def hook_settings_tabs_with_disabled_plugin_and_mocked_form_test(self):
|
||||
def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
|
||||
"""
|
||||
Test running the hook_settings_tabs() method with a disabled plugin and a mocked form
|
||||
"""
|
||||
@ -121,7 +121,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins,
|
||||
'The plugins on the settings form should be the same as the plugins in the plugin manager')
|
||||
|
||||
def hook_settings_tabs_with_active_plugin_and_mocked_form_test(self):
|
||||
def test_hook_settings_tabs_with_active_plugin_and_mocked_form(self):
|
||||
"""
|
||||
Test running the hook_settings_tabs() method with an active plugin and a mocked settings form
|
||||
"""
|
||||
@ -143,7 +143,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(plugin_manager.plugins, mocked_settings_form.plugin_manager.plugins,
|
||||
'The plugins on the settings form should be the same as the plugins in the plugin manager')
|
||||
|
||||
def hook_settings_tabs_with_active_plugin_and_no_form_test(self):
|
||||
def test_hook_settings_tabs_with_active_plugin_and_no_form(self):
|
||||
"""
|
||||
Test running the hook_settings_tabs() method with an active plugin and no settings form
|
||||
"""
|
||||
@ -159,7 +159,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The create_settings_tab() method should have been called
|
||||
mocked_plugin.create_settings_tab.assert_called_with(self.mocked_settings_form)
|
||||
|
||||
def hook_import_menu_with_disabled_plugin_test(self):
|
||||
def test_hook_import_menu_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the hook_import_menu() method with a disabled plugin
|
||||
"""
|
||||
@ -176,7 +176,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.add_import_menu_item.call_count,
|
||||
'The add_import_menu_item() method should not have been called.')
|
||||
|
||||
def hook_import_menu_with_active_plugin_test(self):
|
||||
def test_hook_import_menu_with_active_plugin(self):
|
||||
"""
|
||||
Test running the hook_import_menu() method with an active plugin
|
||||
"""
|
||||
@ -192,7 +192,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The add_import_menu_item() method should have been called
|
||||
mocked_plugin.add_import_menu_item.assert_called_with(self.mocked_main_window.file_import_menu)
|
||||
|
||||
def hook_export_menu_with_disabled_plugin_test(self):
|
||||
def test_hook_export_menu_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the hook_export_menu() method with a disabled plugin
|
||||
"""
|
||||
@ -209,7 +209,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.add_export_menu_item.call_count,
|
||||
'The add_export_menu_item() method should not have been called.')
|
||||
|
||||
def hook_export_menu_with_active_plugin_test(self):
|
||||
def test_hook_export_menu_with_active_plugin(self):
|
||||
"""
|
||||
Test running the hook_export_menu() method with an active plugin
|
||||
"""
|
||||
@ -225,7 +225,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The add_export_menu_item() method should have been called
|
||||
mocked_plugin.add_export_menu_item.assert_called_with(self.mocked_main_window.file_export_menu)
|
||||
|
||||
def hook_upgrade_plugin_settings_with_disabled_plugin_test(self):
|
||||
def test_hook_upgrade_plugin_settings_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the hook_upgrade_plugin_settings() method with a disabled plugin
|
||||
"""
|
||||
@ -243,7 +243,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.upgrade_settings.call_count,
|
||||
'The upgrade_settings() method should not have been called.')
|
||||
|
||||
def hook_upgrade_plugin_settings_with_active_plugin_test(self):
|
||||
def test_hook_upgrade_plugin_settings_with_active_plugin(self):
|
||||
"""
|
||||
Test running the hook_upgrade_plugin_settings() method with an active plugin
|
||||
"""
|
||||
@ -260,7 +260,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The add_export_menu_item() method should have been called
|
||||
mocked_plugin.upgrade_settings.assert_called_with(settings)
|
||||
|
||||
def hook_tools_menu_with_disabled_plugin_test(self):
|
||||
def test_hook_tools_menu_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the hook_tools_menu() method with a disabled plugin
|
||||
"""
|
||||
@ -277,7 +277,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.add_tools_menu_item.call_count,
|
||||
'The add_tools_menu_item() method should not have been called.')
|
||||
|
||||
def hook_tools_menu_with_active_plugin_test(self):
|
||||
def test_hook_tools_menu_with_active_plugin(self):
|
||||
"""
|
||||
Test running the hook_tools_menu() method with an active plugin
|
||||
"""
|
||||
@ -293,7 +293,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The add_tools_menu_item() method should have been called
|
||||
mocked_plugin.add_tools_menu_item.assert_called_with(self.mocked_main_window.tools_menu)
|
||||
|
||||
def initialise_plugins_with_disabled_plugin_test(self):
|
||||
def test_initialise_plugins_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the initialise_plugins() method with a disabled plugin
|
||||
"""
|
||||
@ -311,7 +311,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
self.assertEqual(0, mocked_plugin.initialise.call_count, 'The initialise() method should not have been called.')
|
||||
|
||||
def initialise_plugins_with_active_plugin_test(self):
|
||||
def test_initialise_plugins_with_active_plugin(self):
|
||||
"""
|
||||
Test running the initialise_plugins() method with an active plugin
|
||||
"""
|
||||
@ -329,7 +329,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
mocked_plugin.initialise.assert_called_with()
|
||||
|
||||
def finalise_plugins_with_disabled_plugin_test(self):
|
||||
def test_finalise_plugins_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the finalise_plugins() method with a disabled plugin
|
||||
"""
|
||||
@ -347,7 +347,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
self.assertEqual(0, mocked_plugin.finalise.call_count, 'The finalise() method should not have been called.')
|
||||
|
||||
def finalise_plugins_with_active_plugin_test(self):
|
||||
def test_finalise_plugins_with_active_plugin(self):
|
||||
"""
|
||||
Test running the finalise_plugins() method with an active plugin
|
||||
"""
|
||||
@ -365,7 +365,7 @@ class TestPluginManager(TestCase):
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
mocked_plugin.finalise.assert_called_with()
|
||||
|
||||
def get_plugin_by_name_does_not_exist_test(self):
|
||||
def test_get_plugin_by_name_does_not_exist(self):
|
||||
"""
|
||||
Test running the get_plugin_by_name() method to find a plugin that does not exist
|
||||
"""
|
||||
@ -381,7 +381,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The is_active() and finalise() methods should have been called
|
||||
self.assertIsNone(result, 'The result for get_plugin_by_name should be None')
|
||||
|
||||
def get_plugin_by_name_exists_test(self):
|
||||
def test_get_plugin_by_name_exists(self):
|
||||
"""
|
||||
Test running the get_plugin_by_name() method to find a plugin that exists
|
||||
"""
|
||||
@ -397,7 +397,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The is_active() and finalise() methods should have been called
|
||||
self.assertEqual(result, mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin')
|
||||
|
||||
def new_service_created_with_disabled_plugin_test(self):
|
||||
def test_new_service_created_with_disabled_plugin(self):
|
||||
"""
|
||||
Test running the new_service_created() method with a disabled plugin
|
||||
"""
|
||||
@ -416,7 +416,7 @@ class TestPluginManager(TestCase):
|
||||
self.assertEqual(0, mocked_plugin.new_service_created.call_count,
|
||||
'The new_service_created() method should not have been called.')
|
||||
|
||||
def new_service_created_with_active_plugin_test(self):
|
||||
def test_new_service_created_with_active_plugin(self):
|
||||
"""
|
||||
Test running the new_service_created() method with an active plugin
|
||||
"""
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.lib.projector.constants import E_PARAMETER, ERROR_STRING, S_OFF
|
||||
S_COOLDOWN, PJLINK_POWR_STATUS
|
||||
|
||||
from tests.functional import patch
|
||||
from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE
|
||||
from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE, TEST_HASH
|
||||
|
||||
pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True)
|
||||
|
||||
@ -57,7 +57,7 @@ class TestPJLink(TestCase):
|
||||
@patch.object(pjlink_test, 'send_command')
|
||||
@patch.object(pjlink_test, 'waitForReadyRead')
|
||||
@patch('openlp.core.common.qmd5_hash')
|
||||
def authenticated_connection_call_test(self, mock_qmd5_hash, mock_waitForReadyRead, mock_send_command,
|
||||
def test_authenticated_connection_call(self, mock_qmd5_hash, mock_waitForReadyRead, mock_send_command,
|
||||
mock_readyRead):
|
||||
"""
|
||||
Ticket 92187: Fix for projector connect with PJLink authentication exception.
|
||||
@ -74,7 +74,7 @@ class TestPJLink(TestCase):
|
||||
self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN,
|
||||
"Connection request should have been called with TEST_PIN"))
|
||||
|
||||
def projector_class_test(self):
|
||||
def test_projector_class(self):
|
||||
"""
|
||||
Test class version from projector
|
||||
"""
|
||||
@ -88,7 +88,7 @@ class TestPJLink(TestCase):
|
||||
self.assertEquals(pjlink.pjlink_class, '1',
|
||||
'Projector should have returned class=1')
|
||||
|
||||
def non_standard_class_reply_test(self):
|
||||
def test_non_standard_class_reply(self):
|
||||
"""
|
||||
Bugfix 1550891: CLSS request returns non-standard 'Class N' reply
|
||||
"""
|
||||
@ -103,7 +103,7 @@ class TestPJLink(TestCase):
|
||||
'Non-standard class reply should have set proper class')
|
||||
|
||||
@patch.object(pjlink_test, 'change_status')
|
||||
def status_change_test(self, mock_change_status):
|
||||
def test_status_change(self, mock_change_status):
|
||||
"""
|
||||
Test process_command call with ERR2 (Parameter) status
|
||||
"""
|
||||
@ -120,7 +120,7 @@ class TestPJLink(TestCase):
|
||||
ERROR_STRING[E_PARAMETER]))
|
||||
|
||||
@patch.object(pjlink_test, 'process_inpt')
|
||||
def projector_return_ok_test(self, mock_process_inpt):
|
||||
def test_projector_return_ok(self, mock_process_inpt):
|
||||
"""
|
||||
Test projector calls process_inpt command when process_command is called with INPT option
|
||||
"""
|
||||
@ -135,7 +135,7 @@ class TestPJLink(TestCase):
|
||||
"process_inpt should have been called with 31")
|
||||
|
||||
@patch.object(pjlink_test, 'projectorReceivedData')
|
||||
def projector_process_lamp_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_lamp(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test status lamp on/off and hours
|
||||
"""
|
||||
@ -152,7 +152,7 @@ class TestPJLink(TestCase):
|
||||
'Lamp hours should have been set to 22222')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorReceivedData')
|
||||
def projector_process_multiple_lamp_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_multiple_lamp(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test status multiple lamp on/off and hours
|
||||
"""
|
||||
@ -179,7 +179,7 @@ class TestPJLink(TestCase):
|
||||
'Lamp 3 hours should have been set to 33333')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorReceivedData')
|
||||
def projector_process_power_on_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_power_on(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test status power to ON
|
||||
"""
|
||||
@ -194,7 +194,7 @@ class TestPJLink(TestCase):
|
||||
self.assertEquals(pjlink.power, S_ON, 'Power should have been set to ON')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorReceivedData')
|
||||
def projector_process_power_off_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_power_off(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test status power to STANDBY
|
||||
"""
|
||||
@ -209,7 +209,7 @@ class TestPJLink(TestCase):
|
||||
self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorUpdateIcons')
|
||||
def projector_process_avmt_closed_unmuted_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_avmt_closed_unmuted(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test avmt status shutter closed and audio muted
|
||||
"""
|
||||
@ -226,7 +226,7 @@ class TestPJLink(TestCase):
|
||||
self.assertFalse(pjlink.mute, 'Audio should be off')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorUpdateIcons')
|
||||
def projector_process_avmt_open_muted_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_avmt_open_muted(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test avmt status shutter open and mute on
|
||||
"""
|
||||
@ -243,7 +243,7 @@ class TestPJLink(TestCase):
|
||||
self.assertTrue(pjlink.mute, 'Audio should be off')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorUpdateIcons')
|
||||
def projector_process_avmt_open_unmuted_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_avmt_open_unmuted(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test avmt status shutter open and mute off off
|
||||
"""
|
||||
@ -260,7 +260,7 @@ class TestPJLink(TestCase):
|
||||
self.assertFalse(pjlink.mute, 'Audio should be on')
|
||||
|
||||
@patch.object(pjlink_test, 'projectorUpdateIcons')
|
||||
def projector_process_avmt_closed_muted_test(self, mock_projectorReceivedData):
|
||||
def test_projector_process_avmt_closed_muted(self, mock_projectorReceivedData):
|
||||
"""
|
||||
Test avmt status shutter closed and mute off
|
||||
"""
|
||||
@ -276,7 +276,7 @@ class TestPJLink(TestCase):
|
||||
self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed')
|
||||
self.assertTrue(pjlink.mute, 'Audio should be on')
|
||||
|
||||
def projector_process_input_test(self):
|
||||
def test_projector_process_input(self):
|
||||
"""
|
||||
Test input source status shows current input
|
||||
"""
|
||||
@ -290,7 +290,7 @@ class TestPJLink(TestCase):
|
||||
# THEN: Input selected should reflect current input
|
||||
self.assertEquals(pjlink.source, '1', 'Input source should be set to "1"')
|
||||
|
||||
def projector_reset_information_test(self):
|
||||
def test_projector_reset_information(self):
|
||||
"""
|
||||
Test reset_information() resets all information and stops timers
|
||||
"""
|
||||
@ -332,3 +332,53 @@ class TestPJLink(TestCase):
|
||||
self.assertFalse(pjlink.send_busy, 'Projector send_busy should be False')
|
||||
self.assertTrue(mock_timer.called, 'Projector timer.stop() should have been called')
|
||||
self.assertTrue(mock_socket_timer.called, 'Projector socket_timer.stop() should have been called')
|
||||
|
||||
@patch.object(pjlink_test, 'send_command')
|
||||
@patch.object(pjlink_test, 'waitForReadyRead')
|
||||
@patch.object(pjlink_test, 'projectorAuthentication')
|
||||
@patch.object(pjlink_test, 'timer')
|
||||
@patch.object(pjlink_test, 'socket_timer')
|
||||
def test_bug_1593882_no_pin_authenticated_connection(self, mock_socket_timer,
|
||||
mock_timer,
|
||||
mock_authentication,
|
||||
mock_ready_read,
|
||||
mock_send_command):
|
||||
"""
|
||||
Test bug 1593882 no pin and authenticated request exception
|
||||
"""
|
||||
# GIVEN: Test object and mocks
|
||||
pjlink = pjlink_test
|
||||
pjlink.pin = None
|
||||
mock_ready_read.return_value = True
|
||||
|
||||
# WHEN: call with authentication request and pin not set
|
||||
pjlink.check_login(data=TEST_CONNECT_AUTHENTICATE)
|
||||
|
||||
# THEN: No Authentication signal should have been sent
|
||||
mock_authentication.emit.assert_called_with(pjlink.name)
|
||||
|
||||
@patch.object(pjlink_test, 'waitForReadyRead')
|
||||
@patch.object(pjlink_test, 'state')
|
||||
@patch.object(pjlink_test, '_send_command')
|
||||
@patch.object(pjlink_test, 'timer')
|
||||
@patch.object(pjlink_test, 'socket_timer')
|
||||
def test_bug_1593883_pjlink_authentication(self, mock_socket_timer,
|
||||
mock_timer,
|
||||
mock_send_command,
|
||||
mock_state,
|
||||
mock_waitForReadyRead):
|
||||
"""
|
||||
Test bugfix 1593883 pjlink authentication
|
||||
"""
|
||||
# GIVEN: Test object and data
|
||||
pjlink = pjlink_test
|
||||
pjlink.pin = TEST_PIN
|
||||
mock_state.return_value = pjlink.ConnectedState
|
||||
mock_waitForReadyRead.return_value = True
|
||||
|
||||
# WHEN: Athenticated connection is called
|
||||
pjlink.check_login(data=TEST_CONNECT_AUTHENTICATE)
|
||||
|
||||
# THEN: send_command should have the proper authentication
|
||||
self.assertEquals("{test}".format(test=mock_send_command.call_args),
|
||||
"call(data='{hash}%1CLSS ?\\r')".format(hash=TEST_HASH))
|
||||
|
@ -107,7 +107,7 @@ class TestProjectorDB(TestCase):
|
||||
time.sleep(1)
|
||||
retries += 1
|
||||
|
||||
def find_record_by_ip_test(self):
|
||||
def test_find_record_by_ip(self):
|
||||
"""
|
||||
Test find record by IP
|
||||
"""
|
||||
@ -121,7 +121,7 @@ class TestProjectorDB(TestCase):
|
||||
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
|
||||
'Record found should have been test_2 data')
|
||||
|
||||
def find_record_by_name_test(self):
|
||||
def test_find_record_by_name(self):
|
||||
"""
|
||||
Test find record by name
|
||||
"""
|
||||
@ -135,7 +135,7 @@ class TestProjectorDB(TestCase):
|
||||
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
|
||||
'Record found should have been test_2 data')
|
||||
|
||||
def record_delete_test(self):
|
||||
def test_record_delete(self):
|
||||
"""
|
||||
Test record can be deleted
|
||||
"""
|
||||
@ -150,7 +150,7 @@ class TestProjectorDB(TestCase):
|
||||
found = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
|
||||
self.assertFalse(found, 'test_3 record should have been deleted')
|
||||
|
||||
def record_edit_test(self):
|
||||
def test_record_edit(self):
|
||||
"""
|
||||
Test edited record returns the same record ID with different data
|
||||
"""
|
||||
@ -176,7 +176,7 @@ class TestProjectorDB(TestCase):
|
||||
self.assertEqual(record_id, record.id, 'Edited record should have the same ID')
|
||||
self.assertTrue(compare_data(Projector(**TEST3_DATA), record), 'Edited record should have new data')
|
||||
|
||||
def source_add_test(self):
|
||||
def test_source_add(self):
|
||||
"""
|
||||
Test source entry for projector item
|
||||
"""
|
||||
@ -194,7 +194,7 @@ class TestProjectorDB(TestCase):
|
||||
item = self.projector.get_projector_by_id(item_id)
|
||||
self.assertTrue(compare_source(item.source_list[0], source))
|
||||
|
||||
def manufacturer_repr_test(self):
|
||||
def test_manufacturer_repr(self):
|
||||
"""
|
||||
Test Manufacturer.__repr__ text
|
||||
"""
|
||||
@ -208,7 +208,7 @@ class TestProjectorDB(TestCase):
|
||||
self.assertEqual(str(manufacturer), '<Manufacturer(name="OpenLP Test")>',
|
||||
'Manufacturer.__repr__() should have returned a proper representation string')
|
||||
|
||||
def model_repr_test(self):
|
||||
def test_model_repr(self):
|
||||
"""
|
||||
Test Model.__repr__ text
|
||||
"""
|
||||
@ -222,7 +222,7 @@ class TestProjectorDB(TestCase):
|
||||
self.assertEqual(str(model), '<Model(name='"OpenLP Test"')>',
|
||||
'Model.__repr__() should have returned a proper representation string')
|
||||
|
||||
def source_repr_test(self):
|
||||
def test_source_repr(self):
|
||||
"""
|
||||
Test Source.__repr__ text
|
||||
"""
|
||||
@ -238,7 +238,7 @@ class TestProjectorDB(TestCase):
|
||||
self.assertEqual(str(source), '<Source(pjlink_name="Test object", pjlink_code="11", text="Input text")>',
|
||||
'Source.__repr__() should have returned a proper representation string')
|
||||
|
||||
def projector_repr_test(self):
|
||||
def test_projector_repr(self):
|
||||
"""
|
||||
Test Projector.__repr__() text
|
||||
"""
|
||||
@ -266,7 +266,7 @@ class TestProjectorDB(TestCase):
|
||||
'source_list="[]") >',
|
||||
'Projector.__repr__() should have returned a proper representation string')
|
||||
|
||||
def projectorsource_repr_test(self):
|
||||
def test_projectorsource_repr(self):
|
||||
"""
|
||||
Test ProjectorSource.__repr__() text
|
||||
"""
|
||||
|
@ -59,7 +59,7 @@ class TestRenderer(TestCase):
|
||||
"""
|
||||
del self.screens
|
||||
|
||||
def default_screen_layout_test(self):
|
||||
def test_default_screen_layout(self):
|
||||
"""
|
||||
Test the default layout calculations
|
||||
"""
|
||||
@ -73,7 +73,7 @@ class TestRenderer(TestCase):
|
||||
self.assertEqual(renderer.footer_start, 691, 'The base renderer should be a live controller')
|
||||
|
||||
@patch('openlp.core.lib.renderer.FormattingTags.get_html_tags')
|
||||
def get_start_tags_test(self, mocked_get_html_tags):
|
||||
def test_get_start_tags(self, mocked_get_html_tags):
|
||||
"""
|
||||
Test the get_start_tags() method
|
||||
"""
|
||||
@ -95,7 +95,7 @@ class TestRenderer(TestCase):
|
||||
self.assertEqual(result, expected_tuple), 'A tuple should be returned containing the text with correct ' \
|
||||
'tags, the opening tags, and the opening html tags.'
|
||||
|
||||
def word_split_test(self):
|
||||
def test_word_split(self):
|
||||
"""
|
||||
Test the word_split() method
|
||||
"""
|
||||
@ -109,7 +109,7 @@ class TestRenderer(TestCase):
|
||||
# THEN: The word lists should be the same.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
|
||||
def format_slide_logical_split_test(self):
|
||||
def test_format_slide_logical_split(self):
|
||||
"""
|
||||
Test that a line with text and a logic break does not break the renderer just returns the input
|
||||
"""
|
||||
@ -126,7 +126,7 @@ class TestRenderer(TestCase):
|
||||
# THEN: The word lists should be the same.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
|
||||
def format_slide_blank_before_split_test(self):
|
||||
def test_format_slide_blank_before_split(self):
|
||||
"""
|
||||
Test that a line with blanks before the logical split at handled
|
||||
"""
|
||||
@ -143,7 +143,7 @@ class TestRenderer(TestCase):
|
||||
# THEN: The blanks have been removed.
|
||||
self.assertListEqual(result_words, expected_words)
|
||||
|
||||
def format_slide_blank_after_split_test(self):
|
||||
def test_format_slide_blank_after_split(self):
|
||||
"""
|
||||
Test that a line with blanks before the logical split at handled
|
||||
"""
|
||||
|
@ -62,7 +62,7 @@ class TestScreenList(TestCase):
|
||||
del self.screens
|
||||
del self.application
|
||||
|
||||
def add_desktop_test(self):
|
||||
def test_add_desktop(self):
|
||||
"""
|
||||
Test the ScreenList.screen_count_changed method to check if new monitors are detected by OpenLP.
|
||||
"""
|
||||
|
@ -54,7 +54,7 @@ class TestServiceItem(TestCase):
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
Registry().register('image_manager', MagicMock())
|
||||
|
||||
def service_item_basic_test(self):
|
||||
def test_service_item_basic(self):
|
||||
"""
|
||||
Test the Service Item - basic test
|
||||
"""
|
||||
@ -67,7 +67,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertTrue(service_item.is_valid, 'The new service item should be valid')
|
||||
self.assertTrue(service_item.missing_frames(), 'There should not be any frames in the service item')
|
||||
|
||||
def service_item_load_custom_from_service_test(self):
|
||||
def test_service_item_load_custom_from_service(self):
|
||||
"""
|
||||
Test the Service Item - adding a custom slide from a saved service
|
||||
"""
|
||||
@ -97,7 +97,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertEqual('Slide 2', service_item.get_frame_title(1), '"Slide 2" has been returned as the title')
|
||||
self.assertEqual('', service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3')
|
||||
|
||||
def service_item_load_image_from_service_test(self):
|
||||
def test_service_item_load_image_from_service(self):
|
||||
"""
|
||||
Test the Service Item - adding an image from a saved service
|
||||
"""
|
||||
@ -112,7 +112,6 @@ class TestServiceItem(TestCase):
|
||||
# WHEN: adding an image from a saved Service and mocked exists
|
||||
line = convert_file_service_item(TEST_PATH, 'serviceitem_image_1.osj')
|
||||
with patch('openlp.core.ui.servicemanager.os.path.exists') as mocked_exists,\
|
||||
patch('openlp.core.lib.serviceitem.create_thumb') as mocked_create_thumb,\
|
||||
patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path') as \
|
||||
mocked_get_section_data_path:
|
||||
mocked_exists.return_value = True
|
||||
@ -141,7 +140,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
|
||||
'This service item should be able to have new items added to it')
|
||||
|
||||
def service_item_load_image_from_local_service_test(self):
|
||||
def test_service_item_load_image_from_local_service(self):
|
||||
"""
|
||||
Test the Service Item - adding an image from a saved local service
|
||||
"""
|
||||
@ -164,7 +163,6 @@ class TestServiceItem(TestCase):
|
||||
line2 = convert_file_service_item(TEST_PATH, 'serviceitem_image_2.osj', 1)
|
||||
|
||||
with patch('openlp.core.ui.servicemanager.os.path.exists') as mocked_exists, \
|
||||
patch('openlp.core.lib.serviceitem.create_thumb') as mocked_create_thumb, \
|
||||
patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path') as \
|
||||
mocked_get_section_data_path:
|
||||
mocked_exists.return_value = True
|
||||
@ -206,7 +204,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend),
|
||||
'This service item should be able to have new items added to it')
|
||||
|
||||
def add_from_command_for_a_presentation_test(self):
|
||||
def test_add_from_command_for_a_presentation(self):
|
||||
"""
|
||||
Test the Service Item - adding a presentation
|
||||
"""
|
||||
@ -226,7 +224,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
|
||||
def add_from_comamnd_without_display_title_and_notes_test(self):
|
||||
def test_add_from_comamnd_without_display_title_and_notes(self):
|
||||
"""
|
||||
Test the Service Item - add from command, but not presentation
|
||||
"""
|
||||
@ -246,7 +244,7 @@ class TestServiceItem(TestCase):
|
||||
|
||||
@patch(u'openlp.core.lib.serviceitem.ServiceItem.image_manager')
|
||||
@patch('openlp.core.lib.serviceitem.AppLocation.get_section_data_path')
|
||||
def add_from_command_for_a_presentation_thumb_test(self, mocked_get_section_data_path, mocked_image_manager):
|
||||
def test_add_from_command_for_a_presentation_thumb(self, mocked_get_section_data_path, mocked_image_manager):
|
||||
"""
|
||||
Test the Service Item - adding a presentation, updating the thumb path & adding the thumb to image_manager
|
||||
"""
|
||||
@ -274,7 +272,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
|
||||
self.assertEqual(1, mocked_image_manager.add_image.call_count, 'image_manager should be used')
|
||||
|
||||
def service_item_load_optical_media_from_service_test(self):
|
||||
def test_service_item_load_optical_media_from_service(self):
|
||||
"""
|
||||
Test the Service Item - load an optical media item
|
||||
"""
|
||||
@ -295,7 +293,7 @@ class TestServiceItem(TestCase):
|
||||
self.assertEqual(service_item.end_time, 672.069, 'End time should be 672.069')
|
||||
self.assertEqual(service_item.media_length, 17.694, 'Media length should be 17.694')
|
||||
|
||||
def service_item_load_song_and_audio_from_service_test(self):
|
||||
def test_service_item_load_song_and_audio_from_service(self):
|
||||
"""
|
||||
Test the Service Item - adding a song slide from a saved service
|
||||
"""
|
||||
|
@ -44,7 +44,7 @@ class TestTheme(TestCase):
|
||||
"""
|
||||
pass
|
||||
|
||||
def new_theme_test(self):
|
||||
def test_new_theme(self):
|
||||
"""
|
||||
Test the theme creation - basic test
|
||||
"""
|
||||
|
@ -37,7 +37,7 @@ class TestUi(TestCase):
|
||||
Test the functions in the ui module
|
||||
"""
|
||||
|
||||
def add_welcome_page_test(self):
|
||||
def test_add_welcome_page(self):
|
||||
"""
|
||||
Test appending a welcome page to a wizard
|
||||
"""
|
||||
@ -51,7 +51,7 @@ class TestUi(TestCase):
|
||||
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
|
||||
self.assertIsInstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
||||
|
||||
def create_button_box_test(self):
|
||||
def test_create_button_box(self):
|
||||
"""
|
||||
Test creating a button box for a dialog
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class TestUi(TestCase):
|
||||
self.assertEqual(1, len(btnbox.buttons()))
|
||||
self.assertEqual(QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
||||
|
||||
def create_horizontal_adjusting_combo_box_test(self):
|
||||
def test_create_horizontal_adjusting_combo_box(self):
|
||||
"""
|
||||
Test creating a horizontal adjusting combo box
|
||||
"""
|
||||
@ -94,7 +94,7 @@ class TestUi(TestCase):
|
||||
self.assertEqual('combo1', combo.objectName())
|
||||
self.assertEqual(QtWidgets.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy())
|
||||
|
||||
def create_button_test(self):
|
||||
def test_create_button(self):
|
||||
"""
|
||||
Test creating a button
|
||||
"""
|
||||
@ -126,7 +126,7 @@ class TestUi(TestCase):
|
||||
self.assertEqual('my_btn', btn.objectName())
|
||||
self.assertTrue(btn.isEnabled())
|
||||
|
||||
def create_action_test(self):
|
||||
def test_create_action(self):
|
||||
"""
|
||||
Test creating an action
|
||||
"""
|
||||
@ -151,7 +151,7 @@ class TestUi(TestCase):
|
||||
self.assertEqual('my tooltip', action.toolTip())
|
||||
self.assertEqual('my statustip', action.statusTip())
|
||||
|
||||
def create_action_on_mac_osx_test(self):
|
||||
def test_create_action_on_mac_osx(self):
|
||||
"""
|
||||
Test creating an action on OS X calls the correct method
|
||||
"""
|
||||
@ -169,7 +169,7 @@ class TestUi(TestCase):
|
||||
# THEN: setIconVisibleInMenu should be called
|
||||
mocked_action.setIconVisibleInMenu.assert_called_with(False)
|
||||
|
||||
def create_action_not_on_mac_osx_test(self):
|
||||
def test_create_action_not_on_mac_osx(self):
|
||||
"""
|
||||
Test creating an action on something other than OS X doesn't call the method
|
||||
"""
|
||||
@ -188,7 +188,7 @@ class TestUi(TestCase):
|
||||
self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
|
||||
'setIconVisibleInMenu should not have been called')
|
||||
|
||||
def create_checked_disabled_invisible_action_test(self):
|
||||
def test_create_checked_disabled_invisible_action(self):
|
||||
"""
|
||||
Test that an invisible, disabled, checked action is created correctly
|
||||
"""
|
||||
@ -203,7 +203,7 @@ class TestUi(TestCase):
|
||||
self.assertFalse(action.isEnabled(), 'The action should be disabled')
|
||||
self.assertFalse(action.isVisible(), 'The action should be invisble')
|
||||
|
||||
def create_action_separator_test(self):
|
||||
def test_create_action_separator(self):
|
||||
"""
|
||||
Test creating an action as separator
|
||||
"""
|
||||
@ -216,7 +216,7 @@ class TestUi(TestCase):
|
||||
# THEN: The action should be a separator
|
||||
self.assertTrue(action.isSeparator(), 'The action should be a separator')
|
||||
|
||||
def create_valign_selection_widgets_test(self):
|
||||
def test_create_valign_selection_widgets(self):
|
||||
"""
|
||||
Test creating a combo box for valign selection
|
||||
"""
|
||||
@ -233,7 +233,7 @@ class TestUi(TestCase):
|
||||
for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]:
|
||||
self.assertTrue(combo.findText(text) >= 0)
|
||||
|
||||
def find_and_set_in_combo_box_test(self):
|
||||
def test_find_and_set_in_combo_box(self):
|
||||
"""
|
||||
Test finding a string in a combo box and setting it as the selected item if present
|
||||
"""
|
||||
@ -260,7 +260,7 @@ class TestUi(TestCase):
|
||||
# THEN: The index should have changed
|
||||
self.assertEqual(2, combo.currentIndex())
|
||||
|
||||
def create_widget_action_test(self):
|
||||
def test_create_widget_action(self):
|
||||
"""
|
||||
Test creating an action for a widget
|
||||
"""
|
||||
@ -274,7 +274,7 @@ class TestUi(TestCase):
|
||||
self.assertIsInstance(action, QtWidgets.QAction)
|
||||
self.assertEqual(action.objectName(), 'some action')
|
||||
|
||||
def set_case_insensitive_completer_test(self):
|
||||
def test_set_case_insensitive_completer(self):
|
||||
"""
|
||||
Test setting a case insensitive completer on a widget
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ class TestUtils(TestCase):
|
||||
"""
|
||||
A test suite to test out various methods around the AppLocation class.
|
||||
"""
|
||||
def get_user_agent_linux_test(self):
|
||||
def test_get_user_agent_linux(self):
|
||||
"""
|
||||
Test that getting a user agent on Linux returns a user agent suitable for Linux
|
||||
"""
|
||||
@ -49,7 +49,7 @@ class TestUtils(TestCase):
|
||||
result = 'Linux' in user_agent or 'CrOS' in user_agent
|
||||
self.assertTrue(result, 'The user agent should be a valid Linux user agent')
|
||||
|
||||
def get_user_agent_windows_test(self):
|
||||
def test_get_user_agent_windows(self):
|
||||
"""
|
||||
Test that getting a user agent on Windows returns a user agent suitable for Windows
|
||||
"""
|
||||
@ -64,7 +64,7 @@ class TestUtils(TestCase):
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
self.assertIn('Windows', user_agent, 'The user agent should be a valid Windows user agent')
|
||||
|
||||
def get_user_agent_macos_test(self):
|
||||
def test_get_user_agent_macos(self):
|
||||
"""
|
||||
Test that getting a user agent on OS X returns a user agent suitable for OS X
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class TestUtils(TestCase):
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
self.assertIn('Mac OS X', user_agent, 'The user agent should be a valid OS X user agent')
|
||||
|
||||
def get_user_agent_default_test(self):
|
||||
def test_get_user_agent_default(self):
|
||||
"""
|
||||
Test that getting a user agent on a non-Linux/Windows/OS X platform returns the default user agent
|
||||
"""
|
||||
@ -94,7 +94,7 @@ class TestUtils(TestCase):
|
||||
# THEN: The user agent is a Linux (or ChromeOS) user agent
|
||||
self.assertIn('NetBSD', user_agent, 'The user agent should be the default user agent')
|
||||
|
||||
def get_web_page_no_url_test(self):
|
||||
def test_get_web_page_no_url(self):
|
||||
"""
|
||||
Test that sending a URL of None to the get_web_page method returns None
|
||||
"""
|
||||
@ -107,7 +107,7 @@ class TestUtils(TestCase):
|
||||
# THEN: None should be returned
|
||||
self.assertIsNone(result, 'The return value of get_web_page should be None')
|
||||
|
||||
def get_web_page_test(self):
|
||||
def test_get_web_page(self):
|
||||
"""
|
||||
Test that the get_web_page method works correctly
|
||||
"""
|
||||
@ -137,7 +137,7 @@ class TestUtils(TestCase):
|
||||
self.assertEqual(0, MockRegistry.call_count, 'The Registry() object should have never been called')
|
||||
self.assertEqual(mocked_page_object, returned_page, 'The returned page should be the mock object')
|
||||
|
||||
def get_web_page_with_header_test(self):
|
||||
def test_get_web_page_with_header(self):
|
||||
"""
|
||||
Test that adding a header to the call to get_web_page() adds the header to the request
|
||||
"""
|
||||
@ -166,7 +166,7 @@ class TestUtils(TestCase):
|
||||
mocked_page_object.geturl.assert_called_with()
|
||||
self.assertEqual(mocked_page_object, returned_page, 'The returned page should be the mock object')
|
||||
|
||||
def get_web_page_with_user_agent_in_headers_test(self):
|
||||
def test_get_web_page_with_user_agent_in_headers(self):
|
||||
"""
|
||||
Test that adding a user agent in the header when calling get_web_page() adds that user agent to the request
|
||||
"""
|
||||
@ -194,7 +194,7 @@ class TestUtils(TestCase):
|
||||
mocked_page_object.geturl.assert_called_with()
|
||||
self.assertEqual(mocked_page_object, returned_page, 'The returned page should be the mock object')
|
||||
|
||||
def get_web_page_update_openlp_test(self):
|
||||
def test_get_web_page_update_openlp(self):
|
||||
"""
|
||||
Test that passing "update_openlp" as true to get_web_page calls Registry().get('app').process_events()
|
||||
"""
|
||||
|
@ -38,7 +38,7 @@ class TestFirstTimeWizard(TestMixin, TestCase):
|
||||
"""
|
||||
Test First Time Wizard import functions
|
||||
"""
|
||||
def webpage_connection_retry_test(self):
|
||||
def test_webpage_connection_retry(self):
|
||||
"""
|
||||
Test get_web_page will attempt CONNECTION_RETRIES+1 connections - bug 1409031
|
||||
"""
|
||||
|
@ -78,7 +78,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
if os.path.isfile(self.tempfile):
|
||||
os.remove(self.tempfile)
|
||||
|
||||
def initialise_test(self):
|
||||
def test_initialise(self):
|
||||
"""
|
||||
Test if we can intialise the FirstTimeForm
|
||||
"""
|
||||
@ -97,7 +97,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
self.assertListEqual([], frw.theme_screenshot_workers, 'The list of workers should be empty')
|
||||
self.assertFalse(frw.has_run_wizard, 'has_run_wizard should be False')
|
||||
|
||||
def set_defaults_test(self):
|
||||
def test_set_defaults(self):
|
||||
"""
|
||||
Test that the default values are set when set_defaults() is run
|
||||
"""
|
||||
@ -134,7 +134,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
mocked_gettempdir.assert_called_with()
|
||||
mocked_check_directory_exists.assert_called_with(expected_temp_path)
|
||||
|
||||
def update_screen_list_combo_test(self):
|
||||
def test_update_screen_list_combo(self):
|
||||
"""
|
||||
Test that the update_screen_list_combo() method works correctly
|
||||
"""
|
||||
@ -157,7 +157,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
mocked_display_combo_box.count.assert_called_with()
|
||||
mocked_display_combo_box.setCurrentIndex.assert_called_with(1)
|
||||
|
||||
def on_cancel_button_clicked_test(self):
|
||||
def test_on_cancel_button_clicked(self):
|
||||
"""
|
||||
Test that the cancel button click slot shuts down the threads correctly
|
||||
"""
|
||||
@ -184,7 +184,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
self.assertEqual(1, mocked_time.sleep.call_count, 'sleep() should have only been called once')
|
||||
mocked_set_normal_cursor.assert_called_with()
|
||||
|
||||
def broken_config_test(self):
|
||||
def test_broken_config(self):
|
||||
"""
|
||||
Test if we can handle an config file with missing data
|
||||
"""
|
||||
@ -200,7 +200,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
# THEN: The First Time Form should not have web access
|
||||
self.assertFalse(first_time_form.web_access, 'There should not be web access with a broken config file')
|
||||
|
||||
def invalid_config_test(self):
|
||||
def test_invalid_config(self):
|
||||
"""
|
||||
Test if we can handle an config file in invalid format
|
||||
"""
|
||||
@ -218,7 +218,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
|
||||
@patch('openlp.core.ui.firsttimeform.get_web_page')
|
||||
@patch('openlp.core.ui.firsttimeform.QtWidgets.QMessageBox')
|
||||
def network_error_test(self, mocked_message_box, mocked_get_web_page):
|
||||
def test_network_error(self, mocked_message_box, mocked_get_web_page):
|
||||
"""
|
||||
Test we catch a network error in First Time Wizard - bug 1409627
|
||||
"""
|
||||
@ -238,7 +238,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
||||
'first_time_form should have caught Network Error')
|
||||
|
||||
@patch('openlp.core.ui.firsttimeform.urllib.request.urlopen')
|
||||
def socket_timeout_test(self, mocked_urlopen):
|
||||
def test_socket_timeout(self, mocked_urlopen):
|
||||
"""
|
||||
Test socket timeout gets caught
|
||||
"""
|
||||
|
@ -32,7 +32,7 @@ class TestFormattingTagController(TestCase):
|
||||
def setUp(self):
|
||||
self.services = FormattingTagController()
|
||||
|
||||
def strip_test(self):
|
||||
def test_strip(self):
|
||||
"""
|
||||
Test that the _strip strips the correct chars
|
||||
"""
|
||||
@ -45,7 +45,7 @@ class TestFormattingTagController(TestCase):
|
||||
# THEN: The tag should be returned with the wrappers removed.
|
||||
self.assertEqual(result, 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'')
|
||||
|
||||
def end_tag_changed_processes_correctly_test(self):
|
||||
def test_end_tag_changed_processes_correctly(self):
|
||||
"""
|
||||
Test that the end html tags are generated correctly
|
||||
"""
|
||||
@ -70,7 +70,7 @@ class TestFormattingTagController(TestCase):
|
||||
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
|
||||
error)
|
||||
|
||||
def start_tag_changed_processes_correctly_test(self):
|
||||
def test_start_tag_changed_processes_correctly(self):
|
||||
"""
|
||||
Test that the end html tags are generated correctly
|
||||
"""
|
||||
@ -93,7 +93,7 @@ class TestFormattingTagController(TestCase):
|
||||
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
|
||||
error)
|
||||
|
||||
def start_html_to_end_html_test(self):
|
||||
def test_start_html_to_end_html(self):
|
||||
"""
|
||||
Test that the end html tags are generated correctly
|
||||
"""
|
||||
|
@ -50,7 +50,7 @@ class TestFormattingTagForm(TestCase):
|
||||
"""
|
||||
self.setup_patcher.stop()
|
||||
|
||||
def on_row_selected_test(self):
|
||||
def test_on_row_selected(self):
|
||||
"""
|
||||
Test that the appropriate actions are preformed when on_row_selected is called
|
||||
"""
|
||||
@ -64,7 +64,7 @@ class TestFormattingTagForm(TestCase):
|
||||
# THEN: setEnabled and should have been called on delete_button
|
||||
form.delete_button.setEnabled.assert_called_with(True)
|
||||
|
||||
def on_new_clicked_test(self):
|
||||
def test_on_new_clicked(self):
|
||||
"""
|
||||
Test that clicking the Add a new tag button does the right thing
|
||||
"""
|
||||
|
@ -70,7 +70,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
self.mocked_audio_player.stop()
|
||||
del self.screens
|
||||
|
||||
def initial_main_display_test(self):
|
||||
def test_initial_main_display(self):
|
||||
"""
|
||||
Test the initial Main Display state
|
||||
"""
|
||||
@ -84,7 +84,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
# THEN: The controller should be a live controller.
|
||||
self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
|
||||
|
||||
def set_transparency_enabled_test(self):
|
||||
def test_set_transparency_enabled(self):
|
||||
"""
|
||||
Test setting the display to be transparent
|
||||
"""
|
||||
@ -103,7 +103,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
|
||||
'The MainDisplay should have a translucent background')
|
||||
|
||||
def set_transparency_disabled_test(self):
|
||||
def test_set_transparency_disabled(self):
|
||||
"""
|
||||
Test setting the display to be opaque
|
||||
"""
|
||||
@ -120,7 +120,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
|
||||
'The MainDisplay should not have a translucent background')
|
||||
|
||||
def css_changed_test(self):
|
||||
def test_css_changed(self):
|
||||
"""
|
||||
Test that when the CSS changes, the plugins are looped over and given an opportunity to update the CSS
|
||||
"""
|
||||
@ -143,7 +143,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)
|
||||
|
||||
@skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
|
||||
def macosx_display_window_flags_state_test(self):
|
||||
def test_macosx_display_window_flags_state(self):
|
||||
"""
|
||||
Test that on Mac OS X we set the proper window flags
|
||||
"""
|
||||
@ -160,7 +160,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
'The window flags should be Qt.Window, and Qt.FramelessWindowHint.')
|
||||
|
||||
@skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
|
||||
def macosx_display_test(self):
|
||||
def test_macosx_display(self):
|
||||
"""
|
||||
Test display on Mac OS X
|
||||
"""
|
||||
@ -186,7 +186,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
'Window collection behavior should be NSWindowCollectionBehaviorManaged')
|
||||
|
||||
@patch(u'openlp.core.ui.maindisplay.Settings')
|
||||
def show_display_startup_logo_test(self, MockedSettings):
|
||||
def test_show_display_startup_logo(self, MockedSettings):
|
||||
# GIVEN: Mocked show_display, setting for logo visibility
|
||||
display = MagicMock()
|
||||
main_display = MainDisplay(display)
|
||||
@ -206,7 +206,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
main_display.setVisible.assert_called_once_with(True)
|
||||
|
||||
@patch(u'openlp.core.ui.maindisplay.Settings')
|
||||
def show_display_hide_startup_logo_test(self, MockedSettings):
|
||||
def test_show_display_hide_startup_logo(self, MockedSettings):
|
||||
# GIVEN: Mocked show_display, setting for logo visibility
|
||||
display = MagicMock()
|
||||
main_display = MainDisplay(display)
|
||||
@ -227,7 +227,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
|
||||
@patch(u'openlp.core.ui.maindisplay.Settings')
|
||||
@patch(u'openlp.core.ui.maindisplay.build_html')
|
||||
def build_html_no_video_test(self, MockedSettings, Mocked_build_html):
|
||||
def test_build_html_no_video(self, MockedSettings, Mocked_build_html):
|
||||
# GIVEN: Mocked display
|
||||
display = MagicMock()
|
||||
mocked_media_controller = MagicMock()
|
||||
@ -255,7 +255,7 @@ class TestMainDisplay(TestCase, TestMixin):
|
||||
|
||||
@patch(u'openlp.core.ui.maindisplay.Settings')
|
||||
@patch(u'openlp.core.ui.maindisplay.build_html')
|
||||
def build_html_video_test(self, MockedSettings, Mocked_build_html):
|
||||
def test_build_html_video(self, MockedSettings, Mocked_build_html):
|
||||
# GIVEN: Mocked display
|
||||
display = MagicMock()
|
||||
mocked_media_controller = MagicMock()
|
||||
|
@ -72,7 +72,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
def tearDown(self):
|
||||
del self.main_window
|
||||
|
||||
def cmd_line_file_test(self):
|
||||
def test_cmd_line_file(self):
|
||||
"""
|
||||
Test that passing a service file from the command line loads the service.
|
||||
"""
|
||||
@ -87,7 +87,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
# THEN the service from the arguments is loaded
|
||||
mocked_load_path.assert_called_with(service), 'load_path should have been called with the service\'s path'
|
||||
|
||||
def cmd_line_arg_test(self):
|
||||
def test_cmd_line_arg(self):
|
||||
"""
|
||||
Test that passing a non service file does nothing.
|
||||
"""
|
||||
@ -102,7 +102,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
# THEN the file should not be opened
|
||||
assert not mocked_load_path.called, 'load_path should not have been called'
|
||||
|
||||
def main_window_title_test(self):
|
||||
def test_main_window_title(self):
|
||||
"""
|
||||
Test that running a new instance of OpenLP set the window title correctly
|
||||
"""
|
||||
@ -114,7 +114,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
self.assertEqual(self.main_window.windowTitle(), UiStrings().OLP,
|
||||
'The main window\'s title should be the same as the OLP string in UiStrings class')
|
||||
|
||||
def set_service_modifed_test(self):
|
||||
def test_set_service_modifed(self):
|
||||
"""
|
||||
Test that when setting the service's title the main window's title is set correctly
|
||||
"""
|
||||
@ -127,7 +127,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OLP, 'test.osz'),
|
||||
'The main window\'s title should be set to "<the contents of UiStrings().OLP> - test.osz*"')
|
||||
|
||||
def set_service_unmodified_test(self):
|
||||
def test_set_service_unmodified(self):
|
||||
"""
|
||||
Test that when setting the service's title the main window's title is set correctly
|
||||
"""
|
||||
@ -140,7 +140,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OLP, 'test.osz'),
|
||||
'The main window\'s title should be set to "<the contents of UiStrings().OLP> - test.osz"')
|
||||
|
||||
def mainwindow_configuration_test(self):
|
||||
def test_mainwindow_configuration(self):
|
||||
"""
|
||||
Check that the Main Window initialises the Registry Correctly
|
||||
"""
|
||||
@ -158,7 +158,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
self.assertTrue('plugin_manager' in self.registry.service_list,
|
||||
'The plugin_manager should have been registered.')
|
||||
|
||||
def on_search_shortcut_triggered_shows_media_manager_test(self):
|
||||
def test_on_search_shortcut_triggered_shows_media_manager(self):
|
||||
"""
|
||||
Test that the media manager is made visible when the search shortcut is triggered
|
||||
"""
|
||||
@ -174,7 +174,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
# THEN: The media manager dock is made visible
|
||||
mocked_media_manager_dock.setVisible.assert_called_with(True)
|
||||
|
||||
def on_search_shortcut_triggered_focuses_widget_test(self):
|
||||
def test_on_search_shortcut_triggered_focuses_widget(self):
|
||||
"""
|
||||
Test that the focus is set on the widget when the search shortcut is triggered
|
||||
"""
|
||||
@ -198,7 +198,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
|
||||
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.warning')
|
||||
@patch('openlp.core.ui.mainwindow.Settings')
|
||||
def on_first_time_wizard_clicked_show_projectors_after_test(self, mocked_Settings, mocked_warning,
|
||||
def test_on_first_time_wizard_clicked_show_projectors_after(self, mocked_Settings, mocked_warning,
|
||||
mocked_FirstTimeForm, mocked_application,
|
||||
mocked_first_time,
|
||||
mocked_plugin_manager):
|
||||
@ -225,7 +225,7 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
|
||||
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.warning')
|
||||
@patch('openlp.core.ui.mainwindow.Settings')
|
||||
def on_first_time_wizard_clicked_hide_projectors_after_test(self, mocked_Settings, mocked_warning,
|
||||
def test_on_first_time_wizard_clicked_hide_projectors_after(self, mocked_Settings, mocked_warning,
|
||||
mocked_FirstTimeForm, mocked_application,
|
||||
mocked_first_time,
|
||||
mocked_plugin_manager):
|
||||
|
@ -22,10 +22,12 @@
|
||||
"""
|
||||
Package to test the openlp.core.ui.slidecontroller package.
|
||||
"""
|
||||
import PyQt5
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from openlp.core.common import Registry, ThemeLevel, Settings
|
||||
import PyQt5
|
||||
|
||||
from openlp.core.common import Registry, ThemeLevel
|
||||
from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities
|
||||
from openlp.core.ui import ServiceManager
|
||||
|
||||
@ -33,6 +35,9 @@ from tests.functional import MagicMock, patch
|
||||
|
||||
|
||||
class TestServiceManager(TestCase):
|
||||
"""
|
||||
Test the service manager
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
@ -40,7 +45,7 @@ class TestServiceManager(TestCase):
|
||||
"""
|
||||
Registry.create()
|
||||
|
||||
def initial_service_manager_test(self):
|
||||
def test_initial_service_manager(self):
|
||||
"""
|
||||
Test the initial of service manager.
|
||||
"""
|
||||
@ -50,7 +55,7 @@ class TestServiceManager(TestCase):
|
||||
# THEN: The the controller should be registered in the registry.
|
||||
self.assertNotEqual(Registry().get('service_manager'), None, 'The base service manager should be registered')
|
||||
|
||||
def create_basic_service_test(self):
|
||||
def test_create_basic_service(self):
|
||||
"""
|
||||
Test the create basic service array
|
||||
"""
|
||||
@ -65,7 +70,7 @@ class TestServiceManager(TestCase):
|
||||
self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved')
|
||||
self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved')
|
||||
|
||||
def supported_suffixes_test(self):
|
||||
def test_supported_suffixes(self):
|
||||
"""
|
||||
Test the create basic service array
|
||||
"""
|
||||
@ -79,7 +84,7 @@ class TestServiceManager(TestCase):
|
||||
self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list')
|
||||
self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list')
|
||||
|
||||
def build_context_menu_test(self):
|
||||
def test_build_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from a null service item.
|
||||
"""
|
||||
@ -108,22 +113,22 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have been called once')
|
||||
|
||||
def build_song_context_menu_test(self):
|
||||
def test_build_song_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type text from Songs.
|
||||
"""
|
||||
@ -139,12 +144,10 @@ class TestServiceManager(TestCase):
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.CanEdit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
||||
service_item.add_capability(ItemCapabilities.AddIfNewItem)
|
||||
service_item.add_capability(ItemCapabilities.CanSoftBreak)
|
||||
for capability in [ItemCapabilities.CanEdit, ItemCapabilities.CanPreview, ItemCapabilities.CanLoop,
|
||||
ItemCapabilities.OnLoadUpdate, ItemCapabilities.AddIfNewItem,
|
||||
ItemCapabilities.CanSoftBreak]:
|
||||
service_item.add_capability(capability)
|
||||
service_item.service_item_type = ServiceItemType.Text
|
||||
service_item.edit_id = 1
|
||||
service_item._display_frames.append(MagicMock())
|
||||
@ -165,31 +168,31 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_bible_context_menu_test(self):
|
||||
def test_build_bible_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type text from Bibles.
|
||||
"""
|
||||
@ -205,11 +208,10 @@ class TestServiceManager(TestCase):
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
service_manager.service_manager_list.itemAt.return_value = item
|
||||
service_item = ServiceItem(None)
|
||||
service_item.add_capability(ItemCapabilities.NoLineBreaks)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanWordSplit)
|
||||
service_item.add_capability(ItemCapabilities.CanEditTitle)
|
||||
for capability in [ItemCapabilities.NoLineBreaks, ItemCapabilities.CanPreview,
|
||||
ItemCapabilities.CanLoop, ItemCapabilities.CanWordSplit,
|
||||
ItemCapabilities.CanEditTitle]:
|
||||
service_item.add_capability(capability)
|
||||
service_item.service_item_type = ServiceItemType.Text
|
||||
service_item.edit_id = 1
|
||||
service_item._display_frames.append(MagicMock())
|
||||
@ -230,31 +232,31 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_custom_context_menu_test(self):
|
||||
def test_build_custom_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type text from Custom.
|
||||
"""
|
||||
@ -295,31 +297,31 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
# THEN we add a 2nd display frame
|
||||
service_item._display_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_image_context_menu_test(self):
|
||||
def test_build_image_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Image from Image.
|
||||
"""
|
||||
@ -358,31 +360,31 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
# THEN we add a 2nd display frame and regenerate the menu.
|
||||
service_item._raw_frames.append(MagicMock())
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
|
||||
'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
|
||||
|
||||
def build_media_context_menu_test(self):
|
||||
def test_build_media_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Command from Media.
|
||||
"""
|
||||
@ -419,27 +421,27 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
# THEN I change the length of the media and regenerate the menu.
|
||||
service_item.set_media_length(5)
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following additional calls should have occurred.
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
|
||||
|
||||
def build_presentation_pdf_context_menu_test(self):
|
||||
def test_build_presentation_pdf_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Command with PDF from Presentation.
|
||||
"""
|
||||
@ -477,22 +479,22 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
|
||||
def build_presentation_non_pdf_context_menu_test(self):
|
||||
def test_build_presentation_non_pdf_context_menu(self):
|
||||
"""
|
||||
Test the creation of a context menu from service item of type Command with Impress from Presentation.
|
||||
"""
|
||||
@ -527,24 +529,24 @@ class TestServiceManager(TestCase):
|
||||
# WHEN I define a context menu
|
||||
service_manager.context_menu(1)
|
||||
# THEN the following calls should have occurred.
|
||||
self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
|
||||
'Should have be called once')
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.Settings')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
def single_click_preview_test_true(self, mocked_singleShot, MockedSettings):
|
||||
def test_single_click_preview_true(self, mocked_singleShot, MockedSettings):
|
||||
"""
|
||||
Test that when "Preview items when clicked in Service Manager" enabled the preview timer starts
|
||||
"""
|
||||
@ -561,7 +563,7 @@ class TestServiceManager(TestCase):
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.Settings')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
def single_click_preview_test_false(self, mocked_singleShot, MockedSettings):
|
||||
def test_single_click_preview_false(self, mocked_singleShot, MockedSettings):
|
||||
"""
|
||||
Test that when "Preview items when clicked in Service Manager" disabled the preview timer doesn't start
|
||||
"""
|
||||
@ -573,12 +575,12 @@ class TestServiceManager(TestCase):
|
||||
# WHEN: on_single_click_preview() is called
|
||||
service_manager.on_single_click_preview()
|
||||
# THEN: timer should not be started
|
||||
self.assertEquals(mocked_singleShot.call_count, 0, 'Should not be called')
|
||||
self.assertEqual(mocked_singleShot.call_count, 0, 'Should not be called')
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.Settings')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.make_live')
|
||||
def single_click_preview_test_double(self, mocked_make_live, mocked_singleShot, MockedSettings):
|
||||
def test_single_click_preview_double(self, mocked_make_live, mocked_singleShot, MockedSettings):
|
||||
"""
|
||||
Test that when a double click has registered the preview timer doesn't start
|
||||
"""
|
||||
@ -591,10 +593,11 @@ class TestServiceManager(TestCase):
|
||||
service_manager.on_double_click_live()
|
||||
service_manager.on_single_click_preview()
|
||||
# THEN: timer should not be started
|
||||
self.assertEquals(mocked_singleShot.call_count, 0, 'Should not be called')
|
||||
mocked_make_live.assert_called_with()
|
||||
self.assertEqual(mocked_singleShot.call_count, 0, 'Should not be called')
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.make_preview')
|
||||
def single_click_timeout_test_single(self, mocked_make_preview):
|
||||
def test_single_click_timeout_single(self, mocked_make_preview):
|
||||
"""
|
||||
Test that when a single click has been registered, the item is sent to preview
|
||||
"""
|
||||
@ -603,11 +606,12 @@ class TestServiceManager(TestCase):
|
||||
# WHEN: on_single_click_preview() is called
|
||||
service_manager.on_single_click_preview_timeout()
|
||||
# THEN: make_preview() should have been called
|
||||
self.assertEquals(mocked_make_preview.call_count, 1, 'Should have been called once')
|
||||
self.assertEqual(mocked_make_preview.call_count, 1,
|
||||
'ServiceManager.make_preview() should have been called once')
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.make_preview')
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.make_live')
|
||||
def single_click_timeout_test_double(self, mocked_make_live, mocked_make_preview):
|
||||
def test_single_click_timeout_double(self, mocked_make_live, mocked_make_preview):
|
||||
"""
|
||||
Test that when a double click has been registered, the item does not goes to preview
|
||||
"""
|
||||
@ -616,5 +620,62 @@ class TestServiceManager(TestCase):
|
||||
# WHEN: on_single_click_preview() is called after a double click
|
||||
service_manager.on_double_click_live()
|
||||
service_manager.on_single_click_preview_timeout()
|
||||
# THEN: make_preview() should have been called
|
||||
self.assertEquals(mocked_make_preview.call_count, 0, 'Should not be called')
|
||||
# THEN: make_preview() should not have been called
|
||||
self.assertEqual(mocked_make_preview.call_count, 0, 'ServiceManager.make_preview() should not be called')
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.shutil.copy')
|
||||
@patch(u'openlp.core.ui.servicemanager.zipfile')
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.save_file_as')
|
||||
def test_save_file_raises_permission_error(self, mocked_save_file_as, mocked_zipfile, mocked_shutil_copy):
|
||||
"""
|
||||
Test that when a PermissionError is raised when trying to save a file, it is handled correctly
|
||||
"""
|
||||
# GIVEN: A service manager, a service to save
|
||||
mocked_main_window = MagicMock()
|
||||
mocked_main_window.service_manager_settings_section = 'servicemanager'
|
||||
Registry().register('main_window', mocked_main_window)
|
||||
Registry().register('application', MagicMock())
|
||||
service_manager = ServiceManager(None)
|
||||
service_manager._file_name = os.path.join('temp', 'filename.osz')
|
||||
service_manager._save_lite = False
|
||||
service_manager.service_items = []
|
||||
service_manager.service_theme = 'Default'
|
||||
service_manager.service_manager_list = MagicMock()
|
||||
mocked_save_file_as.return_value = True
|
||||
mocked_zipfile.ZipFile.return_value = MagicMock()
|
||||
mocked_shutil_copy.side_effect = PermissionError
|
||||
|
||||
# WHEN: The service is saved and a PermissionError is thrown
|
||||
result = service_manager.save_file()
|
||||
|
||||
# THEN: The "save_as" method is called to save the service
|
||||
self.assertTrue(result)
|
||||
mocked_save_file_as.assert_called_with()
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.shutil.copy')
|
||||
@patch(u'openlp.core.ui.servicemanager.zipfile')
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.save_file_as')
|
||||
def test_save_local_file_raises_permission_error(self, mocked_save_file_as, mocked_zipfile, mocked_shutil_copy):
|
||||
"""
|
||||
Test that when a PermissionError is raised when trying to save a local file, it is handled correctly
|
||||
"""
|
||||
# GIVEN: A service manager, a service to save
|
||||
mocked_main_window = MagicMock()
|
||||
mocked_main_window.service_manager_settings_section = 'servicemanager'
|
||||
Registry().register('main_window', mocked_main_window)
|
||||
Registry().register('application', MagicMock())
|
||||
service_manager = ServiceManager(None)
|
||||
service_manager._file_name = os.path.join('temp', 'filename.osz')
|
||||
service_manager._save_lite = False
|
||||
service_manager.service_items = []
|
||||
service_manager.service_theme = 'Default'
|
||||
mocked_save_file_as.return_value = True
|
||||
mocked_zipfile.ZipFile.return_value = MagicMock()
|
||||
mocked_shutil_copy.side_effect = PermissionError
|
||||
|
||||
# WHEN: The service is saved and a PermissionError is thrown
|
||||
result = service_manager.save_local_file()
|
||||
|
||||
# THEN: The "save_as" method is called to save the service
|
||||
self.assertTrue(result)
|
||||
mocked_save_file_as.assert_called_with()
|
||||
|
@ -39,7 +39,7 @@ class TestSettingsForm(TestCase):
|
||||
"""
|
||||
Registry.create()
|
||||
|
||||
def insert_tab_visible_test(self):
|
||||
def test_insert_tab_visible(self):
|
||||
"""
|
||||
Test that the insert_tab() method works correctly when a visible tab is inserted
|
||||
"""
|
||||
@ -59,7 +59,7 @@ class TestSettingsForm(TestCase):
|
||||
mocked_add_widget.assert_called_with(general_tab)
|
||||
self.assertEqual(1, mocked_add_item.call_count, 'addItem should have been called')
|
||||
|
||||
def insert_tab_not_visible_test(self):
|
||||
def test_insert_tab_not_visible(self):
|
||||
"""
|
||||
Test that the insert_tab() method works correctly when a tab that should not be visible is inserted
|
||||
"""
|
||||
@ -77,7 +77,7 @@ class TestSettingsForm(TestCase):
|
||||
mocked_add_widget.assert_called_with(general_tab)
|
||||
self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called')
|
||||
|
||||
def accept_with_inactive_plugins_test(self):
|
||||
def test_accept_with_inactive_plugins(self):
|
||||
"""
|
||||
Test that the accept() method works correctly when some of the plugins are inactive
|
||||
"""
|
||||
@ -105,7 +105,7 @@ class TestSettingsForm(TestCase):
|
||||
mocked_general_save.assert_called_with()
|
||||
self.assertEqual(0, mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called')
|
||||
|
||||
def list_item_changed_invalid_item_test(self):
|
||||
def test_list_item_changed_invalid_item(self):
|
||||
"""
|
||||
Test that the list_item_changed() slot handles a non-existent item
|
||||
"""
|
||||
@ -124,7 +124,7 @@ class TestSettingsForm(TestCase):
|
||||
# THEN: The rest of the method should not have been called
|
||||
self.assertEqual(0, mocked_count.call_count, 'The count method of the stacked layout should not be called')
|
||||
|
||||
def reject_with_inactive_items_test(self):
|
||||
def test_reject_with_inactive_items(self):
|
||||
"""
|
||||
Test that the reject() method works correctly when some of the plugins are inactive
|
||||
"""
|
||||
|
@ -35,7 +35,7 @@ from tests.functional import MagicMock, patch
|
||||
|
||||
class TestSlideController(TestCase):
|
||||
|
||||
def initial_slide_controller_test(self):
|
||||
def test_initial_slide_controller(self):
|
||||
"""
|
||||
Test the initial slide controller state .
|
||||
"""
|
||||
@ -46,7 +46,7 @@ class TestSlideController(TestCase):
|
||||
# THEN: The controller should not be a live controller.
|
||||
self.assertEqual(slide_controller.is_live, False, 'The base slide controller should not be a live controller')
|
||||
|
||||
def text_service_item_blank_test(self):
|
||||
def test_text_service_item_blank(self):
|
||||
"""
|
||||
Test that loading a text-based service item into the slide controller sets the correct blank menu
|
||||
"""
|
||||
@ -65,7 +65,7 @@ class TestSlideController(TestCase):
|
||||
# THEN: the call to set the visible items on the toolbar should be correct
|
||||
toolbar.set_widget_visible.assert_called_with(WIDE_MENU, True)
|
||||
|
||||
def non_text_service_item_blank_test(self):
|
||||
def test_non_text_service_item_blank(self):
|
||||
"""
|
||||
Test that loading a non-text service item into the slide controller sets the correct blank menu
|
||||
"""
|
||||
@ -85,7 +85,7 @@ class TestSlideController(TestCase):
|
||||
toolbar.set_widget_visible.assert_called_with(NON_TEXT_MENU, True)
|
||||
|
||||
@patch('openlp.core.ui.slidecontroller.Settings')
|
||||
def receive_spin_delay_test(self, MockedSettings):
|
||||
def test_receive_spin_delay(self, MockedSettings):
|
||||
"""
|
||||
Test that the spin box is updated accordingly after a call to receive_spin_delay()
|
||||
"""
|
||||
@ -103,7 +103,7 @@ class TestSlideController(TestCase):
|
||||
mocked_value.assert_called_with('core/loop delay')
|
||||
mocked_delay_spin_box.setValue.assert_called_with(1)
|
||||
|
||||
def toggle_display_blank_test(self):
|
||||
def test_toggle_display_blank(self):
|
||||
"""
|
||||
Check that the toggle_display('blank') method calls the on_blank_display() method
|
||||
"""
|
||||
@ -124,7 +124,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
|
||||
|
||||
def toggle_display_hide_test(self):
|
||||
def test_toggle_display_hide(self):
|
||||
"""
|
||||
Check that the toggle_display('hide') method calls the on_blank_display() method
|
||||
"""
|
||||
@ -145,7 +145,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
|
||||
|
||||
def toggle_display_theme_test(self):
|
||||
def test_toggle_display_theme(self):
|
||||
"""
|
||||
Check that the toggle_display('theme') method calls the on_theme_display() method
|
||||
"""
|
||||
@ -166,7 +166,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called')
|
||||
|
||||
def toggle_display_desktop_test(self):
|
||||
def test_toggle_display_desktop(self):
|
||||
"""
|
||||
Check that the toggle_display('desktop') method calls the on_hide_display() method
|
||||
"""
|
||||
@ -187,7 +187,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called')
|
||||
self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called')
|
||||
|
||||
def toggle_display_show_test(self):
|
||||
def test_toggle_display_show(self):
|
||||
"""
|
||||
Check that the toggle_display('show') method calls all the on_X_display() methods
|
||||
"""
|
||||
@ -208,7 +208,7 @@ class TestSlideController(TestCase):
|
||||
mocked_on_theme_display.assert_called_once_with(False)
|
||||
mocked_on_hide_display.assert_called_once_with(False)
|
||||
|
||||
def live_escape_test(self):
|
||||
def test_live_escape(self):
|
||||
"""
|
||||
Test that when the live_escape() method is called, the display is set to invisible and any media is stopped
|
||||
"""
|
||||
@ -231,7 +231,7 @@ class TestSlideController(TestCase):
|
||||
mocked_display.setVisible.assert_called_once_with(False)
|
||||
mocked_media_controller.media_stop.assert_called_once_with(slide_controller)
|
||||
|
||||
def on_go_live_live_controller_test(self):
|
||||
def test_on_go_live_live_controller(self):
|
||||
"""
|
||||
Test that when the on_go_live() method is called the message is sent to the live controller and focus is
|
||||
set correctly.
|
||||
@ -259,7 +259,7 @@ class TestSlideController(TestCase):
|
||||
mocked_live_controller.add_service_manager_item.assert_called_once_with(mocked_service_item, 1)
|
||||
mocked_live_controller.preview_widget.setFocus.assert_called_once_with()
|
||||
|
||||
def on_go_live_service_manager_test(self):
|
||||
def test_on_go_live_service_manager(self):
|
||||
"""
|
||||
Test that when the on_go_live() method is called the message is sent to the live controller and focus is
|
||||
set correctly.
|
||||
@ -290,7 +290,7 @@ class TestSlideController(TestCase):
|
||||
mocked_service_manager.preview_live.assert_called_once_with(42, 1)
|
||||
mocked_live_controller.preview_widget.setFocus.assert_called_once_with()
|
||||
|
||||
def service_previous_test(self):
|
||||
def test_service_previous(self):
|
||||
"""
|
||||
Check that calling the service_previous() method adds the previous key to the queue and processes the queue
|
||||
"""
|
||||
@ -308,7 +308,7 @@ class TestSlideController(TestCase):
|
||||
mocked_keypress_queue.append.assert_called_once_with(ServiceItemAction.Previous)
|
||||
mocked_process_queue.assert_called_once_with()
|
||||
|
||||
def service_next_test(self):
|
||||
def test_service_next(self):
|
||||
"""
|
||||
Check that calling the service_next() method adds the next key to the queue and processes the queue
|
||||
"""
|
||||
@ -327,7 +327,7 @@ class TestSlideController(TestCase):
|
||||
mocked_process_queue.assert_called_once_with()
|
||||
|
||||
@patch('openlp.core.ui.slidecontroller.Settings')
|
||||
def update_slide_limits_test(self, MockedSettings):
|
||||
def test_update_slide_limits(self, MockedSettings):
|
||||
"""
|
||||
Test that calling the update_slide_limits() method updates the slide limits
|
||||
"""
|
||||
@ -346,7 +346,7 @@ class TestSlideController(TestCase):
|
||||
mocked_value.assert_called_once_with('advanced/slide limits')
|
||||
self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10')
|
||||
|
||||
def enable_tool_bar_live_test(self):
|
||||
def test_enable_tool_bar_live(self):
|
||||
"""
|
||||
Check that when enable_tool_bar on a live slide controller is called, enable_live_tool_bar is called
|
||||
"""
|
||||
@ -366,7 +366,7 @@ class TestSlideController(TestCase):
|
||||
mocked_enable_live_tool_bar.assert_called_once_with(mocked_service_item)
|
||||
self.assertEqual(0, mocked_enable_preview_tool_bar.call_count, 'The preview method should not have been called')
|
||||
|
||||
def enable_tool_bar_preview_test(self):
|
||||
def test_enable_tool_bar_preview(self):
|
||||
"""
|
||||
Check that when enable_tool_bar on a preview slide controller is called, enable_preview_tool_bar is called
|
||||
"""
|
||||
@ -386,7 +386,7 @@ class TestSlideController(TestCase):
|
||||
mocked_enable_preview_tool_bar.assert_called_once_with(mocked_service_item)
|
||||
self.assertEqual(0, mocked_enable_live_tool_bar.call_count, 'The live method should not have been called')
|
||||
|
||||
def refresh_service_item_text_test(self):
|
||||
def test_refresh_service_item_text(self):
|
||||
"""
|
||||
Test that the refresh_service_item() method refreshes a text service item
|
||||
"""
|
||||
@ -409,7 +409,7 @@ class TestSlideController(TestCase):
|
||||
mocked_service_item.render.assert_called_once_with()
|
||||
mocked_process_item.assert_called_once_with(mocked_service_item, 5)
|
||||
|
||||
def refresh_service_item_image_test(self):
|
||||
def test_refresh_service_item_image(self):
|
||||
"""
|
||||
Test that the refresh_service_item() method refreshes a image service item
|
||||
"""
|
||||
@ -432,7 +432,7 @@ class TestSlideController(TestCase):
|
||||
mocked_service_item.render.assert_called_once_with()
|
||||
mocked_process_item.assert_called_once_with(mocked_service_item, 5)
|
||||
|
||||
def refresh_service_item_not_image_or_text_test(self):
|
||||
def test_refresh_service_item_not_image_or_text(self):
|
||||
"""
|
||||
Test that the refresh_service_item() method does not refresh a service item if it's neither text or an image
|
||||
"""
|
||||
@ -456,7 +456,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_process_item.call_count,
|
||||
'The mocked_process_item() method should not have been called')
|
||||
|
||||
def add_service_item_with_song_edit_test(self):
|
||||
def test_add_service_item_with_song_edit(self):
|
||||
"""
|
||||
Test the add_service_item() method when song_edit is True
|
||||
"""
|
||||
@ -476,7 +476,7 @@ class TestSlideController(TestCase):
|
||||
self.assertFalse(slide_controller.song_edit, 'song_edit should be False')
|
||||
mocked_process_item.assert_called_once_with(mocked_item, 2)
|
||||
|
||||
def add_service_item_without_song_edit_test(self):
|
||||
def test_add_service_item_without_song_edit(self):
|
||||
"""
|
||||
Test the add_service_item() method when song_edit is False
|
||||
"""
|
||||
@ -496,7 +496,7 @@ class TestSlideController(TestCase):
|
||||
self.assertFalse(slide_controller.song_edit, 'song_edit should be False')
|
||||
mocked_process_item.assert_called_once_with(mocked_item, 0)
|
||||
|
||||
def replace_service_manager_item_different_items_test(self):
|
||||
def test_replace_service_manager_item_different_items(self):
|
||||
"""
|
||||
Test that when the service items are not the same, nothing happens
|
||||
"""
|
||||
@ -517,7 +517,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_preview_widget.current_slide_number.call_count,
|
||||
'The preview_widgetcurrent_slide_number.() method should not have been called')
|
||||
|
||||
def replace_service_manager_item_same_item_test(self):
|
||||
def test_replace_service_manager_item_same_item(self):
|
||||
"""
|
||||
Test that when the service item is the same, the service item is reprocessed
|
||||
"""
|
||||
@ -538,7 +538,7 @@ class TestSlideController(TestCase):
|
||||
mocked_preview_widget.current_slide_number.assert_called_with()
|
||||
mocked_process_item.assert_called_once_with(mocked_item, 7)
|
||||
|
||||
def on_slide_blank_test(self):
|
||||
def test_on_slide_blank(self):
|
||||
"""
|
||||
Test on_slide_blank
|
||||
"""
|
||||
@ -552,7 +552,7 @@ class TestSlideController(TestCase):
|
||||
# THEN: on_blank_display should have been called with True
|
||||
slide_controller.on_blank_display.assert_called_once_with(True)
|
||||
|
||||
def on_slide_unblank_test(self):
|
||||
def test_on_slide_unblank(self):
|
||||
"""
|
||||
Test on_slide_unblank
|
||||
"""
|
||||
@ -566,7 +566,7 @@ class TestSlideController(TestCase):
|
||||
# THEN: on_blank_display should have been called with False
|
||||
slide_controller.on_blank_display.assert_called_once_with(False)
|
||||
|
||||
def on_slide_selected_index_no_service_item_test(self):
|
||||
def test_on_slide_selected_index_no_service_item(self):
|
||||
"""
|
||||
Test that when there is no service item, the on_slide_selected_index() method returns immediately
|
||||
"""
|
||||
@ -582,7 +582,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_item.is_command.call_count, 'The service item should have not been called')
|
||||
|
||||
@patch.object(Registry, 'execute')
|
||||
def on_slide_selected_index_service_item_command_test(self, mocked_execute):
|
||||
def test_on_slide_selected_index_service_item_command(self, mocked_execute):
|
||||
"""
|
||||
Test that when there is a command service item, the command is executed
|
||||
"""
|
||||
@ -612,7 +612,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called')
|
||||
|
||||
@patch.object(Registry, 'execute')
|
||||
def on_slide_selected_index_service_item_not_command_test(self, mocked_execute):
|
||||
def test_on_slide_selected_index_service_item_not_command(self, mocked_execute):
|
||||
"""
|
||||
Test that when there is a service item but it's not a command, the preview widget is updated
|
||||
"""
|
||||
@ -641,7 +641,7 @@ class TestSlideController(TestCase):
|
||||
mocked_slide_selected.assert_called_once_with()
|
||||
|
||||
@patch.object(Registry, 'execute')
|
||||
def process_item_test(self, mocked_execute):
|
||||
def test_process_item(self, mocked_execute):
|
||||
"""
|
||||
Test that presentation service-items is closed when followed by a media service-item
|
||||
"""
|
||||
@ -685,7 +685,7 @@ class TestSlideController(TestCase):
|
||||
self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
|
||||
'The presentation should have been stopped.')
|
||||
|
||||
def live_stolen_focus_shortcuts_test(self):
|
||||
def test_live_stolen_focus_shortcuts(self):
|
||||
"""
|
||||
Test that all the needed shortcuts are available in scenarios where Live has stolen focus.
|
||||
These are found under def __add_actions_to_widget(self, widget): in slidecontroller.py
|
||||
@ -715,7 +715,7 @@ class TestSlideController(TestCase):
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
def update_preview_test_live(self, mocked_singleShot, mocked_image_manager):
|
||||
def test_update_preview_live(self, mocked_singleShot, mocked_image_manager):
|
||||
"""
|
||||
Test that the preview screen is updated with a screen grab for live service items
|
||||
"""
|
||||
@ -758,7 +758,7 @@ class TestSlideController(TestCase):
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
def update_preview_test_pres(self, mocked_singleShot, mocked_image_manager):
|
||||
def test_update_preview_pres(self, mocked_singleShot, mocked_image_manager):
|
||||
"""
|
||||
Test that the preview screen is updated with the correct preview for presentation service items
|
||||
"""
|
||||
@ -800,7 +800,7 @@ class TestSlideController(TestCase):
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
def update_preview_test_media(self, mocked_singleShot, mocked_image_manager):
|
||||
def test_update_preview_media(self, mocked_singleShot, mocked_image_manager):
|
||||
"""
|
||||
Test that the preview screen is updated with the correct preview for media service items
|
||||
"""
|
||||
@ -842,7 +842,7 @@ class TestSlideController(TestCase):
|
||||
|
||||
@patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
|
||||
@patch(u'PyQt5.QtCore.QTimer.singleShot')
|
||||
def update_preview_test_image(self, mocked_singleShot, mocked_image_manager):
|
||||
def test_update_preview_image(self, mocked_singleShot, mocked_image_manager):
|
||||
"""
|
||||
Test that the preview screen is updated with the correct preview for image service items
|
||||
"""
|
||||
@ -885,7 +885,7 @@ class TestSlideController(TestCase):
|
||||
|
||||
class TestInfoLabel(TestCase):
|
||||
|
||||
def paint_event_text_fits_test(self):
|
||||
def test_paint_event_text_fits(self):
|
||||
"""
|
||||
Test the paintEvent method when text fits the label
|
||||
"""
|
||||
@ -913,7 +913,7 @@ class TestInfoLabel(TestCase):
|
||||
# THEN: The text should be drawn centered with the complete test_string
|
||||
mocked_qpainter().drawText.assert_called_once_with(mocked_rect(), QtCore.Qt.AlignCenter, test_string)
|
||||
|
||||
def paint_event_text_doesnt_fit_test(self):
|
||||
def test_paint_event_text_doesnt_fit(self):
|
||||
"""
|
||||
Test the paintEvent method when text fits the label
|
||||
"""
|
||||
@ -944,7 +944,7 @@ class TestInfoLabel(TestCase):
|
||||
mocked_qpainter().drawText.assert_called_once_with(mocked_rect(), QtCore.Qt.AlignLeft, elided_test_string)
|
||||
|
||||
@patch('builtins.super')
|
||||
def set_text_test(self, mocked_super):
|
||||
def test_set_text(self, mocked_super):
|
||||
"""
|
||||
Test the reimplemented setText method
|
||||
"""
|
||||
@ -963,7 +963,7 @@ class TestInfoLabel(TestCase):
|
||||
|
||||
class TestLiveController(TestCase):
|
||||
|
||||
def initial_live_controller_test(self):
|
||||
def test_initial_live_controller(self):
|
||||
"""
|
||||
Test the initial live slide controller state .
|
||||
"""
|
||||
@ -978,7 +978,7 @@ class TestLiveController(TestCase):
|
||||
|
||||
class TestPreviewLiveController(TestCase):
|
||||
|
||||
def initial_preview_controller_test(self):
|
||||
def test_initial_preview_controller(self):
|
||||
"""
|
||||
Test the initial preview slide controller state.
|
||||
"""
|
||||
|
@ -34,7 +34,7 @@ class TestThemeManager(TestCase):
|
||||
"""
|
||||
Test the functions in the ThemeManager Class
|
||||
"""
|
||||
def select_image_file_dialog_cancelled_test(self):
|
||||
def test_select_image_file_dialog_cancelled(self):
|
||||
"""
|
||||
Test the select image file dialog when the user presses cancel
|
||||
"""
|
||||
@ -62,7 +62,7 @@ class TestThemeManager(TestCase):
|
||||
'All Files (*.*)')
|
||||
mocked_set_background_page_values.assert_called_once_with()
|
||||
|
||||
def select_image_file_dialog_new_file_test(self):
|
||||
def test_select_image_file_dialog_new_file(self):
|
||||
"""
|
||||
Test the select image file dialog when the user presses ok
|
||||
"""
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user