~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to tests/openlp_core/projectors/test_projector_pjlink_commands_01.py

  • Committer: Tomas Groth
  • Date: 2019-04-30 19:02:42 UTC
  • mfrom: (2829.2.32 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190430190242-6zwjk8724tyux70m
trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection                                      #
6
6
# --------------------------------------------------------------------------- #
7
 
# Copyright (c) 2008-2015 OpenLP Developers                                   #
 
7
# Copyright (c) 2008-2019 OpenLP Developers                                   #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it     #
10
10
# under the terms of the GNU General Public License as published by the Free  #
22
22
"""
23
23
Package to test the openlp.core.projectors.pjlink commands package.
24
24
"""
25
 
from unittest import TestCase
 
25
from unittest import TestCase, skip
26
26
from unittest.mock import call, patch
27
27
 
28
28
import openlp.core.projectors.pjlink
29
 
from openlp.core.projectors.constants import \
30
 
    PJLINK_ERST_DATA, \
31
 
    PJLINK_ERST_STATUS, \
32
 
    PJLINK_POWR_STATUS, \
33
 
    STATUS_CODE, \
34
 
    E_ERROR, \
35
 
    E_WARN, \
36
 
    S_OK, \
37
 
    S_ON, \
38
 
    S_NOT_CONNECTED, \
39
 
    S_STANDBY
 
29
from openlp.core.projectors.constants import E_ERROR, E_WARN, PJLINK_ERST_DATA, PJLINK_ERST_STATUS, \
 
30
    PJLINK_POWR_STATUS, S_NOT_CONNECTED, S_OK, S_ON, S_STANDBY, STATUS_CODE
40
31
from openlp.core.projectors.db import Projector
41
32
from openlp.core.projectors.pjlink import PJLink
42
 
 
43
33
from tests.resources.projector.data import TEST1_DATA
44
34
 
45
35
 
47
37
    """
48
38
    Tests for the PJLinkCommands class part 1
49
39
    """
 
40
    @skip('Needs update to new setup')
50
41
    def test_projector_process_inf1(self):
51
42
        """
52
43
        Test saving INF1 data (manufacturer)
63
54
        # THEN: Data should be saved
64
55
        assert pjlink.manufacturer == test_data, 'Test data should have been saved'
65
56
 
 
57
    @skip('Needs update to new setup')
66
58
    def test_projector_process_inf2(self):
67
59
        """
68
60
        Test saving INF2 data (model)
79
71
        # THEN: Data should be saved
80
72
        assert pjlink.model == test_data, 'Test data should have been saved'
81
73
 
 
74
    @skip('Needs update to new setup')
82
75
    def test_projector_process_info(self):
83
76
        """
84
77
        Test saving INFO data (other information)
95
88
        # THEN: Data should be saved
96
89
        assert pjlink.other_info == test_data, 'Test data should have been saved'
97
90
 
 
91
    @skip('Needs update to new setup')
98
92
    def test_projector_process_avmt_bad_data(self):
99
93
        """
100
94
        Test avmt bad data fail
113
107
            assert pjlink.mute is True, 'Audio should not have changed'
114
108
            assert mock_UpdateIcons.emit.called is False, 'Update icons should NOT have been called'
115
109
 
 
110
    @skip('Needs update to new setup')
116
111
    def test_projector_process_avmt_closed_muted(self):
117
112
        """
118
113
        Test avmt status shutter closed and mute off
131
126
            assert pjlink.mute is True, 'Audio should be muted'
132
127
            assert mock_UpdateIcons.emit.called is True, 'Update icons should have been called'
133
128
 
 
129
    @skip('Needs update to new setup')
134
130
    def test_projector_process_avmt_shutter_closed(self):
135
131
        """
136
132
        Test avmt status shutter closed and audio unchanged
149
145
            assert pjlink.mute is True, 'Audio should not have changed'
150
146
            assert mock_UpdateIcons.emit.called is True, 'Update icons should have been called'
151
147
 
 
148
    @skip('Needs update to new setup')
152
149
    def test_projector_process_avmt_audio_muted(self):
153
150
        """
154
151
        Test avmt status shutter unchanged and mute on
167
164
            assert pjlink.mute is True, 'Audio should be off'
168
165
            assert mock_UpdateIcons.emit.called is True, 'Update icons should have been called'
169
166
 
 
167
    @skip('Needs update to new setup')
170
168
    def test_projector_process_avmt_open_unmuted(self):
171
169
        """
172
170
        Test avmt status shutter open and mute off
185
183
            assert pjlink.mute is False, 'Audio should be on'
186
184
            assert mock_UpdateIcons.emit.called is True, 'Update icons should have been called'
187
185
 
 
186
    @skip('Needs update to new setup')
188
187
    def test_projector_process_clss_one(self):
189
188
        """
190
189
        Test class 1 sent from projector
198
197
        # THEN: Projector class should be set to 1
199
198
        assert pjlink.pjlink_class == '1', 'Projector should have set class=1'
200
199
 
 
200
    @skip('Needs update to new setup')
201
201
    def test_projector_process_clss_two(self):
202
202
        """
203
203
        Test class 2 sent from projector
211
211
        # THEN: Projector class should be set to 1
212
212
        assert pjlink.pjlink_class == '2', 'Projector should have set class=2'
213
213
 
 
214
    @skip('Needs update to new setup')
214
215
    def test_projector_process_clss_invalid_nan(self):
215
216
        """
216
217
        Test CLSS reply has no class number
232
233
            mock_log.error.assert_has_calls(log_error_calls)
233
234
            mock_log.debug.assert_has_calls(log_debug_calls)
234
235
 
 
236
    @skip('Needs update to new setup')
235
237
    def test_projector_process_clss_invalid_no_version(self):
236
238
        """
237
239
        Test CLSS reply has no class number
253
255
            mock_log.error.assert_has_calls(log_error_calls)
254
256
            mock_log.debug.assert_has_calls(log_debug_calls)
255
257
 
 
258
    @skip('Needs update to new setup')
256
259
    def test_projector_process_clss_nonstandard_reply_1(self):
257
260
        """
258
261
        Test CLSS request returns non-standard reply 1
266
269
        # THEN: Projector class should be set with proper value
267
270
        assert '1' == pjlink.pjlink_class, 'Non-standard class reply should have set class=1'
268
271
 
 
272
    @skip('Needs update to new setup')
269
273
    def test_projector_process_clss_nonstandard_reply_2(self):
270
274
        """
271
275
        Test CLSS request returns non-standard reply 2
279
283
        # THEN: Projector class should be set with proper value
280
284
        assert '2' == pjlink.pjlink_class, 'Non-standard class reply should have set class=2'
281
285
 
 
286
    @skip('Needs update to new setup')
282
287
    def test_projector_process_erst_all_ok(self):
283
288
        """
284
289
        Test to verify pjlink.projector_errors is set to None when no errors
294
299
        # THEN: PJLink instance errors should be None
295
300
        assert pjlink.projector_errors is None, 'projector_errors should have been set to None'
296
301
 
 
302
    @skip('Needs update to new setup')
297
303
    def test_projector_process_erst_data_invalid_length(self):
298
304
        """
299
305
        Test test_projector_process_erst_data_invalid_length
316
322
            mock_log.debug.assert_has_calls(log_debug_calls)
317
323
            mock_log.warning.assert_has_calls(log_warn_calls)
318
324
 
 
325
    @skip('Needs update to new setup')
319
326
    def test_projector_process_erst_data_invalid_nan(self):
320
327
        """
321
328
        Test test_projector_process_erst_data_invalid_nan
337
344
            mock_log.debug.assert_has_calls(log_debug_calls)
338
345
            mock_log.warning.assert_has_calls(log_warn_calls)
339
346
 
 
347
    @skip('Needs update to new setup')
340
348
    def test_projector_process_erst_all_warn(self):
341
349
        """
342
350
        Test test_projector_process_erst_all_warn
364
372
        # THEN: PJLink instance errors should match chk_value
365
373
        assert pjlink.projector_errors == chk_test, 'Projector errors should be all E_WARN'
366
374
 
 
375
    @skip('Needs update to new setup')
367
376
    def test_projector_process_erst_all_error(self):
368
377
        """
369
378
        Test test_projector_process_erst_all_error
391
400
        # THEN: PJLink instance errors should match chk_value
392
401
        assert pjlink.projector_errors == chk_test, 'Projector errors should be all E_ERROR'
393
402
 
 
403
    @skip('Needs update to new setup')
394
404
    def test_projector_process_erst_warn_cover_only(self):
395
405
        """
396
406
        Test test_projector_process_erst_warn_cover_only
416
426
        assert pjlink.projector_errors['Cover'] == E_WARN, '"Cover" should have E_WARN listed as error'
417
427
        assert chk_test == pjlink.projector_errors, 'projector_errors should match test errors'
418
428
 
 
429
    @skip('Needs update to new setup')
419
430
    def test_projector_process_inpt_valid(self):
420
431
        """
421
432
        Test input source status shows current input
436
447
            assert pjlink.source == '21', 'Input source should be set to "21"'
437
448
            mock_log.debug.assert_has_calls(log_debug_calls)
438
449
 
 
450
    @skip('Needs update to new setup')
439
451
    def test_projector_process_input_not_in_list(self):
440
452
        """
441
453
        Test setting input outside of available inputs
444
456
        """
445
457
        pass
446
458
 
 
459
    @skip('Needs update to new setup')
447
460
    def test_projector_process_input_not_in_default(self):
448
461
        """
449
462
        Test setting input with no sources available
451
464
        """
452
465
        pass
453
466
 
 
467
    @skip('Needs update to new setup')
454
468
    def test_projector_process_input_invalid(self):
455
469
        """
456
470
        Test setting input with an invalid value
458
472
        TODO: Future test
459
473
        """
460
474
 
 
475
    @skip('Needs update to new setup')
461
476
    def test_projector_process_inst_class_1(self):
462
477
        """
463
478
        Test saving video source available information
464
479
        """
 
480
 
465
481
        # GIVEN: Test object
466
482
        with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
467
483
            pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
468
484
            pjlink.source_available = []
469
 
            log_debug_calls = [call('({ip}) Setting projector sources_available to '
 
485
            log_debug_calls = [call('({ip}) reset_information() connect status is '
 
486
                                    'S_NOT_CONNECTED'.format(ip=pjlink.name)),
 
487
                               call('({ip}) Setting projector source_available to '
470
488
                                    '"[\'11\', \'12\', \'21\', \'22\', \'31\', \'32\']"'.format(ip=pjlink.name))]
 
489
 
471
490
            chk_data = '21 12 11 22 32 31'  # Although they should already be sorted, use unsorted to verify method
472
491
            chk_test = ['11', '12', '21', '22', '31', '32']
473
492
 
478
497
            assert pjlink.source_available == chk_test, "Sources should have been sorted and saved"
479
498
            mock_log.debug.assert_has_calls(log_debug_calls)
480
499
 
 
500
    @skip('Needs update to new setup')
481
501
    def test_projector_process_lamp_invalid(self):
482
502
        """
483
503
        Test status multiple lamp on/off and hours
500
520
            assert 11111 == pjlink.lamp[1]['Hours'], 'Lamp 2 hours should have been left at 11111'
501
521
            mock_log.warning.assert_has_calls(log_data)
502
522
 
 
523
    @skip('Needs update to new setup')
503
524
    def test_projector_process_lamp_multiple(self):
504
525
        """
505
526
        Test status multiple lamp on/off and hours
520
541
        assert pjlink.lamp[2]['On'] is True, 'Lamp 3 power status should have been set to TRUE'
521
542
        assert 33333 == pjlink.lamp[2]['Hours'], 'Lamp 3 hours should have been set to 33333'
522
543
 
 
544
    @skip('Needs update to new setup')
523
545
    def test_projector_process_lamp_single(self):
524
546
        """
525
547
        Test status lamp on/off and hours
537
559
        assert pjlink.lamp[0]['On'] is True, 'Lamp power status should have been set to TRUE'
538
560
        assert 22222 == pjlink.lamp[0]['Hours'], 'Lamp hours should have been set to 22222'
539
561
 
 
562
    @skip('Needs update to new setup')
540
563
    def test_projector_process_lamp_single_hours_only(self):
541
564
        """
542
565
        Test process lamp with 1 lamp reply hours only and no on/off status
553
576
        assert 45 == pjlink.lamp[0]['Hours'], 'Lamp hours should have equalled 45'
554
577
        assert pjlink.lamp[0]['On'] is None, 'Lamp power should be "None"'
555
578
 
 
579
    @skip('Needs update to new setup')
556
580
    def test_projector_process_name(self):
557
581
        """
558
582
        Test saving NAME data from projector
571
595
            assert pjlink.pjlink_name == chk_data, 'Name test data should have been saved'
572
596
            mock_log.debug.assert_has_calls(log_debug_calls)
573
597
 
 
598
    @skip('Needs update to new setup')
574
599
    def test_projector_process_powr_on(self):
575
600
        """
576
601
        Test status power to ON
592
617
            mock_send_command.assert_called_once_with('INST')
593
618
            mock_change_status.assert_called_once_with(S_ON)
594
619
 
 
620
    @skip('Needs update to new setup')
595
621
    def test_projector_process_powr_invalid(self):
596
622
        """
597
623
        Test process_powr invalid call
611
637
 
612
638
            # THEN: Power should be set to ON
613
639
            assert pjlink.power == S_STANDBY, 'Power should not have changed'
614
 
            assert mock_UpdateIcons.emit.called is False, 'projectorUpdateIcons() should not have been called'
615
 
            mock_change_status.called is False, 'change_status() should not have been called'
616
 
            mock_send_command.called is False, 'send_command() should not have been called'
 
640
            mock_UpdateIcons.emit.assert_not_called()
 
641
            mock_change_status.assert_not_called()
 
642
            mock_send_command.assert_not_called()
617
643
            mock_log.warning.assert_has_calls(log_warn_calls)
618
644
 
 
645
    @skip('Needs update to new setup')
619
646
    def test_projector_process_powr_off(self):
620
647
        """
621
648
        Test status power to STANDBY
633
660
 
634
661
            # THEN: Power should be set to ON
635
662
            assert pjlink.power == S_STANDBY, 'Power should have changed to S_STANDBY'
636
 
            assert mock_UpdateIcons.emit.called is True, 'projectorUpdateIcons should have been called'
637
 
            mock_change_status.called is True, 'change_status should have been called'
638
 
            mock_send_command.called is False, 'send_command should not have been called'
 
663
            mock_UpdateIcons.emit.assert_called_with()
 
664
            mock_change_status.assert_called_with(313)
 
665
            mock_send_command.assert_not_called()
639
666
 
 
667
    @skip('Needs update to new setup')
640
668
    def test_projector_process_rfil_save(self):
641
669
        """
642
670
        Test saving filter type
653
681
        # THEN: Filter model number should be saved
654
682
        assert pjlink.model_filter == filter_model, 'Filter type should have been saved'
655
683
 
 
684
    @skip('Needs update to new setup')
656
685
    def test_projector_process_rfil_nosave(self):
657
686
        """
658
687
        Test saving filter type previously saved
674
703
            assert pjlink.model_filter != filter_model, 'Filter type should NOT have been saved'
675
704
            mock_log.warning.assert_has_calls(log_warn_calls)
676
705
 
 
706
    @skip('Needs update to new setup')
677
707
    def test_projector_process_rlmp_save(self):
678
708
        """
679
709
        Test saving lamp type
690
720
        # THEN: Filter model number should be saved
691
721
        assert pjlink.model_lamp == lamp_model, 'Lamp type should have been saved'
692
722
 
 
723
    @skip('Needs update to new setup')
693
724
    def test_projector_process_rlmp_nosave(self):
694
725
        """
695
726
        Test saving lamp type previously saved
711
742
            assert pjlink.model_lamp != lamp_model, 'Lamp type should NOT have been saved'
712
743
            mock_log.warning.assert_has_calls(log_warn_calls)
713
744
 
 
745
    @skip('Needs update to new setup')
714
746
    def test_projector_process_snum_set(self):
715
747
        """
716
748
        Test saving serial number from projector
731
763
            assert pjlink.serial_no == test_number, 'Projector serial number should have been set'
732
764
            mock_log.debug.assert_has_calls(log_debug_calls)
733
765
 
 
766
    @skip('Needs update to new setup')
734
767
    def test_projector_process_snum_different(self):
735
768
        """
736
769
        Test projector serial number different than saved serial number
753
786
            assert pjlink.serial_no != test_number, 'Projector serial number should NOT have been set'
754
787
            mock_log.warning.assert_has_calls(log_warn_calls)
755
788
 
 
789
    @skip('Needs update to new setup')
756
790
    def test_projector_process_sver(self):
757
791
        """
758
792
        Test invalid software version information - too long
773
807
            assert pjlink.sw_version == test_data, 'Software version should have been updated'
774
808
            mock_log.debug.assert_has_calls(log_debug_calls)
775
809
 
 
810
    @skip('Needs update to new setup')
776
811
    def test_projector_process_sver_changed(self):
777
812
        """
778
813
        Test invalid software version information - Received different than saved
796
831
            assert pjlink.sw_version == test_data_new, 'Software version should have changed'
797
832
            mock_log.warning.assert_has_calls(log_warn_calls)
798
833
 
 
834
    @skip('Needs update to new setup')
799
835
    def test_projector_process_sver_invalid(self):
800
836
        """
801
837
        Test invalid software version information - too long