Ken Roberts has proposed merging lp:~alisonken1/openlp/pjlink2-v02 into
lp:openlp with lp:~alisonken1/openlp/pjlink2-v1 as a prerequisite.
Commit message:
PJLink2 Update V02
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~alisonken1/openlp/pjlink2-v02/+merge/366554
NOTE: Part 2 of a multi-part merge.
v[2..n] merges are to fix tests
WARNING: Requires merge of lp:~alisonken1/openlp/pjlink2-v1
- Updated pjlink imports
- Added setUp() and tearDown() to pjlinkcommands.py::TestPJLinkBase to have a
common
pjlink() instance creation
- Fix tests in test_projector_pjlink_base_01.py
- Move patch.object context managers to decorators
lp:~alisonken1/openlp/pjlink2-v02 (revision 2860)
https://ci.openlp.io/job/Branch-01-Pull/2720/ [SUCCESS]
https://ci.openlp.io/job/Branch-02a-Linux-Tests/2614/ [SUCCESS]
https://ci.openlp.io/job/Branch-02b-macOS-Tests/389/ [SUCCESS]
https://ci.openlp.io/job/Branch-03a-Build-Source/212/ [SUCCESS]
https://ci.openlp.io/job/Branch-03b-Build-macOS/191/ [SUCCESS]
https://ci.openlp.io/job/Branch-04a-Code-Lint/1674/[SUCCESS]
https://ci.openlp.io/job/Branch-04b-Test-Coverage/1487/[SUCCESS]
https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/369/ [FAILURE]
Stopping after failure
--
Your team OpenLP Core is requested to review the proposed merge of
lp:~alisonken1/openlp/pjlink2-v02 into lp:openlp.
=== modified file 'tests/openlp_core/projectors/test_projector_pjlink_base_01.py'
--- tests/openlp_core/projectors/test_projector_pjlink_base_01.py 2019-04-26 07:51:13 +
+++ tests/openlp_core/projectors/test_projector_pjlink_base_01.py 2019-04-26 07:51:13 +
@@ -22,10 +22,11 @@
"""
Package to test the openlp.core.projectors.pjlink base package.
"""
-from unittest import TestCase, skip
+from unittest import TestCase
from unittest.mock import MagicMock, call, patch
import openlp.core.projectors.pjlink
+from openlp.core.projectors.pjlinkcommands import process_command
from openlp.core.projectors.constants import E_NOT_CONNECTED, E_PARAMETER, E_UNKNOWN_SOCKET_ERROR, QSOCKET_STATE, \
S_CONNECTED, S_CONNECTING, S_NOT_CONNECTED, S_OK, S_ON, STATUS_CODE, STATUS_MSG
from openlp.core.projectors.db import Projector
@@ -37,47 +38,56 @@
"""
Tests for the PJLink module
"""
-@skip('Needs update to new setup')
-def test_status_change(self):
+def setUp(self):
+"""
+Initialize test state(s)
+"""
+# Default PJLink instance for tests
+self.pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
+
+def tearDown(self):
+"""
+Cleanup test state(s)
+"""
+del(self.pjlink)
+
+@patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus')
+def test_status_change(self, mock_changeStatus):
"""
Test process_command call with ERR2 (Parameter) status
"""
# GIVEN: Test object
-with patch('openlp.core.projectors.pjlink.PJLink.changeStatus') as mock_changeStatus:
-
-pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
-
-# WHEN: process_command is called with "ERR2" status from projector
-pjlink.process_command('POWR', 'ERR2')
-
-# THEN: change_status should have called change_status with E_UNDEFINED
-# as first parameter
-mock_changeStatus.called_with(E_PARAMETER,
- 'change_status should have been called with "{}"'.format(
- STATUS_CODE[E_PARAMETER]))
-
-@skip('Needs update to new setup')
-def test_socket_abort(self):
+pjlink = self.pjlink
+
+# WHEN: process_command is called with "ERR2" status from projector
+process_command(projector=pjlink, cmd='POWR', data='ERR2')
+
+# THEN: change_status should have called change_status with E_UNDEFINED
+# as first parameter
+mock_changeStatus.called_with(E_PARAMETER,
+ 'change_status should have been called '
+ 'with "{}"'.format(STATUS_CODE[E_PARAMETER]))
+
+@patch.object(openlp.core.projectors.pjlink.PJLink, 'disconnect_from_host')
+def test_socket_abort(self, mock_disconnect):
"""
Test PJLink.socket_abort calls disconnect_from_host
"""
# GIVEN: Test object
-with patch('openlp.core.projectors.pjlink.PJLink.disconnect_from_host') as mock_disconnect:
-pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
-
-# WHEN: Calling socket_abort
-pjlink.socket_abort()
-
-# THEN: disconnect_from_host should be called
-assert