2016-01-03 08:18:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2019 OpenLP Developers #
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# This program is free software: you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, #
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
##########################################################################
|
2016-01-03 08:18:58 +00:00
|
|
|
"""
|
2017-11-10 11:59:38 +00:00
|
|
|
Package to test the openlp.core.projectors.pjlink commands package.
|
2016-01-03 08:18:58 +00:00
|
|
|
"""
|
2019-04-21 01:04:59 +00:00
|
|
|
from unittest import TestCase, skip
|
2017-12-25 08:44:30 +00:00
|
|
|
from unittest.mock import call, patch
|
2016-01-03 08:18:58 +00:00
|
|
|
|
2017-11-10 11:59:38 +00:00
|
|
|
import openlp.core.projectors.pjlink
|
2019-05-04 10:21:48 +00:00
|
|
|
from openlp.core.projectors.pjlinkcommands import process_command
|
|
|
|
from openlp.core.projectors.constants import PJLINK_POWR_STATUS, S_ON, S_STANDBY
|
2017-11-16 23:53:53 +00:00
|
|
|
from openlp.core.projectors.db import Projector
|
|
|
|
from openlp.core.projectors.pjlink import PJLink
|
2017-12-25 08:44:30 +00:00
|
|
|
from tests.resources.projector.data import TEST1_DATA
|
2016-05-28 05:55:54 +00:00
|
|
|
|
2017-08-06 07:23:26 +00:00
|
|
|
|
|
|
|
class TestPJLinkCommands(TestCase):
|
2016-01-03 08:18:58 +00:00
|
|
|
"""
|
2019-05-04 10:21:48 +00:00
|
|
|
Tests PJLink get status commands part 2
|
2016-01-03 08:18:58 +00:00
|
|
|
"""
|
2019-05-04 10:21:48 +00:00
|
|
|
def setUp(self):
|
2017-08-11 11:04:33 +00:00
|
|
|
"""
|
2019-05-04 10:21:48 +00:00
|
|
|
Initial test setup
|
2017-08-11 11:04:33 +00:00
|
|
|
"""
|
2019-05-04 10:21:48 +00:00
|
|
|
self.pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
2017-08-11 11:04:33 +00:00
|
|
|
|
2019-05-04 10:21:48 +00:00
|
|
|
def tearDown(self):
|
2018-01-13 05:41:42 +00:00
|
|
|
"""
|
2019-05-04 10:21:48 +00:00
|
|
|
Test reset
|
2018-01-13 05:41:42 +00:00
|
|
|
"""
|
2019-05-04 10:21:48 +00:00
|
|
|
del(self.pjlink)
|
2017-12-25 08:44:30 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_inpt_valid(self):
|
2017-08-06 07:23:26 +00:00
|
|
|
"""
|
|
|
|
Test input source status shows current input
|
2016-04-02 03:04:15 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.source = '11'
|
2018-01-13 05:41:42 +00:00
|
|
|
log_debug_calls = [call('({ip}) reset_information() connect status is '
|
|
|
|
'S_NOT_CONNECTED'.format(ip=pjlink.name))]
|
|
|
|
chk_source_available = ['11', '12', '21', '22', '31', '32']
|
|
|
|
pjlink.source_available = chk_source_available
|
2017-12-25 08:44:30 +00:00
|
|
|
|
|
|
|
# WHEN: Called with input source
|
2019-05-04 10:21:48 +00:00
|
|
|
process_command(projector=self.pjlink, cmd='INPT', data='21')
|
2016-04-02 03:04:15 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Input selected should reflect current input
|
|
|
|
assert pjlink.source == '21', 'Input source should be set to "21"'
|
|
|
|
mock_log.debug.assert_has_calls(log_debug_calls)
|
2016-04-02 03:04:15 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_input_not_in_list(self):
|
|
|
|
"""
|
|
|
|
Test setting input outside of available inputs
|
|
|
|
|
|
|
|
TODO: Future test
|
|
|
|
"""
|
|
|
|
pass
|
2016-04-17 09:30:30 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_input_not_in_default(self):
|
|
|
|
"""
|
|
|
|
Test setting input with no sources available
|
|
|
|
TODO: Future test
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_input_invalid(self):
|
|
|
|
"""
|
|
|
|
Test setting input with an invalid value
|
|
|
|
|
|
|
|
TODO: Future test
|
|
|
|
"""
|
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_inst_class_1(self):
|
2016-04-16 08:08:45 +00:00
|
|
|
"""
|
2017-08-12 09:48:38 +00:00
|
|
|
Test saving video source available information
|
2016-04-16 08:08:45 +00:00
|
|
|
"""
|
2019-03-08 15:19:57 +00:00
|
|
|
|
2016-04-16 08:08:45 +00:00
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.source_available = []
|
2019-03-08 15:19:57 +00:00
|
|
|
log_debug_calls = [call('({ip}) reset_information() connect status is '
|
|
|
|
'S_NOT_CONNECTED'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Setting projector source_available to '
|
2018-01-13 05:41:42 +00:00
|
|
|
'"[\'11\', \'12\', \'21\', \'22\', \'31\', \'32\']"'.format(ip=pjlink.name))]
|
2019-03-08 15:19:57 +00:00
|
|
|
|
2018-01-13 05:41:42 +00:00
|
|
|
chk_data = '21 12 11 22 32 31' # Although they should already be sorted, use unsorted to verify method
|
|
|
|
chk_test = ['11', '12', '21', '22', '31', '32']
|
2017-12-25 08:44:30 +00:00
|
|
|
|
|
|
|
# WHEN: process_inst called with test data
|
|
|
|
pjlink.process_inst(data=chk_data)
|
|
|
|
|
|
|
|
# THEN: Data should have been sorted and saved properly
|
|
|
|
assert pjlink.source_available == chk_test, "Sources should have been sorted and saved"
|
|
|
|
mock_log.debug.assert_has_calls(log_debug_calls)
|
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_lamp_invalid(self):
|
2017-08-12 09:48:38 +00:00
|
|
|
"""
|
|
|
|
Test status multiple lamp on/off and hours
|
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.lamp = [{'Hours': 00000, 'On': True},
|
|
|
|
{'Hours': 11111, 'On': False}]
|
2018-01-13 05:41:42 +00:00
|
|
|
log_data = [call('({ip}) process_lamp(): Invalid data "11111 1 22222 0 333A3 1"'.format(ip=pjlink.name))]
|
2017-12-25 08:44:30 +00:00
|
|
|
|
|
|
|
# WHEN: Call process_command with invalid lamp data
|
|
|
|
pjlink.process_lamp('11111 1 22222 0 333A3 1')
|
|
|
|
|
|
|
|
# THEN: lamps should not have changed
|
|
|
|
assert 2 == len(pjlink.lamp), 'Projector should have kept 2 lamps specified'
|
|
|
|
assert pjlink.lamp[0]['On'] is True, 'Lamp 1 power status should have stayed TRUE'
|
|
|
|
assert 00000 == pjlink.lamp[0]['Hours'], 'Lamp 1 hours should have been left at 00000'
|
|
|
|
assert pjlink.lamp[1]['On'] is False, 'Lamp 2 power status should have stayed FALSE'
|
|
|
|
assert 11111 == pjlink.lamp[1]['Hours'], 'Lamp 2 hours should have been left at 11111'
|
|
|
|
mock_log.warning.assert_has_calls(log_data)
|
2016-04-22 11:41:29 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-12 09:48:38 +00:00
|
|
|
def test_projector_process_lamp_multiple(self):
|
2016-04-17 09:30:30 +00:00
|
|
|
"""
|
2016-05-15 17:33:42 +00:00
|
|
|
Test status multiple lamp on/off and hours
|
2016-04-17 09:30:30 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.lamp = []
|
2016-04-17 09:30:30 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: Call process_command with invalid lamp data
|
2017-08-12 09:48:38 +00:00
|
|
|
pjlink.process_lamp('11111 1 22222 0 33333 1')
|
2016-04-17 09:30:30 +00:00
|
|
|
|
2016-04-17 09:33:48 +00:00
|
|
|
# THEN: Lamp should have been set with proper lamp status
|
2017-12-25 08:44:30 +00:00
|
|
|
assert 3 == len(pjlink.lamp), 'Projector should have 3 lamps specified'
|
|
|
|
assert pjlink.lamp[0]['On'] is True, 'Lamp 1 power status should have been set to TRUE'
|
|
|
|
assert 11111 == pjlink.lamp[0]['Hours'], 'Lamp 1 hours should have been set to 11111'
|
|
|
|
assert pjlink.lamp[1]['On'] is False, 'Lamp 2 power status should have been set to FALSE'
|
|
|
|
assert 22222 == pjlink.lamp[1]['Hours'], 'Lamp 2 hours should have been set to 22222'
|
|
|
|
assert pjlink.lamp[2]['On'] is True, 'Lamp 3 power status should have been set to TRUE'
|
|
|
|
assert 33333 == pjlink.lamp[2]['Hours'], 'Lamp 3 hours should have been set to 33333'
|
2016-04-23 19:55:47 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-12 09:48:38 +00:00
|
|
|
def test_projector_process_lamp_single(self):
|
|
|
|
"""
|
|
|
|
Test status lamp on/off and hours
|
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
|
2017-08-12 09:48:38 +00:00
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.lamp = []
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: Call process_command with invalid lamp data
|
2017-08-12 09:48:38 +00:00
|
|
|
pjlink.process_lamp('22222 1')
|
|
|
|
|
|
|
|
# THEN: Lamp should have been set with status=ON and hours=22222
|
2017-12-25 08:44:30 +00:00
|
|
|
assert 1 == len(pjlink.lamp), 'Projector should have only 1 lamp'
|
|
|
|
assert pjlink.lamp[0]['On'] is True, 'Lamp power status should have been set to TRUE'
|
|
|
|
assert 22222 == pjlink.lamp[0]['Hours'], 'Lamp hours should have been set to 22222'
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2018-01-13 05:41:42 +00:00
|
|
|
def test_projector_process_lamp_single_hours_only(self):
|
|
|
|
"""
|
|
|
|
Test process lamp with 1 lamp reply hours only and no on/off status
|
|
|
|
"""
|
|
|
|
# GIVEN: Test object
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.lamp = []
|
|
|
|
|
|
|
|
# WHEN: Process lamp command called with only hours and no lamp power state
|
|
|
|
pjlink.process_lamp("45")
|
|
|
|
|
|
|
|
# THEN: Lamp should show hours as 45 and lamp power as Unavailable
|
|
|
|
assert 1 == len(pjlink.lamp), 'There should only be 1 lamp available'
|
|
|
|
assert 45 == pjlink.lamp[0]['Hours'], 'Lamp hours should have equalled 45'
|
|
|
|
assert pjlink.lamp[0]['On'] is None, 'Lamp power should be "None"'
|
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_name(self):
|
2017-08-12 09:48:38 +00:00
|
|
|
"""
|
|
|
|
Test saving NAME data from projector
|
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
2018-01-13 05:41:42 +00:00
|
|
|
chk_data = "Some Name the End-User Set IN Projector"
|
|
|
|
log_debug_calls = [call('({ip}) Setting projector PJLink name to '
|
|
|
|
'"Some Name the End-User Set IN Projector"'.format(ip=pjlink.name))]
|
2017-12-25 08:44:30 +00:00
|
|
|
|
|
|
|
# WHEN: process_name called with test data
|
|
|
|
pjlink.process_name(data=chk_data)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: name should be set and logged
|
|
|
|
assert pjlink.pjlink_name == chk_data, 'Name test data should have been saved'
|
|
|
|
mock_log.debug.assert_has_calls(log_debug_calls)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_powr_on(self):
|
2016-04-23 19:55:47 +00:00
|
|
|
"""
|
2016-05-15 17:33:42 +00:00
|
|
|
Test status power to ON
|
2016-04-23 19:55:47 +00:00
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'change_status') as mock_change_status, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') as mock_UpdateIcons:
|
|
|
|
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.power = S_STANDBY
|
2016-04-23 19:55:47 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: process_name called with test data
|
|
|
|
pjlink.process_powr(data=PJLINK_POWR_STATUS[S_ON])
|
2016-04-23 19:55:47 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Power should be set to ON
|
|
|
|
assert pjlink.power == S_ON, 'Power should have been set to ON'
|
|
|
|
assert mock_UpdateIcons.emit.called is True, 'projectorUpdateIcons should have been called'
|
|
|
|
mock_send_command.assert_called_once_with('INST')
|
|
|
|
mock_change_status.assert_called_once_with(S_ON)
|
2016-04-23 19:55:47 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_powr_invalid(self):
|
2017-08-12 09:48:38 +00:00
|
|
|
"""
|
|
|
|
Test process_powr invalid call
|
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'change_status') as mock_change_status, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') as mock_UpdateIcons:
|
|
|
|
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.power = S_STANDBY
|
2018-01-13 05:41:42 +00:00
|
|
|
log_warn_calls = [call('({ip}) Unknown power response: "99"'.format(ip=pjlink.name))]
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: process_name called with test data
|
|
|
|
pjlink.process_powr(data='99')
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Power should be set to ON
|
|
|
|
assert pjlink.power == S_STANDBY, 'Power should not have changed'
|
2019-03-03 17:44:40 +00:00
|
|
|
mock_UpdateIcons.emit.assert_not_called()
|
|
|
|
mock_change_status.assert_not_called()
|
|
|
|
mock_send_command.assert_not_called()
|
2017-12-25 08:44:30 +00:00
|
|
|
mock_log.warning.assert_has_calls(log_warn_calls)
|
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_powr_off(self):
|
2016-04-23 19:55:47 +00:00
|
|
|
"""
|
2016-05-15 17:33:42 +00:00
|
|
|
Test status power to STANDBY
|
2016-04-23 19:55:47 +00:00
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'change_status') as mock_change_status, \
|
|
|
|
patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') as mock_UpdateIcons:
|
2016-04-23 19:55:47 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.power = S_ON
|
2016-04-23 19:55:47 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: process_name called with test data
|
|
|
|
pjlink.process_powr(data=PJLINK_POWR_STATUS[S_STANDBY])
|
|
|
|
|
|
|
|
# THEN: Power should be set to ON
|
|
|
|
assert pjlink.power == S_STANDBY, 'Power should have changed to S_STANDBY'
|
2019-03-03 17:44:40 +00:00
|
|
|
mock_UpdateIcons.emit.assert_called_with()
|
|
|
|
mock_change_status.assert_called_with(313)
|
|
|
|
mock_send_command.assert_not_called()
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-06 07:23:26 +00:00
|
|
|
def test_projector_process_rfil_save(self):
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
2017-08-06 07:23:26 +00:00
|
|
|
Test saving filter type
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
filter_model = 'Filter Type Test'
|
|
|
|
|
2016-05-15 17:33:42 +00:00
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
2017-08-06 07:23:26 +00:00
|
|
|
pjlink.model_filter = None
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-08-06 07:23:26 +00:00
|
|
|
# WHEN: Filter model is received
|
|
|
|
pjlink.process_rfil(data=filter_model)
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-08-06 07:23:26 +00:00
|
|
|
# THEN: Filter model number should be saved
|
2017-12-25 08:44:30 +00:00
|
|
|
assert pjlink.model_filter == filter_model, 'Filter type should have been saved'
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-06 07:23:26 +00:00
|
|
|
def test_projector_process_rfil_nosave(self):
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
2017-08-06 07:23:26 +00:00
|
|
|
Test saving filter type previously saved
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.model_filter = 'Old filter type'
|
2018-01-13 05:41:42 +00:00
|
|
|
filter_model = 'Filter Type Test'
|
|
|
|
log_warn_calls = [call('({ip}) Filter model already set'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Saved model: "Old filter type"'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) New model: "Filter Type Test"'.format(ip=pjlink.name))]
|
2017-12-25 08:44:30 +00:00
|
|
|
|
|
|
|
# WHEN: Filter model is received
|
|
|
|
pjlink.process_rfil(data=filter_model)
|
|
|
|
|
|
|
|
# THEN: Filter model number should be saved
|
|
|
|
assert pjlink.model_filter != filter_model, 'Filter type should NOT have been saved'
|
|
|
|
mock_log.warning.assert_has_calls(log_warn_calls)
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-06 07:23:26 +00:00
|
|
|
def test_projector_process_rlmp_save(self):
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
2017-08-06 07:23:26 +00:00
|
|
|
Test saving lamp type
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
2017-08-06 07:23:26 +00:00
|
|
|
pjlink.model_lamp = None
|
|
|
|
lamp_model = 'Lamp Type Test'
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-08-06 07:23:26 +00:00
|
|
|
# WHEN: Filter model is received
|
|
|
|
pjlink.process_rlmp(data=lamp_model)
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-08-06 07:23:26 +00:00
|
|
|
# THEN: Filter model number should be saved
|
2017-12-26 04:14:39 +00:00
|
|
|
assert pjlink.model_lamp == lamp_model, 'Lamp type should have been saved'
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-06 07:23:26 +00:00
|
|
|
def test_projector_process_rlmp_nosave(self):
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
2017-08-06 07:23:26 +00:00
|
|
|
Test saving lamp type previously saved
|
2016-05-15 17:33:42 +00:00
|
|
|
"""
|
|
|
|
# GIVEN: Test object
|
2017-12-25 08:44:30 +00:00
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.model_lamp = 'Old lamp type'
|
2018-01-13 05:41:42 +00:00
|
|
|
lamp_model = 'Lamp Type Test'
|
|
|
|
log_warn_calls = [call('({ip}) Lamp model already set'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Saved lamp: "Old lamp type"'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) New lamp: "Lamp Type Test"'.format(ip=pjlink.name))]
|
2016-05-15 17:33:42 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: Filter model is received
|
|
|
|
pjlink.process_rlmp(data=lamp_model)
|
|
|
|
|
|
|
|
# THEN: Filter model number should be saved
|
|
|
|
assert pjlink.model_lamp != lamp_model, 'Lamp type should NOT have been saved'
|
|
|
|
mock_log.warning.assert_has_calls(log_warn_calls)
|
2016-05-21 18:19:18 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-06 07:23:26 +00:00
|
|
|
def test_projector_process_snum_set(self):
|
2016-05-21 18:19:18 +00:00
|
|
|
"""
|
2017-08-06 07:23:26 +00:00
|
|
|
Test saving serial number from projector
|
2016-05-21 18:19:18 +00:00
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.serial_no = None
|
2018-01-13 05:41:42 +00:00
|
|
|
log_debug_calls = [call('({ip}) Setting projector serial number to '
|
|
|
|
'"Test Serial Number"'.format(ip=pjlink.name))]
|
|
|
|
test_number = 'Test Serial Number'
|
2016-06-18 02:02:53 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: No serial number is set and we receive serial number command
|
|
|
|
pjlink.process_snum(data=test_number)
|
|
|
|
|
|
|
|
# THEN: Serial number should be set
|
|
|
|
assert pjlink.serial_no == test_number, 'Projector serial number should have been set'
|
|
|
|
mock_log.debug.assert_has_calls(log_debug_calls)
|
2017-05-12 09:51:56 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-08-06 07:23:26 +00:00
|
|
|
def test_projector_process_snum_different(self):
|
2017-05-13 09:00:29 +00:00
|
|
|
"""
|
2017-08-06 07:23:26 +00:00
|
|
|
Test projector serial number different than saved serial number
|
2017-05-13 09:00:29 +00:00
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.serial_no = 'Previous serial number'
|
2018-01-13 05:41:42 +00:00
|
|
|
log_warn_calls = [call('({ip}) Projector serial number does not match '
|
|
|
|
'saved serial number'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Saved: "Previous serial number"'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Received: "Test Serial Number"'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) NOT saving serial number'.format(ip=pjlink.name))]
|
|
|
|
test_number = 'Test Serial Number'
|
2017-05-13 09:00:29 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: No serial number is set and we receive serial number command
|
|
|
|
pjlink.process_snum(data=test_number)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Serial number should be set
|
|
|
|
assert pjlink.serial_no != test_number, 'Projector serial number should NOT have been set'
|
|
|
|
mock_log.warning.assert_has_calls(log_warn_calls)
|
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_sver(self):
|
2017-08-12 09:48:38 +00:00
|
|
|
"""
|
|
|
|
Test invalid software version information - too long
|
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.sw_version = None
|
|
|
|
pjlink.sw_version_received = None
|
2018-01-13 05:41:42 +00:00
|
|
|
test_data = 'Test 1 Subtest 1'
|
|
|
|
log_debug_calls = [call('({ip}) Setting projector software version to '
|
|
|
|
'"Test 1 Subtest 1"'.format(ip=pjlink.name))]
|
2017-12-25 08:44:30 +00:00
|
|
|
|
|
|
|
# WHEN: process_sver called with invalid data
|
|
|
|
pjlink.process_sver(data=test_data)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Version information should not change
|
|
|
|
assert pjlink.sw_version == test_data, 'Software version should have been updated'
|
|
|
|
mock_log.debug.assert_has_calls(log_debug_calls)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_sver_changed(self):
|
2017-08-12 09:48:38 +00:00
|
|
|
"""
|
|
|
|
Test invalid software version information - Received different than saved
|
|
|
|
"""
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
2018-01-13 05:41:42 +00:00
|
|
|
test_data_old = 'Test 1 Subtest 1'
|
|
|
|
test_data_new = 'Test 1 Subtest 2'
|
|
|
|
log_warn_calls = [call('({ip}) Projector software version does not match '
|
|
|
|
'saved software version'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Saved: "Test 1 Subtest 1"'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Received: "Test 1 Subtest 2"'.format(ip=pjlink.name)),
|
|
|
|
call('({ip}) Updating software version'.format(ip=pjlink.name))]
|
2017-12-25 08:44:30 +00:00
|
|
|
pjlink.sw_version = test_data_old
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# WHEN: process_sver called with invalid data
|
|
|
|
pjlink.process_sver(data=test_data_new)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Version information should not change
|
|
|
|
assert pjlink.sw_version == test_data_new, 'Software version should have changed'
|
|
|
|
mock_log.warning.assert_has_calls(log_warn_calls)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2019-04-21 01:04:59 +00:00
|
|
|
@skip('Needs update to new setup')
|
2017-12-25 08:44:30 +00:00
|
|
|
def test_projector_process_sver_invalid(self):
|
2017-08-12 09:48:38 +00:00
|
|
|
"""
|
|
|
|
Test invalid software version information - too long
|
|
|
|
"""
|
|
|
|
test_data = 'This is a test software version line that is too long based on PJLink version 2 specs'
|
2017-12-25 08:44:30 +00:00
|
|
|
log_warn_calls = [call('Invalid software version - too long')]
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# GIVEN: Test object
|
|
|
|
with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
|
|
|
|
pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
|
|
|
pjlink.sw_version = None
|
|
|
|
|
|
|
|
# WHEN: process_sver called with invalid data
|
|
|
|
pjlink.process_sver(data=test_data)
|
2017-08-12 09:48:38 +00:00
|
|
|
|
2017-12-25 08:44:30 +00:00
|
|
|
# THEN: Version information should not change
|
|
|
|
assert pjlink.sw_version is None, 'Software version should not have changed'
|
|
|
|
assert pjlink.sw_version_received is None, 'Received software version should not have changed'
|
|
|
|
mock_log.warning.assert_has_calls(log_warn_calls)
|