PJLink2-L updates

This commit is contained in:
Ken Roberts 2017-11-10 03:59:38 -08:00
parent f7e1dcbea1
commit 3d4ed035e9
22 changed files with 97 additions and 97 deletions

View File

@ -620,6 +620,3 @@ from .serviceitem import ServiceItem, ServiceItemType, ItemCapabilities
from .htmlbuilder import build_html, build_lyrics_format_css, build_lyrics_outline_css, build_chords_css
from .imagemanager import ImageManager
from .mediamanageritem import MediaManagerItem
from .projector.db import ProjectorDB, Projector
from .projector.pjlink import PJLink
from .projector.constants import PJLINK_PORT, ERROR_MSG, ERROR_STRING

View File

@ -25,10 +25,22 @@
Initialization for the openlp.core.ui.projector modules.
"""
__all__ = ['PJLINK_PORT', 'ERROR_MSG', 'ERROR_STRING', 'DialogSourceStyle', 'PJLink', 'Projector',
'ProjectorDB', 'ProjectorEditForm', 'ProjectorManager', 'ProjectorTab']
# Due to circular dependencies, put the imports after defines
class DialogSourceStyle(object):
"""
An enumeration for projector dialog box type.
"""
Tabbed = 0
Single = 1
from .constants import PJLINK_PORT, ERROR_MSG, ERROR_STRING
from .db import Projector, ProjectorDB
from .editform import ProjectorEditForm
from .manager import ProjectorManager
from .pjlink import PJLink
from .tab import ProjectorTab

View File

@ -43,8 +43,8 @@ from sqlalchemy.ext.declarative import declarative_base, declared_attr
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
from openlp.core.lib.projector import upgrade
from openlp.core.projectors.constants import PJLINK_DEFAULT_CODES
from openlp.core.projectors import upgrade
Base = declarative_base(MetaData())

View File

@ -30,8 +30,8 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common import verify_ip_address
from openlp.core.common.i18n import translate
from openlp.core.lib import build_icon
from openlp.core.lib.projector.db import Projector
from openlp.core.lib.projector.constants import PJLINK_PORT
from openlp.core.projectors.db import Projector
from openlp.core.projectors.constants import PJLINK_PORT
log = logging.getLogger(__name__)
log.debug('editform loaded')

View File

@ -34,14 +34,14 @@ from openlp.core.common.mixins import LogMixin, RegistryProperties
from openlp.core.common.registry import RegistryBase
from openlp.core.common.settings import Settings
from openlp.core.lib.ui import create_widget_action
from openlp.core.lib.projector import DialogSourceStyle
from openlp.core.lib.projector.constants import ERROR_MSG, ERROR_STRING, E_AUTHENTICATION, E_ERROR, \
from openlp.core.projectors import DialogSourceStyle
from openlp.core.projectors.constants import ERROR_MSG, ERROR_STRING, E_AUTHENTICATION, E_ERROR, \
E_NETWORK, E_NOT_CONNECTED, E_UNKNOWN_SOCKET_ERROR, STATUS_STRING, S_CONNECTED, S_CONNECTING, S_COOLDOWN, \
S_INITIALIZE, S_NOT_CONNECTED, S_OFF, S_ON, S_STANDBY, S_WARMUP
from openlp.core.lib.projector.db import ProjectorDB
from openlp.core.lib.projector.pjlink import PJLink, PJLinkUDP
from openlp.core.ui.projector.editform import ProjectorEditForm
from openlp.core.ui.projector.sourceselectform import SourceSelectTabs, SourceSelectSingle
from openlp.core.projectors.db import ProjectorDB
from openlp.core.projectors.pjlink import PJLink, PJLinkUDP
from openlp.core.projectors.editform import ProjectorEditForm
from openlp.core.projectors.sourceselectform import SourceSelectTabs, SourceSelectSingle
from openlp.core.widgets.toolbar import OpenLPToolbar
log = logging.getLogger(__name__)
@ -518,7 +518,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector.thread.quit()
new_list = []
for item in self.projector_list:
if item.link.dbid == projector.link.dbid:
if item.link.db_item.id == projector.link.db_item.id:
continue
new_list.append(item)
self.projector_list = new_list
@ -730,7 +730,6 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
thread.started.connect(item.link.thread_started)
thread.finished.connect(item.link.thread_stopped)
thread.finished.connect(thread.deleteLater)
item.link.projectorNetwork.connect(self.update_status)
item.link.changeStatus.connect(self.update_status)
item.link.projectorAuthentication.connect(self.authentication_error)
item.link.projectorNoAuthentication.connect(self.no_authentication_error)

View File

@ -54,7 +54,7 @@ from PyQt5 import QtCore, QtNetwork
from openlp.core.common import qmd5_hash
from openlp.core.common.i18n import translate
from openlp.core.lib.projector.constants import CONNECTION_ERRORS, CR, ERROR_MSG, ERROR_STRING, \
from openlp.core.projectors.constants import CONNECTION_ERRORS, CR, ERROR_MSG, ERROR_STRING, \
E_AUTHENTICATION, E_CONNECTION_REFUSED, E_GENERAL, E_INVALID_DATA, E_NETWORK, E_NOT_CONNECTED, E_OK, \
E_PARAMETER, E_PROJECTOR, E_SOCKET_TIMEOUT, E_UNAVAILABLE, E_UNDEFINED, PJLINK_ERRORS, PJLINK_ERST_DATA, \
PJLINK_ERST_STATUS, PJLINK_MAX_PACKET, PJLINK_PORT, PJLINK_POWR_STATUS, PJLINK_VALID_CMD, \
@ -520,7 +520,6 @@ class PJLink(QtNetwork.QTcpSocket, PJLinkCommands):
"""
# Signals sent by this module
changeStatus = QtCore.pyqtSignal(str, int, str)
projectorNetwork = QtCore.pyqtSignal(int) # Projector network activity
projectorStatus = QtCore.pyqtSignal(int) # Status update
projectorAuthentication = QtCore.pyqtSignal(str) # Authentication error
projectorNoAuthentication = QtCore.pyqtSignal(str) # PIN set and no authentication needed
@ -846,7 +845,6 @@ class PJLink(QtNetwork.QTcpSocket, PJLinkCommands):
log.debug('({ip}) get_socket(): No data available (-1)'.format(ip=self.ip))
return self.receive_data_signal()
self.socket_timer.stop()
self.projectorNetwork.emit(S_NETWORK_RECEIVED)
return self.get_data(buff=read, ip=self.ip)
def get_data(self, buff, ip):
@ -925,7 +923,6 @@ class PJLink(QtNetwork.QTcpSocket, PJLinkCommands):
if cmd not in PJLINK_VALID_CMD:
log.error('({ip}) send_command(): Invalid command requested - ignoring.'.format(ip=self.ip))
return
self.projectorNetwork.emit(S_NETWORK_SENDING)
log.debug('({ip}) send_command(): Building cmd="{command}" opts="{data}"{salt}'.format(ip=self.ip,
command=cmd,
data=opts,
@ -996,7 +993,6 @@ class PJLink(QtNetwork.QTcpSocket, PJLinkCommands):
log.debug('({ip}) _send_string(): Sending "{data}"'.format(ip=self.ip, data=out.strip()))
log.debug('({ip}) _send_string(): Queue = {data}'.format(ip=self.ip, data=self.send_queue))
self.socket_timer.start()
self.projectorNetwork.emit(S_NETWORK_SENDING)
sent = self.write(out.encode('{string_encoding}'.format(string_encoding='utf-8' if utf8 else 'ascii')))
self.waitForBytesWritten(2000) # 2 seconds should be enough
if sent == -1:

View File

@ -31,8 +31,8 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common import is_macosx
from openlp.core.common.i18n import translate
from openlp.core.lib import build_icon
from openlp.core.lib.projector.db import ProjectorSource
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_SOURCES, PJLINK_DEFAULT_CODES
from openlp.core.projectors.db import ProjectorSource
from openlp.core.projectors.constants import PJLINK_DEFAULT_SOURCES, PJLINK_DEFAULT_CODES
log = logging.getLogger(__name__)

View File

@ -29,7 +29,7 @@ from PyQt5 import QtWidgets
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.settings import Settings
from openlp.core.lib import SettingsTab
from openlp.core.lib.projector import DialogSourceStyle
from openlp.core.projectors import DialogSourceStyle
log = logging.getLogger(__name__)
log.debug('projectortab module loaded')

View File

@ -115,9 +115,10 @@ from .formattingtagcontroller import FormattingTagController
from .shortcutlistform import ShortcutListForm
from .servicemanager import ServiceManager
from .thememanager import ThemeManager
from .projector.manager import ProjectorManager
from .projector.tab import ProjectorTab
from .projector.editform import ProjectorEditForm
from openlp.core.projectors import ProjectorManager
from openlp.core.projectors import ProjectorTab
from openlp.core.projectors import ProjectorEditForm
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeForm',
'ThemeManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'Display', 'AudioPlayer',

View File

@ -55,7 +55,7 @@ from openlp.core.widgets.dialogs import FileDialog
from openlp.core.widgets.docks import OpenLPDockWidget, 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.projectors import ProjectorManager
from openlp.core.ui.style import PROGRESSBAR_STYLE, get_library_stylesheet
from openlp.core.version import get_version

View File

@ -32,7 +32,7 @@ from openlp.core.common.registry import Registry
from openlp.core.lib import build_icon
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
from openlp.core.ui.media import PlayerTab
from openlp.core.ui.projector.tab import ProjectorTab
from openlp.core.projectors import ProjectorTab
from openlp.core.ui.settingsdialog import Ui_SettingsDialog
log = logging.getLogger(__name__)

View File

@ -20,5 +20,5 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The Projector driver module.
Module-level functions for the functional test suite
"""

View File

@ -20,7 +20,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Package to test the openlp.core.lib.projector.constants package.
Package to test the openlp.core.projectors.constants module.
"""
from unittest import TestCase
@ -37,7 +37,7 @@ class TestProjectorConstants(TestCase):
from tests.resources.projector.data import TEST_VIDEO_CODES
# WHEN: Import projector PJLINK_DEFAULT_CODES
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES
from openlp.core.projectors.constants import PJLINK_DEFAULT_CODES
# THEN: Verify dictionary was build correctly
self.assertEqual(PJLINK_DEFAULT_CODES, TEST_VIDEO_CODES, 'PJLink video strings should match')

View File

@ -20,7 +20,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Package to test the openlp.core.ui.projectordb find, edit, delete
Package to test the openlp.core.projectors.db module.
record functions.
PREREQUISITE: add_record() and get_all() functions validated.
@ -32,10 +32,10 @@ from tempfile import mkdtemp
from unittest import TestCase
from unittest.mock import patch
from openlp.core.lib.projector import upgrade
from openlp.core.lib.db import upgrade_db
from openlp.core.lib.projector.constants import PJLINK_PORT
from openlp.core.lib.projector.db import Manufacturer, Model, Projector, ProjectorDB, ProjectorSource, Source
from openlp.core.projectors import upgrade
from openlp.core.projectors.constants import PJLINK_PORT
from openlp.core.projectors.db import Manufacturer, Model, Projector, ProjectorDB, ProjectorSource, Source
from tests.resources.projector.data import TEST_DB_PJLINK1, TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA
from tests.utils.constants import TEST_RESOURCES_PATH
@ -129,7 +129,7 @@ class TestProjectorDB(TestCase):
"""
Test case for ProjectorDB
"""
@patch('openlp.core.lib.projector.db.init_url')
@patch('openlp.core.projectors.db.init_url')
def setUp(self, mocked_init_url):
"""
Set up anything necessary for all tests

View File

@ -20,14 +20,13 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Package to test the openlp.core.lib.projector.pjlink base package.
Package to test the openlp.core.projectors.pjlink base package.
"""
from unittest import TestCase
from unittest.mock import call, patch, MagicMock
from openlp.core.lib.projector.db import Projector
from openlp.core.lib.projector.pjlink import PJLink
from openlp.core.lib.projector.constants import E_PARAMETER, ERROR_STRING, S_ON, S_CONNECTED
from openlp.core.projectors import PJLink, Projector
from openlp.core.projectors.constants import E_PARAMETER, ERROR_STRING, S_ON, S_CONNECTED
from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE, TEST_HASH, TEST1_DATA

View File

@ -20,20 +20,19 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Package to test the openlp.core.lib.projector.pjlink class command routing.
Package to test the openlp.core.projectors.pjlink command routing.
"""
from unittest import TestCase
from unittest.mock import patch, MagicMock
import openlp.core.lib.projector.pjlink
from openlp.core.lib.projector.db import Projector
from openlp.core.lib.projector.pjlink import PJLink
from openlp.core.lib.projector.constants import PJLINK_ERRORS, \
import openlp.core.projectors.pjlink
from openlp.core.projectors import PJLink, Projector
from openlp.core.projectors.constants import PJLINK_ERRORS, \
E_AUTHENTICATION, E_PARAMETER, E_PROJECTOR, E_UNAVAILABLE, E_UNDEFINED
'''
from openlp.core.lib.projector.constants import ERROR_STRING, PJLINK_ERST_DATA, PJLINK_ERST_STATUS, \
from openlp.core.projectors.constants import ERROR_STRING, PJLINK_ERST_DATA, PJLINK_ERST_STATUS, \
PJLINK_POWR_STATUS, PJLINK_VALID_CMD, E_WARN, E_ERROR, S_OFF, S_STANDBY, S_ON
'''
from tests.resources.projector.data import TEST_PIN, TEST1_DATA
@ -46,7 +45,7 @@ class TestPJLinkRouting(TestCase):
"""
Tests for the PJLink module command routing
"""
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_call_clss(self, mock_log):
"""
Test process_command calls proper function
@ -66,7 +65,7 @@ class TestPJLinkRouting(TestCase):
mock_process_clss.assert_called_with('1')
@patch.object(pjlink_test, 'change_status')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_err1(self, mock_log, mock_change_status):
"""
Test ERR1 - Undefined projector function
@ -85,7 +84,7 @@ class TestPJLinkRouting(TestCase):
mock_log.error.assert_called_with(log_text)
@patch.object(pjlink_test, 'change_status')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_err2(self, mock_log, mock_change_status):
"""
Test ERR2 - Parameter Error
@ -104,7 +103,7 @@ class TestPJLinkRouting(TestCase):
mock_log.error.assert_called_with(log_text)
@patch.object(pjlink_test, 'change_status')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_err3(self, mock_log, mock_change_status):
"""
Test ERR3 - Unavailable error
@ -123,7 +122,7 @@ class TestPJLinkRouting(TestCase):
mock_log.error.assert_called_with(log_text)
@patch.object(pjlink_test, 'change_status')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_err4(self, mock_log, mock_change_status):
"""
Test ERR3 - Unavailable error
@ -144,7 +143,7 @@ class TestPJLinkRouting(TestCase):
@patch.object(pjlink_test, 'projectorAuthentication')
@patch.object(pjlink_test, 'change_status')
@patch.object(pjlink_test, 'disconnect_from_host')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_erra(self, mock_log, mock_disconnect, mock_change_status, mock_err_authenticate):
"""
Test ERRA - Authentication Error
@ -163,7 +162,7 @@ class TestPJLinkRouting(TestCase):
mock_change_status.assert_called_once_with(E_AUTHENTICATION)
mock_log.error.assert_called_with(log_text)
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_future(self, mock_log):
"""
Test command valid but no method to process yet
@ -184,7 +183,7 @@ class TestPJLinkRouting(TestCase):
mock_log.warning.assert_called_once_with(log_text)
@patch.object(pjlink_test, 'pjlink_functions')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_invalid(self, mock_log, mock_functions):
"""
Test not a valid command
@ -203,7 +202,7 @@ class TestPJLinkRouting(TestCase):
mock_log.error.assert_called_once_with(log_text)
@patch.object(pjlink_test, 'pjlink_functions')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_process_command_ok(self, mock_log, mock_functions):
"""
Test command returned success

View File

@ -20,15 +20,14 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Package to test the openlp.core.lib.projector.pjlink commands package.
Package to test the openlp.core.projectors.pjlink commands package.
"""
from unittest import TestCase
from unittest.mock import patch
import openlp.core.lib.projector.pjlink
from openlp.core.lib.projector.db import Projector
from openlp.core.lib.projector.pjlink import PJLink
from openlp.core.lib.projector.constants import ERROR_STRING, PJLINK_ERST_DATA, PJLINK_ERST_STATUS, \
import openlp.core.projectors.pjlink
from openlp.core.projectors import PJLink, Projector
from openlp.core.projectors.constants import ERROR_STRING, PJLINK_ERST_DATA, PJLINK_ERST_STATUS, \
PJLINK_POWR_STATUS, \
E_ERROR, E_NOT_CONNECTED, E_SOCKET_ADDRESS_NOT_AVAILABLE, E_UNKNOWN_SOCKET_ERROR, E_WARN, \
S_CONNECTED, S_OFF, S_ON, S_NOT_CONNECTED, S_CONNECTING, S_STANDBY
@ -50,7 +49,7 @@ class TestPJLinkCommands(TestCase):
Tests for the PJLink module
"""
@patch.object(pjlink_test, 'changeStatus')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_change_status_connection_error(self, mock_log, mock_change_status):
"""
Test change_status with connection error
@ -74,7 +73,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(mock_log.debug.call_count, 3, 'Debug log should have been called 3 times')
@patch.object(pjlink_test, 'changeStatus')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_change_status_connection_status_connecting(self, mock_log, mock_change_status):
"""
Test change_status with connection status
@ -97,7 +96,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(mock_log.debug.call_count, 3, 'Debug log should have been called 3 times')
@patch.object(pjlink_test, 'changeStatus')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_change_status_connection_status_connected(self, mock_log, mock_change_status):
"""
Test change_status with connection status
@ -120,7 +119,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(mock_log.debug.call_count, 3, 'Debug log should have been called 3 times')
@patch.object(pjlink_test, 'changeStatus')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_change_status_connection_status_with_message(self, mock_log, mock_change_status):
"""
Test change_status with connection status
@ -144,7 +143,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(mock_log.debug.call_count, 3, 'Debug log should have been called 3 times')
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_av_mute_status(self, mock_log, mock_send_command):
"""
Test sending command to retrieve shutter/audio state
@ -164,7 +163,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_available_inputs(self, mock_log, mock_send_command):
"""
Test sending command to retrieve avaliable inputs
@ -184,7 +183,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_error_status(self, mock_log, mock_send_command):
"""
Test sending command to retrieve projector error status
@ -204,7 +203,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_input_source(self, mock_log, mock_send_command):
"""
Test sending command to retrieve current input
@ -224,7 +223,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_lamp_status(self, mock_log, mock_send_command):
"""
Test sending command to retrieve lamp(s) status
@ -244,7 +243,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_manufacturer(self, mock_log, mock_send_command):
"""
Test sending command to retrieve manufacturer name
@ -264,7 +263,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_model(self, mock_log, mock_send_command):
"""
Test sending command to get model information
@ -284,7 +283,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_name(self, mock_log, mock_send_command):
"""
Test sending command to get user-assigned name
@ -304,7 +303,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_other_info(self, mock_log, mock_send_command):
"""
Test sending command to retrieve other information
@ -324,7 +323,7 @@ class TestPJLinkCommands(TestCase):
mock_send_command.assert_called_once_with(cmd=test_data)
@patch.object(pjlink_test, 'send_command')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_get_power_status(self, mock_log, mock_send_command):
"""
Test sending command to retrieve current power state
@ -599,7 +598,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(pjlink.pjlink_class, '2',
'Non-standard class reply should have set class=2')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_clss_invalid_nan(self, mock_log):
"""
Test CLSS reply has no class number
@ -616,7 +615,7 @@ class TestPJLinkCommands(TestCase):
'Non-standard class reply should have set class=1')
mock_log.error.assert_called_once_with(log_text)
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_clss_invalid_no_version(self, mock_log):
"""
Test CLSS reply has no class number
@ -648,7 +647,7 @@ class TestPJLinkCommands(TestCase):
# THEN: PJLink instance errors should be None
self.assertIsNone(pjlink.projector_errors, 'projector_errors should have been set to None')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_erst_data_invalid_length(self, mock_log):
"""
Test test_projector_process_erst_data_invalid_length
@ -666,7 +665,7 @@ class TestPJLinkCommands(TestCase):
self.assertTrue(mock_log.warning.called, 'Warning should have been logged')
mock_log.warning.assert_called_once_with(log_text)
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_erst_data_invalid_nan(self, mock_log):
"""
Test test_projector_process_erst_data_invalid_nan
@ -764,7 +763,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(pjlink.source, '1', 'Input source should be set to "1"')
@patch.object(pjlink_test, 'projectorUpdateIcons')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_inst(self, mock_log, mock_UpdateIcons):
"""
Test saving video source available information
@ -787,7 +786,7 @@ class TestPJLinkCommands(TestCase):
mock_log.debug.assert_called_once_with(log_data)
self.assertTrue(mock_UpdateIcons.emit.called, 'Update Icons should have been called')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_lamp_invalid(self, mock_log):
"""
Test status multiple lamp on/off and hours
@ -858,7 +857,7 @@ class TestPJLinkCommands(TestCase):
self.assertEqual(pjlink.lamp[0]['Hours'], 22222,
'Lamp hours should have been set to 22222')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_name(self, mock_log):
"""
Test saving NAME data from projector
@ -1040,7 +1039,7 @@ class TestPJLinkCommands(TestCase):
self.assertNotEquals(pjlink.serial_no, test_number,
'Projector serial number should NOT have been set')
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_sver(self, mock_log):
"""
Test invalid software version information - too long
@ -1061,7 +1060,7 @@ class TestPJLinkCommands(TestCase):
self.assertIsNone(pjlink.sw_version_received, 'Received software version should not have changed')
mock_log.debug.assert_called_once_with(test_log)
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_sver_changed(self, mock_log):
"""
Test invalid software version information - Received different than saved
@ -1086,7 +1085,7 @@ class TestPJLinkCommands(TestCase):
# There was 4 calls, but only the last one is checked with this method
mock_log.warning.assert_called_with(test_log)
@patch.object(openlp.core.lib.projector.pjlink, 'log')
@patch.object(openlp.core.projectors.pjlink, 'log')
def test_projector_process_sver_invalid(self, mock_log):
"""
Test invalid software version information - too long

View File

@ -20,7 +20,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Interface tests to test the openlp.core.ui.projector.editform.ProjectorEditForm()
Interface tests to test the openlp.core.projectors.editform.ProjectorEditForm()
class and methods.
"""
import os
@ -28,8 +28,7 @@ from unittest import TestCase
from unittest.mock import patch
from openlp.core.common.registry import Registry
from openlp.core.lib.projector.db import Projector, ProjectorDB
from openlp.core.ui import ProjectorEditForm
from openlp.core.projectors import Projector, ProjectorDB, ProjectorEditForm, ProjectorManager
from tests.helpers.testmixin import TestMixin
from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA
@ -48,7 +47,7 @@ class TestProjectorEditForm(TestCase, TestMixin):
self.setup_application()
self.build_settings()
Registry.create()
with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
if os.path.exists(TEST_DB):
os.unlink(TEST_DB)
mocked_init_url.return_value = 'sqlite:///' + TEST_DB
@ -66,7 +65,7 @@ class TestProjectorEditForm(TestCase, TestMixin):
del self.projector_form
self.destroy_settings()
@patch('openlp.core.ui.projector.editform.QtWidgets.QDialog.exec')
@patch('openlp.core.projectors.editform.QtWidgets.QDialog.exec')
def test_edit_form_add_projector(self, mocked_exec):
"""
Test projector edit form with no parameters creates a new entry.
@ -84,7 +83,7 @@ class TestProjectorEditForm(TestCase, TestMixin):
self.assertTrue((item.ip is None and item.name is None),
'Projector edit form should have a new Projector() instance to edit')
@patch('openlp.core.ui.projector.editform.QtWidgets.QDialog.exec')
@patch('openlp.core.projectors.editform.QtWidgets.QDialog.exec')
def test_edit_form_edit_projector(self, mocked_exec):
"""
Test projector edit form with existing projector entry

View File

@ -27,8 +27,7 @@ from unittest import TestCase
from unittest.mock import patch, MagicMock
from openlp.core.common.registry import Registry
from openlp.core.ui import ProjectorManager, ProjectorEditForm
from openlp.core.lib.projector.db import ProjectorDB
from openlp.core.projectors import ProjectorDB, ProjectorEditForm, ProjectorManager
from tests.helpers.testmixin import TestMixin
from tests.resources.projector.data import TEST_DB
@ -45,7 +44,7 @@ class TestProjectorManager(TestCase, TestMixin):
self.build_settings()
self.setup_application()
Registry.create()
with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
if os.path.exists(TEST_DB):
os.unlink(TEST_DB)
mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB

View File

@ -32,9 +32,9 @@ from unittest.mock import patch
from PyQt5.QtWidgets import QDialog
from openlp.core.common.registry import Registry
from openlp.core.lib.projector.db import ProjectorDB, Projector
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
from openlp.core.projectors.db import ProjectorDB, Projector
from openlp.core.projectors.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
from openlp.core.projectors.sourceselectform import source_group, SourceSelectSingle
from tests.helpers.testmixin import TestMixin
from tests.resources.projector.data import TEST_DB, TEST1_DATA
@ -58,7 +58,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
"""
Test class for the Projector Source Select form module
"""
@patch('openlp.core.lib.projector.db.init_url')
@patch('openlp.core.projectors.db.init_url')
def setUp(self, mocked_init_url):
"""
Set up anything necessary for all tests