Merge lp:~alisonken1/openlp/pjlink2-v02 into lp:openlp
- pjlink2-v02
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 2860 |
Proposed branch: | lp:~alisonken1/openlp/pjlink2-v02 |
Merge into: | lp:openlp |
Prerequisite: | lp:~alisonken1/openlp/pjlink2-v1 |
Diff against target: |
856 lines (+352/-385) 1 file modified
tests/openlp_core/projectors/test_projector_pjlink_base_01.py (+352/-385) |
To merge this branch: | bzr merge lp:~alisonken1/openlp/pjlink2-v02 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tomas Groth | Approve | ||
Tim Bentley | Approve | ||
Review via email:
|
Commit message
PJLink2 Update V02
Description of the change
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.
pjlink() instance creation
- Fix tests in test_projector_
- Move patch.object context managers to decorators
-------
lp:~alisonken1/openlp/pjlink2-v02 (revision 2860)
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
Stopping after failure
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) wrote : | # |
Linting passed!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) wrote : | # |
macOS tests passed!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tim Bentley (trb143) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tomas Groth (tomasgroth) : | # |
Preview Diff
1 | === modified file 'tests/openlp_core/projectors/test_projector_pjlink_base_01.py' | |||
2 | --- tests/openlp_core/projectors/test_projector_pjlink_base_01.py 2019-04-26 07:51:13 +0000 | |||
3 | +++ tests/openlp_core/projectors/test_projector_pjlink_base_01.py 2019-04-26 07:51:13 +0000 | |||
4 | @@ -22,10 +22,11 @@ | |||
5 | 22 | """ | 22 | """ |
6 | 23 | Package to test the openlp.core.projectors.pjlink base package. | 23 | Package to test the openlp.core.projectors.pjlink base package. |
7 | 24 | """ | 24 | """ |
9 | 25 | from unittest import TestCase, skip | 25 | from unittest import TestCase |
10 | 26 | from unittest.mock import MagicMock, call, patch | 26 | from unittest.mock import MagicMock, call, patch |
11 | 27 | 27 | ||
12 | 28 | import openlp.core.projectors.pjlink | 28 | import openlp.core.projectors.pjlink |
13 | 29 | from openlp.core.projectors.pjlinkcommands import process_command | ||
14 | 29 | from openlp.core.projectors.constants import E_NOT_CONNECTED, E_PARAMETER, E_UNKNOWN_SOCKET_ERROR, QSOCKET_STATE, \ | 30 | from openlp.core.projectors.constants import E_NOT_CONNECTED, E_PARAMETER, E_UNKNOWN_SOCKET_ERROR, QSOCKET_STATE, \ |
15 | 30 | S_CONNECTED, S_CONNECTING, S_NOT_CONNECTED, S_OK, S_ON, STATUS_CODE, STATUS_MSG | 31 | S_CONNECTED, S_CONNECTING, S_NOT_CONNECTED, S_OK, S_ON, STATUS_CODE, STATUS_MSG |
16 | 31 | from openlp.core.projectors.db import Projector | 32 | from openlp.core.projectors.db import Projector |
17 | @@ -37,47 +38,56 @@ | |||
18 | 37 | """ | 38 | """ |
19 | 38 | Tests for the PJLink module | 39 | Tests for the PJLink module |
20 | 39 | """ | 40 | """ |
23 | 40 | @skip('Needs update to new setup') | 41 | def setUp(self): |
24 | 41 | def test_status_change(self): | 42 | """ |
25 | 43 | Initialize test state(s) | ||
26 | 44 | """ | ||
27 | 45 | # Default PJLink instance for tests | ||
28 | 46 | self.pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | ||
29 | 47 | |||
30 | 48 | def tearDown(self): | ||
31 | 49 | """ | ||
32 | 50 | Cleanup test state(s) | ||
33 | 51 | """ | ||
34 | 52 | del(self.pjlink) | ||
35 | 53 | |||
36 | 54 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') | ||
37 | 55 | def test_status_change(self, mock_changeStatus): | ||
38 | 42 | """ | 56 | """ |
39 | 43 | Test process_command call with ERR2 (Parameter) status | 57 | Test process_command call with ERR2 (Parameter) status |
40 | 44 | """ | 58 | """ |
41 | 45 | # GIVEN: Test object | 59 | # GIVEN: Test object |
57 | 46 | with patch('openlp.core.projectors.pjlink.PJLink.changeStatus') as mock_changeStatus: | 60 | pjlink = self.pjlink |
58 | 47 | 61 | ||
59 | 48 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 62 | # WHEN: process_command is called with "ERR2" status from projector |
60 | 49 | 63 | process_command(projector=pjlink, cmd='POWR', data='ERR2') | |
61 | 50 | # WHEN: process_command is called with "ERR2" status from projector | 64 | |
62 | 51 | pjlink.process_command('POWR', 'ERR2') | 65 | # THEN: change_status should have called change_status with E_UNDEFINED |
63 | 52 | 66 | # as first parameter | |
64 | 53 | # THEN: change_status should have called change_status with E_UNDEFINED | 67 | mock_changeStatus.called_with(E_PARAMETER, |
65 | 54 | # as first parameter | 68 | 'change_status should have been called ' |
66 | 55 | mock_changeStatus.called_with(E_PARAMETER, | 69 | 'with "{}"'.format(STATUS_CODE[E_PARAMETER])) |
67 | 56 | 'change_status should have been called with "{}"'.format( | 70 | |
68 | 57 | STATUS_CODE[E_PARAMETER])) | 71 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'disconnect_from_host') |
69 | 58 | 72 | def test_socket_abort(self, mock_disconnect): | |
55 | 59 | @skip('Needs update to new setup') | ||
56 | 60 | def test_socket_abort(self): | ||
70 | 61 | """ | 73 | """ |
71 | 62 | Test PJLink.socket_abort calls disconnect_from_host | 74 | Test PJLink.socket_abort calls disconnect_from_host |
72 | 63 | """ | 75 | """ |
73 | 64 | # GIVEN: Test object | 76 | # GIVEN: Test object |
84 | 65 | with patch('openlp.core.projectors.pjlink.PJLink.disconnect_from_host') as mock_disconnect: | 77 | pjlink = self.pjlink |
85 | 66 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 78 | |
86 | 67 | 79 | # WHEN: Calling socket_abort | |
87 | 68 | # WHEN: Calling socket_abort | 80 | pjlink.socket_abort() |
88 | 69 | pjlink.socket_abort() | 81 | |
89 | 70 | 82 | # THEN: disconnect_from_host should be called | |
90 | 71 | # THEN: disconnect_from_host should be called | 83 | assert mock_disconnect.called is True, 'Should have called disconnect_from_host' |
91 | 72 | assert mock_disconnect.called is True, 'Should have called disconnect_from_host' | 84 | |
82 | 73 | |||
83 | 74 | @skip('Needs update to new setup') | ||
92 | 75 | def test_poll_loop_not_connected(self): | 85 | def test_poll_loop_not_connected(self): |
93 | 76 | """ | 86 | """ |
94 | 77 | Test PJLink.poll_loop not connected return | 87 | Test PJLink.poll_loop not connected return |
95 | 78 | """ | 88 | """ |
98 | 79 | # GIVEN: Test object and mocks | 89 | # GIVEN: Test object |
99 | 80 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 90 | pjlink = self.pjlink |
100 | 81 | pjlink.state = MagicMock() | 91 | pjlink.state = MagicMock() |
101 | 82 | pjlink.timer = MagicMock() | 92 | pjlink.timer = MagicMock() |
102 | 83 | pjlink.state.return_value = False | 93 | pjlink.state.return_value = False |
103 | @@ -89,412 +99,371 @@ | |||
104 | 89 | # THEN: poll_loop should exit without calling any other method | 99 | # THEN: poll_loop should exit without calling any other method |
105 | 90 | assert pjlink.timer.called is False, 'Should have returned without calling any other method' | 100 | assert pjlink.timer.called is False, 'Should have returned without calling any other method' |
106 | 91 | 101 | ||
109 | 92 | @skip('Needs update to new setup') | 102 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
110 | 93 | def test_poll_loop_set_interval(self): | 103 | def test_poll_loop_set_interval(self, mock_send_command): |
111 | 94 | """ | 104 | """ |
112 | 95 | Test PJLink.poll_loop makes correct calls | 105 | Test PJLink.poll_loop makes correct calls |
113 | 96 | """ | 106 | """ |
154 | 97 | # GIVEN: Mocks and test data | 107 | # GIVEN: Test object and data |
155 | 98 | with patch('openlp.core.projectors.pjlink.PJLink.send_command') as mock_send_command: | 108 | pjlink = self.pjlink |
156 | 99 | 109 | pjlink.state = MagicMock() | |
157 | 100 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 110 | pjlink.state.return_value = QSOCKET_STATE[S_CONNECTED] |
158 | 101 | pjlink.state = MagicMock() | 111 | pjlink.poll_timer = MagicMock() |
159 | 102 | pjlink.state.return_value = QSOCKET_STATE[S_CONNECTED] | 112 | pjlink.poll_timer.interval.return_value = 10 |
160 | 103 | pjlink.poll_timer = MagicMock() | 113 | |
161 | 104 | pjlink.poll_timer.interval.return_value = 10 | 114 | pjlink.poll_time = 20 |
162 | 105 | 115 | pjlink.power = S_ON | |
163 | 106 | pjlink.poll_time = 20 | 116 | pjlink.source_available = None |
164 | 107 | pjlink.power = S_ON | 117 | pjlink.other_info = None |
165 | 108 | pjlink.source_available = None | 118 | pjlink.manufacturer = None |
166 | 109 | pjlink.other_info = None | 119 | pjlink.model = None |
167 | 110 | pjlink.manufacturer = None | 120 | pjlink.pjlink_name = None |
168 | 111 | pjlink.model = None | 121 | call_list = [ |
169 | 112 | pjlink.pjlink_name = None | 122 | call('POWR'), |
170 | 113 | call_list = [ | 123 | call('ERST'), |
171 | 114 | call('POWR'), | 124 | call('LAMP'), |
172 | 115 | call('ERST'), | 125 | call('AVMT'), |
173 | 116 | call('LAMP'), | 126 | call('INPT'), |
174 | 117 | call('AVMT'), | 127 | call('INST'), |
175 | 118 | call('INPT'), | 128 | call('INFO'), |
176 | 119 | call('INST'), | 129 | call('INF1'), |
177 | 120 | call('INFO'), | 130 | call('INF2'), |
178 | 121 | call('INF1'), | 131 | call('NAME'), |
179 | 122 | call('INF2'), | 132 | ] |
180 | 123 | call('NAME'), | 133 | |
181 | 124 | ] | 134 | # WHEN: PJLink.poll_loop is called |
182 | 125 | 135 | pjlink.poll_loop() | |
183 | 126 | # WHEN: PJLink.poll_loop is called | 136 | |
184 | 127 | pjlink.poll_loop() | 137 | # THEN: proper calls were made to retrieve projector data |
185 | 128 | 138 | # First, call to update the timer with the next interval | |
186 | 129 | # THEN: proper calls were made to retrieve projector data | 139 | assert pjlink.poll_timer.setInterval.called is True, 'Timer update interval should have been called' |
187 | 130 | # First, call to update the timer with the next interval | 140 | # Finally, should have called send_command with a list of projetctor status checks |
188 | 131 | assert pjlink.poll_timer.setInterval.called is True, 'Timer update interval should have been called' | 141 | mock_send_command.assert_has_calls(call_list, 'Should have queued projector queries') |
189 | 132 | # Finally, should have called send_command with a list of projetctor status checks | 142 | |
190 | 133 | mock_send_command.assert_has_calls(call_list, 'Should have queued projector queries') | 143 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') |
191 | 134 | 144 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') | |
192 | 135 | @skip('Needs update to new setup') | 145 | @patch.object(openlp.core.projectors.pjlink, 'log') |
193 | 136 | def test_projector_change_status_unknown_socket_error(self): | 146 | def test_projector_change_status_unknown_socket_error(self, mock_log, mock_changeStatus, mock_UpdateIcons): |
194 | 137 | """ | 147 | """ |
195 | 138 | Test change_status with connection error | 148 | Test change_status with connection error |
196 | 139 | """ | 149 | """ |
232 | 140 | # GIVEN: Test object and mocks | 150 | # GIVEN: Test object |
233 | 141 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 151 | pjlink = self.pjlink |
234 | 142 | patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') as mock_changeStatus, \ | 152 | pjlink.projector_status = 0 |
235 | 143 | patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') as mock_UpdateIcons: | 153 | pjlink.status_connect = 0 |
236 | 144 | 154 | log_debug_calls = [ | |
237 | 145 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 155 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, |
238 | 146 | pjlink.projector_status = 0 | 156 | status=STATUS_CODE[E_UNKNOWN_SOCKET_ERROR], |
239 | 147 | pjlink.status_connect = 0 | 157 | msg=STATUS_MSG[E_UNKNOWN_SOCKET_ERROR])), |
240 | 148 | log_debug_calls = [ | 158 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, |
241 | 149 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, | 159 | code=STATUS_CODE[E_NOT_CONNECTED], |
242 | 150 | status=STATUS_CODE[E_UNKNOWN_SOCKET_ERROR], | 160 | msg=STATUS_MSG[E_NOT_CONNECTED])), |
243 | 151 | msg=STATUS_MSG[E_UNKNOWN_SOCKET_ERROR])), | 161 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, |
244 | 152 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, | 162 | code=STATUS_CODE[S_OK], |
245 | 153 | code=STATUS_CODE[E_NOT_CONNECTED], | 163 | msg=STATUS_MSG[S_OK])), |
246 | 154 | msg=STATUS_MSG[E_NOT_CONNECTED])), | 164 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, |
247 | 155 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, | 165 | code=STATUS_CODE[E_UNKNOWN_SOCKET_ERROR], |
248 | 156 | code=STATUS_CODE[S_OK], | 166 | msg=STATUS_MSG[E_UNKNOWN_SOCKET_ERROR]))] |
249 | 157 | msg=STATUS_MSG[S_OK])), | 167 | |
250 | 158 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | 168 | # WHEN: change_status called with unknown socket error |
251 | 159 | code=STATUS_CODE[E_UNKNOWN_SOCKET_ERROR], | 169 | pjlink.change_status(status=E_UNKNOWN_SOCKET_ERROR) |
252 | 160 | msg=STATUS_MSG[E_UNKNOWN_SOCKET_ERROR]))] | 170 | |
253 | 161 | 171 | # THEN: Proper settings should change and signals sent | |
254 | 162 | # WHEN: change_status called with unknown socket error | 172 | mock_log.debug.assert_has_calls(log_debug_calls) |
255 | 163 | pjlink.change_status(status=E_UNKNOWN_SOCKET_ERROR) | 173 | assert pjlink.projector_status == S_OK, 'Projector status should not have changed' |
256 | 164 | 174 | assert pjlink.status_connect == E_NOT_CONNECTED, 'Status connect should be NOT CONNECTED' | |
257 | 165 | # THEN: Proper settings should change and signals sent | 175 | assert mock_UpdateIcons.emit.called is True, 'Should have called UpdateIcons' |
258 | 166 | mock_log.debug.assert_has_calls(log_debug_calls) | 176 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, E_UNKNOWN_SOCKET_ERROR, |
259 | 167 | assert pjlink.projector_status == S_OK, 'Projector status should not have changed' | 177 | STATUS_MSG[E_UNKNOWN_SOCKET_ERROR]) |
260 | 168 | assert pjlink.status_connect == E_NOT_CONNECTED, 'Status connect should be NOT CONNECTED' | 178 | |
261 | 169 | assert mock_UpdateIcons.emit.called is True, 'Should have called UpdateIcons' | 179 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') |
262 | 170 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, E_UNKNOWN_SOCKET_ERROR, | 180 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') |
263 | 171 | STATUS_MSG[E_UNKNOWN_SOCKET_ERROR]) | 181 | @patch.object(openlp.core.projectors.pjlink, 'log') |
264 | 172 | 182 | def test_projector_change_status_connection_status_connecting(self, mock_log, mock_changeStatus, mock_UpdateIcons): | |
230 | 173 | @skip('Needs update to new setup') | ||
231 | 174 | def test_projector_change_status_connection_status_connecting(self): | ||
265 | 175 | """ | 183 | """ |
266 | 176 | Test change_status with connecting status | 184 | Test change_status with connecting status |
267 | 177 | """ | 185 | """ |
282 | 178 | # GIVEN: Test object and mocks | 186 | # GIVEN: Test object |
283 | 179 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 187 | pjlink = self.pjlink |
284 | 180 | patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') as mock_changeStatus, \ | 188 | pjlink.projector_status = 0 |
285 | 181 | patch.object(openlp.core.projectors.pjlink.PJLink, 'projectorUpdateIcons') as mock_UpdateIcons: | 189 | pjlink.status_connect = 0 |
286 | 182 | 190 | log_debug_calls = [ | |
287 | 183 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 191 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, |
288 | 184 | pjlink.projector_status = 0 | 192 | status=STATUS_CODE[S_CONNECTING], |
275 | 185 | pjlink.status_connect = 0 | ||
276 | 186 | log_debug_calls = [ | ||
277 | 187 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, | ||
278 | 188 | status=STATUS_CODE[S_CONNECTING], | ||
279 | 189 | msg=STATUS_MSG[S_CONNECTING])), | ||
280 | 190 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, | ||
281 | 191 | code=STATUS_CODE[S_CONNECTING], | ||
289 | 192 | msg=STATUS_MSG[S_CONNECTING])), | 193 | msg=STATUS_MSG[S_CONNECTING])), |
294 | 193 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, | 194 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, |
295 | 194 | code=STATUS_CODE[S_OK], | 195 | code=STATUS_CODE[S_CONNECTING], |
296 | 195 | msg=STATUS_MSG[S_OK])), | 196 | msg=STATUS_MSG[S_CONNECTING])), |
297 | 196 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | 197 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, |
298 | 197 | code=STATUS_CODE[S_OK], | 198 | code=STATUS_CODE[S_OK], |
313 | 198 | msg=STATUS_MSG[S_OK]))] | 199 | msg=STATUS_MSG[S_OK])), |
314 | 199 | 200 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | |
315 | 200 | # WHEN: change_status called with CONNECTING | 201 | code=STATUS_CODE[S_OK], |
316 | 201 | pjlink.change_status(status=S_CONNECTING) | 202 | msg=STATUS_MSG[S_OK]))] |
317 | 202 | 203 | ||
318 | 203 | # THEN: Proper settings should change and signals sent | 204 | # WHEN: change_status called with CONNECTING |
319 | 204 | mock_log.debug.assert_has_calls(log_debug_calls) | 205 | pjlink.change_status(status=S_CONNECTING) |
320 | 205 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, S_CONNECTING, STATUS_MSG[S_CONNECTING]) | 206 | |
321 | 206 | assert pjlink.projector_status == S_OK, 'Projector status should not have changed' | 207 | # THEN: Proper settings should change and signals sent |
322 | 207 | assert pjlink.status_connect == S_CONNECTING, 'Status connect should be CONNECTING' | 208 | mock_log.debug.assert_has_calls(log_debug_calls) |
323 | 208 | assert mock_UpdateIcons.emit.called is True, 'Should have called UpdateIcons' | 209 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, S_CONNECTING, STATUS_MSG[S_CONNECTING]) |
324 | 209 | 210 | assert pjlink.projector_status == S_OK, 'Projector status should not have changed' | |
325 | 210 | @skip('Needs update to new setup') | 211 | assert pjlink.status_connect == S_CONNECTING, 'Status connect should be CONNECTING' |
326 | 211 | def test_projector_change_status_connection_status_connected(self): | 212 | assert mock_UpdateIcons.emit.called is True, 'Should have called UpdateIcons' |
327 | 213 | |||
328 | 214 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') | ||
329 | 215 | @patch.object(openlp.core.projectors.pjlink, 'log') | ||
330 | 216 | def test_projector_change_status_connection_status_connected(self, mock_log, mock_changeStatus): | ||
331 | 212 | """ | 217 | """ |
332 | 213 | Test change_status with connected status | 218 | Test change_status with connected status |
333 | 214 | """ | 219 | """ |
347 | 215 | # GIVEN: Test object and mocks | 220 | # GIVEN: Test object |
348 | 216 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 221 | pjlink = self.pjlink |
349 | 217 | patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') as mock_changeStatus: | 222 | pjlink.projector_status = 0 |
350 | 218 | 223 | pjlink.status_connect = 0 | |
351 | 219 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 224 | log_debug_calls = [ |
352 | 220 | pjlink.projector_status = 0 | 225 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, |
353 | 221 | pjlink.status_connect = 0 | 226 | status=STATUS_CODE[S_CONNECTED], |
341 | 222 | log_debug_calls = [ | ||
342 | 223 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, | ||
343 | 224 | status=STATUS_CODE[S_CONNECTED], | ||
344 | 225 | msg=STATUS_MSG[S_CONNECTED])), | ||
345 | 226 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, | ||
346 | 227 | code=STATUS_CODE[S_CONNECTED], | ||
354 | 228 | msg=STATUS_MSG[S_CONNECTED])), | 227 | msg=STATUS_MSG[S_CONNECTED])), |
359 | 229 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, | 228 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, |
360 | 230 | code=STATUS_CODE[S_OK], | 229 | code=STATUS_CODE[S_CONNECTED], |
361 | 231 | msg=STATUS_MSG[S_OK])), | 230 | msg=STATUS_MSG[S_CONNECTED])), |
362 | 232 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | 231 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, |
363 | 233 | code=STATUS_CODE[S_OK], | 232 | code=STATUS_CODE[S_OK], |
377 | 234 | msg=STATUS_MSG[S_OK]))] | 233 | msg=STATUS_MSG[S_OK])), |
378 | 235 | 234 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | |
379 | 236 | # WHEN: change_status called with CONNECTED | 235 | code=STATUS_CODE[S_OK], |
380 | 237 | pjlink.change_status(status=S_CONNECTED) | 236 | msg=STATUS_MSG[S_OK]))] |
381 | 238 | 237 | ||
382 | 239 | # THEN: Proper settings should change and signals sent | 238 | # WHEN: change_status called with CONNECTED |
383 | 240 | mock_log.debug.assert_has_calls(log_debug_calls) | 239 | pjlink.change_status(status=S_CONNECTED) |
384 | 241 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, S_CONNECTED, 'Connected') | 240 | |
385 | 242 | assert pjlink.projector_status == S_OK, 'Projector status should not have changed' | 241 | # THEN: Proper settings should change and signals sent |
386 | 243 | assert pjlink.status_connect == S_CONNECTED, 'Status connect should be CONNECTED' | 242 | mock_log.debug.assert_has_calls(log_debug_calls) |
387 | 244 | 243 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, S_CONNECTED, 'Connected') | |
388 | 245 | @skip('Needs update to new setup') | 244 | assert pjlink.projector_status == S_OK, 'Projector status should not have changed' |
389 | 246 | def test_projector_change_status_connection_status_with_message(self): | 245 | assert pjlink.status_connect == S_CONNECTED, 'Status connect should be CONNECTED' |
390 | 246 | |||
391 | 247 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') | ||
392 | 248 | @patch.object(openlp.core.projectors.pjlink, 'log') | ||
393 | 249 | def test_projector_change_status_connection_status_with_message(self, mock_log, mock_changeStatus): | ||
394 | 247 | """ | 250 | """ |
395 | 248 | Test change_status with connection status | 251 | Test change_status with connection status |
396 | 249 | """ | 252 | """ |
411 | 250 | # GIVEN: Test object and mocks | 253 | # GIVEN: Test object |
412 | 251 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 254 | pjlink = self.pjlink |
413 | 252 | patch.object(openlp.core.projectors.pjlink.PJLink, 'changeStatus') as mock_changeStatus: | 255 | pjlink.projector_status = 0 |
414 | 253 | 256 | pjlink.status_connect = 0 | |
415 | 254 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 257 | test_message = 'Different Status Message than default' |
416 | 255 | pjlink.projector_status = 0 | 258 | log_debug_calls = [ |
417 | 256 | pjlink.status_connect = 0 | 259 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, |
418 | 257 | test_message = 'Different Status Message than default' | 260 | status=STATUS_CODE[S_ON], |
405 | 258 | log_debug_calls = [ | ||
406 | 259 | call('({ip}) Changing status to {status} "{msg}"'.format(ip=pjlink.name, | ||
407 | 260 | status=STATUS_CODE[S_ON], | ||
408 | 261 | msg=test_message)), | ||
409 | 262 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, | ||
410 | 263 | code=STATUS_CODE[S_OK], | ||
419 | 264 | msg=test_message)), | 261 | msg=test_message)), |
438 | 265 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, | 262 | call('({ip}) status_connect: {code}: "{msg}"'.format(ip=pjlink.name, |
439 | 266 | code=STATUS_CODE[S_ON], | 263 | code=STATUS_CODE[S_OK], |
440 | 267 | msg=test_message)), | 264 | msg=test_message)), |
441 | 268 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | 265 | call('({ip}) projector_status: {code}: "{msg}"'.format(ip=pjlink.name, |
442 | 269 | code=STATUS_CODE[S_OK], | 266 | code=STATUS_CODE[S_ON], |
443 | 270 | msg=test_message))] | 267 | msg=test_message)), |
444 | 271 | 268 | call('({ip}) error_status: {code}: "{msg}"'.format(ip=pjlink.name, | |
445 | 272 | # WHEN: change_status called with projector ON status | 269 | code=STATUS_CODE[S_OK], |
446 | 273 | pjlink.change_status(status=S_ON, msg=test_message) | 270 | msg=test_message))] |
447 | 274 | 271 | ||
448 | 275 | # THEN: Proper settings should change and signals sent | 272 | # WHEN: change_status called with projector ON status |
449 | 276 | mock_log.debug.assert_has_calls(log_debug_calls) | 273 | pjlink.change_status(status=S_ON, msg=test_message) |
450 | 277 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, S_ON, test_message) | 274 | |
451 | 278 | assert pjlink.projector_status == S_ON, 'Projector status should be ON' | 275 | # THEN: Proper settings should change and signals sent |
452 | 279 | assert pjlink.status_connect == S_OK, 'Status connect should not have changed' | 276 | mock_log.debug.assert_has_calls(log_debug_calls) |
453 | 280 | 277 | mock_changeStatus.emit.assert_called_once_with(pjlink.ip, S_ON, test_message) | |
454 | 281 | @skip('Needs update to new setup') | 278 | assert pjlink.projector_status == S_ON, 'Projector status should be ON' |
455 | 282 | def test_projector_get_av_mute_status(self): | 279 | assert pjlink.status_connect == S_OK, 'Status connect should not have changed' |
456 | 280 | |||
457 | 281 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') | ||
458 | 282 | @patch.object(openlp.core.projectors.pjlink, 'log') | ||
459 | 283 | def test_projector_get_av_mute_status(self, mock_log, mock_send_command): | ||
460 | 283 | """ | 284 | """ |
461 | 284 | Test sending command to retrieve shutter/audio state | 285 | Test sending command to retrieve shutter/audio state |
462 | 285 | """ | 286 | """ |
481 | 286 | # GIVEN: Test object and mocks | 287 | # GIVEN: Test object |
482 | 287 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 288 | pjlink = self.pjlink |
483 | 288 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 289 | test_data = 'AVMT' |
484 | 289 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 290 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
485 | 290 | test_data = 'AVMT' | 291 | |
486 | 291 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 292 | # WHEN: get_av_mute_status is called |
487 | 292 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 293 | pjlink.get_av_mute_status() |
488 | 293 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 294 | |
489 | 294 | 295 | # THEN: log data and send_command should have been called | |
490 | 295 | # WHEN: get_av_mute_status is called | 296 | mock_log.debug.assert_has_calls(log_debug_calls) |
491 | 296 | pjlink.get_av_mute_status() | 297 | mock_send_command.assert_called_once_with(cmd=test_data, priority=False) |
492 | 297 | 298 | ||
493 | 298 | # THEN: log data and send_command should have been called | 299 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
494 | 299 | mock_log.debug.assert_has_calls(log_debug_calls) | 300 | @patch.object(openlp.core.projectors.pjlink, 'log') |
495 | 300 | mock_send_command.assert_called_once_with(cmd=test_data, priority=False) | 301 | def test_projector_get_available_inputs(self, mock_log, mock_send_command): |
478 | 301 | |||
479 | 302 | @skip('Needs update to new setup') | ||
480 | 303 | def test_projector_get_available_inputs(self): | ||
496 | 304 | """ | 302 | """ |
497 | 305 | Test sending command to retrieve avaliable inputs | 303 | Test sending command to retrieve avaliable inputs |
498 | 306 | """ | 304 | """ |
517 | 307 | # GIVEN: Test object and mocks | 305 | # GIVEN: Test object |
518 | 308 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 306 | pjlink = self.pjlink |
519 | 309 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 307 | test_data = 'INST' |
520 | 310 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 308 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
521 | 311 | test_data = 'INST' | 309 | |
522 | 312 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 310 | # WHEN: get_available_inputs is called |
523 | 313 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 311 | pjlink.get_available_inputs() |
524 | 314 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 312 | |
525 | 315 | 313 | # THEN: log data and send_command should have been called | |
526 | 316 | # WHEN: get_available_inputs is called | 314 | mock_log.debug.assert_has_calls(log_debug_calls) |
527 | 317 | pjlink.get_available_inputs() | 315 | mock_send_command.assert_called_once_with(cmd=test_data) |
528 | 318 | 316 | ||
529 | 319 | # THEN: log data and send_command should have been called | 317 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
530 | 320 | mock_log.debug.assert_has_calls(log_debug_calls) | 318 | @patch.object(openlp.core.projectors.pjlink, 'log') |
531 | 321 | mock_send_command.assert_called_once_with(cmd=test_data) | 319 | def test_projector_get_error_status(self, mock_log, mock_send_command): |
514 | 322 | |||
515 | 323 | @skip('Needs update to new setup') | ||
516 | 324 | def test_projector_get_error_status(self): | ||
532 | 325 | """ | 320 | """ |
533 | 326 | Test sending command to retrieve projector error status | 321 | Test sending command to retrieve projector error status |
534 | 327 | """ | 322 | """ |
553 | 328 | # GIVEN: Test object and mocks | 323 | # GIVEN: Test object |
554 | 329 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 324 | pjlink = self.pjlink |
555 | 330 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 325 | test_data = 'ERST' |
556 | 331 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 326 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
557 | 332 | test_data = 'ERST' | 327 | |
558 | 333 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 328 | # WHEN: get_error_status is called |
559 | 334 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 329 | pjlink.get_error_status() |
560 | 335 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 330 | |
561 | 336 | 331 | # THEN: log data and send_command should have been called | |
562 | 337 | # WHEN: get_error_status is called | 332 | mock_log.debug.assert_has_calls(log_debug_calls) |
563 | 338 | pjlink.get_error_status() | 333 | mock_send_command.assert_called_once_with(cmd=test_data) |
564 | 339 | 334 | ||
565 | 340 | # THEN: log data and send_command should have been called | 335 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
566 | 341 | mock_log.debug.assert_has_calls(log_debug_calls) | 336 | @patch.object(openlp.core.projectors.pjlink, 'log') |
567 | 342 | mock_send_command.assert_called_once_with(cmd=test_data) | 337 | def test_projector_get_input_source(self, mock_log, mock_send_command): |
550 | 343 | |||
551 | 344 | @skip('Needs update to new setup') | ||
552 | 345 | def test_projector_get_input_source(self): | ||
568 | 346 | """ | 338 | """ |
569 | 347 | Test sending command to retrieve current input | 339 | Test sending command to retrieve current input |
570 | 348 | """ | 340 | """ |
589 | 349 | # GIVEN: Test object and mocks | 341 | # GIVEN: Test object |
590 | 350 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 342 | pjlink = self.pjlink |
591 | 351 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 343 | test_data = 'INPT' |
592 | 352 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 344 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
593 | 353 | test_data = 'INPT' | 345 | |
594 | 354 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 346 | # WHEN: get_input_source is called |
595 | 355 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 347 | pjlink.get_input_source() |
596 | 356 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 348 | |
597 | 357 | 349 | # THEN: log data and send_command should have been called | |
598 | 358 | # WHEN: get_input_source is called | 350 | mock_log.debug.assert_has_calls(log_debug_calls) |
599 | 359 | pjlink.get_input_source() | 351 | mock_send_command.assert_called_once_with(cmd=test_data) |
600 | 360 | 352 | ||
601 | 361 | # THEN: log data and send_command should have been called | 353 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
602 | 362 | mock_log.debug.assert_has_calls(log_debug_calls) | 354 | @patch.object(openlp.core.projectors.pjlink, 'log') |
603 | 363 | mock_send_command.assert_called_once_with(cmd=test_data) | 355 | def test_projector_get_lamp_status(self, mock_log, mock_send_command): |
586 | 364 | |||
587 | 365 | @skip('Needs update to new setup') | ||
588 | 366 | def test_projector_get_lamp_status(self): | ||
604 | 367 | """ | 356 | """ |
605 | 368 | Test sending command to retrieve lamp(s) status | 357 | Test sending command to retrieve lamp(s) status |
606 | 369 | """ | 358 | """ |
625 | 370 | # GIVEN: Test object and mocks | 359 | # GIVEN: Test object |
626 | 371 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 360 | pjlink = self.pjlink |
627 | 372 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 361 | test_data = 'LAMP' |
628 | 373 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 362 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
629 | 374 | test_data = 'LAMP' | 363 | |
630 | 375 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 364 | # WHEN: get_input_source is called |
631 | 376 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 365 | pjlink.get_lamp_status() |
632 | 377 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 366 | |
633 | 378 | 367 | # THEN: log data and send_command should have been called | |
634 | 379 | # WHEN: get_input_source is called | 368 | mock_log.debug.assert_has_calls(log_debug_calls) |
635 | 380 | pjlink.get_lamp_status() | 369 | mock_send_command.assert_called_once_with(cmd=test_data) |
636 | 381 | 370 | ||
637 | 382 | # THEN: log data and send_command should have been called | 371 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
638 | 383 | mock_log.debug.assert_has_calls(log_debug_calls) | 372 | @patch.object(openlp.core.projectors.pjlink, 'log') |
639 | 384 | mock_send_command.assert_called_once_with(cmd=test_data) | 373 | def test_projector_get_manufacturer(self, mock_log, mock_send_command): |
622 | 385 | |||
623 | 386 | @skip('Needs update to new setup') | ||
624 | 387 | def test_projector_get_manufacturer(self): | ||
640 | 388 | """ | 374 | """ |
641 | 389 | Test sending command to retrieve manufacturer name | 375 | Test sending command to retrieve manufacturer name |
642 | 390 | """ | 376 | """ |
661 | 391 | # GIVEN: Test object and mocks | 377 | # GIVEN: Test object |
662 | 392 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 378 | pjlink = self.pjlink |
663 | 393 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 379 | test_data = 'INF1' |
664 | 394 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 380 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
665 | 395 | test_data = 'INF1' | 381 | |
666 | 396 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 382 | # WHEN: get_input_source is called |
667 | 397 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 383 | pjlink.get_manufacturer() |
668 | 398 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 384 | |
669 | 399 | 385 | # THEN: log data and send_command should have been called | |
670 | 400 | # WHEN: get_input_source is called | 386 | mock_log.debug.assert_has_calls(log_debug_calls) |
671 | 401 | pjlink.get_manufacturer() | 387 | mock_send_command.assert_called_once_with(cmd=test_data) |
672 | 402 | 388 | ||
673 | 403 | # THEN: log data and send_command should have been called | 389 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
674 | 404 | mock_log.debug.assert_has_calls(log_debug_calls) | 390 | @patch.object(openlp.core.projectors.pjlink, 'log') |
675 | 405 | mock_send_command.assert_called_once_with(cmd=test_data) | 391 | def test_projector_get_model(self, mock_log, mock_send_command): |
658 | 406 | |||
659 | 407 | @skip('Needs update to new setup') | ||
660 | 408 | def test_projector_get_model(self): | ||
676 | 409 | """ | 392 | """ |
677 | 410 | Test sending command to get model information | 393 | Test sending command to get model information |
678 | 411 | """ | 394 | """ |
697 | 412 | # GIVEN: Test object and mocks | 395 | # GIVEN: Test object |
698 | 413 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 396 | pjlink = self.pjlink |
699 | 414 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 397 | test_data = 'INF2' |
700 | 415 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 398 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
701 | 416 | test_data = 'INF2' | 399 | |
702 | 417 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 400 | # WHEN: get_input_source is called |
703 | 418 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 401 | pjlink.get_model() |
704 | 419 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 402 | |
705 | 420 | 403 | # THEN: log data and send_command should have been called | |
706 | 421 | # WHEN: get_input_source is called | 404 | mock_log.debug.assert_has_calls(log_debug_calls) |
707 | 422 | pjlink.get_model() | 405 | mock_send_command.assert_called_once_with(cmd=test_data) |
708 | 423 | 406 | ||
709 | 424 | # THEN: log data and send_command should have been called | 407 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
710 | 425 | mock_log.debug.assert_has_calls(log_debug_calls) | 408 | @patch.object(openlp.core.projectors.pjlink, 'log') |
711 | 426 | mock_send_command.assert_called_once_with(cmd=test_data) | 409 | def test_projector_get_name(self, mock_log, mock_send_command): |
694 | 427 | |||
695 | 428 | @skip('Needs update to new setup') | ||
696 | 429 | def test_projector_get_name(self): | ||
712 | 430 | """ | 410 | """ |
713 | 431 | Test sending command to get user-assigned name | 411 | Test sending command to get user-assigned name |
714 | 432 | """ | 412 | """ |
733 | 433 | # GIVEN: Test object and mocks | 413 | # GIVEN: Test object |
734 | 434 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 414 | pjlink = self.pjlink |
735 | 435 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 415 | test_data = 'NAME' |
736 | 436 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 416 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
737 | 437 | test_data = 'NAME' | 417 | |
738 | 438 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 418 | # WHEN: get_input_source is called |
739 | 439 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 419 | pjlink.get_name() |
740 | 440 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 420 | |
741 | 441 | 421 | # THEN: log data and send_command should have been called | |
742 | 442 | # WHEN: get_input_source is called | 422 | mock_log.debug.assert_has_calls(log_debug_calls) |
743 | 443 | pjlink.get_name() | 423 | mock_send_command.assert_called_once_with(cmd=test_data) |
744 | 444 | 424 | ||
745 | 445 | # THEN: log data and send_command should have been called | 425 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
746 | 446 | mock_log.debug.assert_has_calls(log_debug_calls) | 426 | @patch.object(openlp.core.projectors.pjlink, 'log') |
747 | 447 | mock_send_command.assert_called_once_with(cmd=test_data) | 427 | def test_projector_get_other_info(self, mock_log, mock_send_command): |
730 | 448 | |||
731 | 449 | @skip('Needs update to new setup') | ||
732 | 450 | def test_projector_get_other_info(self): | ||
748 | 451 | """ | 428 | """ |
749 | 452 | Test sending command to retrieve other information | 429 | Test sending command to retrieve other information |
750 | 453 | """ | 430 | """ |
769 | 454 | # GIVEN: Test object and mocks | 431 | # GIVEN: Test object |
770 | 455 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 432 | pjlink = self.pjlink |
771 | 456 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 433 | test_data = 'INFO' |
772 | 457 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 434 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
773 | 458 | test_data = 'INFO' | 435 | |
774 | 459 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 436 | # WHEN: get_input_source is called |
775 | 460 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 437 | pjlink.get_other_info() |
776 | 461 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 438 | |
777 | 462 | 439 | # THEN: log data and send_command should have been called | |
778 | 463 | # WHEN: get_input_source is called | 440 | mock_log.debug.assert_has_calls(log_debug_calls) |
779 | 464 | pjlink.get_other_info() | 441 | mock_send_command.assert_called_once_with(cmd=test_data) |
780 | 465 | 442 | ||
781 | 466 | # THEN: log data and send_command should have been called | 443 | @patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') |
782 | 467 | mock_log.debug.assert_has_calls(log_debug_calls) | 444 | @patch.object(openlp.core.projectors.pjlink, 'log') |
783 | 468 | mock_send_command.assert_called_once_with(cmd=test_data) | 445 | def test_projector_get_power_status(self, mock_log, mock_send_command): |
766 | 469 | |||
767 | 470 | @skip('Needs update to new setup') | ||
768 | 471 | def test_projector_get_power_status(self): | ||
784 | 472 | """ | 446 | """ |
785 | 473 | Test sending command to retrieve current power state | 447 | Test sending command to retrieve current power state |
786 | 474 | """ | 448 | """ |
804 | 475 | # GIVEN: Test object and mocks | 449 | # GIVEN: Test object |
805 | 476 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log, \ | 450 | pjlink = self.pjlink |
806 | 477 | patch.object(openlp.core.projectors.pjlink.PJLink, 'send_command') as mock_send_command: | 451 | test_data = 'POWR' |
807 | 478 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 452 | log_debug_calls = [call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] |
808 | 479 | test_data = 'POWR' | 453 | |
809 | 480 | log_debug_calls = [call('({ip}) reset_information() connect status is ' | 454 | # WHEN: get_input_source is called |
810 | 481 | '{state}'.format(ip=pjlink.name, state=STATUS_CODE[S_NOT_CONNECTED])), | 455 | pjlink.get_power_status() |
811 | 482 | call('({ip}) Sending {cmd} command'.format(ip=pjlink.name, cmd=test_data))] | 456 | |
812 | 483 | 457 | # THEN: log data and send_command should have been called | |
813 | 484 | # WHEN: get_input_source is called | 458 | mock_log.debug.assert_has_calls(log_debug_calls) |
814 | 485 | pjlink.get_power_status() | 459 | mock_send_command.assert_called_once_with(cmd=test_data, priority=False) |
815 | 486 | 460 | ||
799 | 487 | # THEN: log data and send_command should have been called | ||
800 | 488 | mock_log.debug.assert_has_calls(log_debug_calls) | ||
801 | 489 | mock_send_command.assert_called_once_with(cmd=test_data, priority=False) | ||
802 | 490 | |||
803 | 491 | @skip('Needs update to new setup') | ||
816 | 492 | def test_projector_get_status_invalid(self): | 461 | def test_projector_get_status_invalid(self): |
817 | 493 | """ | 462 | """ |
818 | 494 | Test to check returned information for error code | 463 | Test to check returned information for error code |
819 | 495 | """ | 464 | """ |
820 | 496 | # GIVEN: Test object | 465 | # GIVEN: Test object |
822 | 497 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 466 | pjlink = self.pjlink |
823 | 498 | test_string = 'NaN test' | 467 | test_string = 'NaN test' |
824 | 499 | 468 | ||
825 | 500 | # WHEN: get_status called | 469 | # WHEN: get_status called |
826 | @@ -504,14 +473,13 @@ | |||
827 | 504 | assert code == -1, 'Should have returned -1 as a bad status check' | 473 | assert code == -1, 'Should have returned -1 as a bad status check' |
828 | 505 | assert message is None, 'Invalid code type should have returned None for message' | 474 | assert message is None, 'Invalid code type should have returned None for message' |
829 | 506 | 475 | ||
830 | 507 | @skip('Needs update to new setup') | ||
831 | 508 | def test_projector_get_status_valid(self): | 476 | def test_projector_get_status_valid(self): |
832 | 509 | """ | 477 | """ |
833 | 510 | Test to check returned information for status codes | 478 | Test to check returned information for status codes |
834 | 511 | """ | 479 | """ |
835 | 512 | # GIVEN: Test object | 480 | # GIVEN: Test object |
836 | 513 | test_message = 'Not Connected' | 481 | test_message = 'Not Connected' |
838 | 514 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 482 | pjlink = self.pjlink |
839 | 515 | 483 | ||
840 | 516 | # WHEN: get_status called | 484 | # WHEN: get_status called |
841 | 517 | code, message = pjlink._get_status(status=S_NOT_CONNECTED) | 485 | code, message = pjlink._get_status(status=S_NOT_CONNECTED) |
842 | @@ -520,13 +488,12 @@ | |||
843 | 520 | assert code == 'S_NOT_CONNECTED', 'Code returned should have been the same code that was sent' | 488 | assert code == 'S_NOT_CONNECTED', 'Code returned should have been the same code that was sent' |
844 | 521 | assert message == test_message, 'Description of code should have been returned' | 489 | assert message == test_message, 'Description of code should have been returned' |
845 | 522 | 490 | ||
846 | 523 | @skip('Needs update to new setup') | ||
847 | 524 | def test_projector_get_status_unknown(self): | 491 | def test_projector_get_status_unknown(self): |
848 | 525 | """ | 492 | """ |
849 | 526 | Test to check returned information for unknown code | 493 | Test to check returned information for unknown code |
850 | 527 | """ | 494 | """ |
851 | 528 | # GIVEN: Test object | 495 | # GIVEN: Test object |
853 | 529 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) | 496 | pjlink = self.pjlink |
854 | 530 | 497 | ||
855 | 531 | # WHEN: get_status called | 498 | # WHEN: get_status called |
856 | 532 | code, message = pjlink._get_status(status=9999) | 499 | code, message = pjlink._get_status(status=9999) |
Linux tests passed!