From d5b98b73081130626428f69b4be70d1718236a7f Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Sat, 23 Apr 2016 12:55:47 -0700 Subject: [PATCH] Added projector power test --- openlp/core/lib/projector/constants.py | 6 +++- .../openlp_core_lib/test_projector_pjlink1.py | 33 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/projector/constants.py b/openlp/core/lib/projector/constants.py index 6bfc88a6f..5c0d6c6c2 100644 --- a/openlp/core/lib/projector/constants.py +++ b/openlp/core/lib/projector/constants.py @@ -297,7 +297,11 @@ PJLINK_ERST_STATUS = {'0': ERROR_STRING[E_OK], PJLINK_POWR_STATUS = {'0': S_STANDBY, '1': S_ON, '2': S_COOLDOWN, - '3': S_WARMUP} + '3': S_WARMUP, + S_STANDBY: '0', + S_ON: '1', + S_COOLDOWN: '2', + S_WARMUP: '3'} PJLINK_DEFAULT_SOURCES = {'1': translate('OpenLP.DB', 'RGB'), '2': translate('OpenLP.DB', 'Video'), diff --git a/tests/functional/openlp_core_lib/test_projector_pjlink1.py b/tests/functional/openlp_core_lib/test_projector_pjlink1.py index 5d0d26ceb..95d86efe9 100644 --- a/tests/functional/openlp_core_lib/test_projector_pjlink1.py +++ b/tests/functional/openlp_core_lib/test_projector_pjlink1.py @@ -26,7 +26,8 @@ Package to test the openlp.core.lib.projector.pjlink1 package. from unittest import TestCase from openlp.core.lib.projector.pjlink1 import PJLink1 -from openlp.core.lib.projector.constants import E_PARAMETER, ERROR_STRING +from openlp.core.lib.projector.constants import E_PARAMETER, ERROR_STRING, S_OFF, S_STANDBY, S_WARMUP, S_ON, \ + S_COOLDOWN, PJLINK_POWR_STATUS from tests.functional import patch from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE @@ -151,3 +152,33 @@ class TestPJLink(TestCase): 'Lamp 3 power status should have been set to TRUE') self.assertEquals(pjlink.lamp[2]['Hours'], 33333, 'Lamp 3 hours should have been set to 33333') + + @patch.object(pjlink_test, 'projectorReceivedData') + def projector_process_power_on_test(self, mock_projectorReceivedData): + """ + Test setting power on + """ + # GIVEN: Test object and preset + pjlink = pjlink_test + pjlink.power = S_STANDBY + + # WHEN: Call process_command with turn power on command + pjlink.process_command('POWR', PJLINK_POWR_STATUS[S_ON]) + + # THEN: Power should be set to ON + 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): + """ + Test setting power off + """ + # GIVEN: Test object and preset + pjlink = pjlink_test + pjlink.power = S_ON + + # WHEN: Call process_command with turn power on command + pjlink.process_command('POWR', PJLINK_POWR_STATUS[S_STANDBY]) + + # THEN: Power should be set to ON + self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY')