def test_projector_reset_information(self):
        """
        Test reset_information() resets all information and stops timers
        """
        # GIVEN: Test object
        with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log:
            pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
            log_debug_calls = [call('({ip}): Calling poll_timer.stop()'.format(ip=pjlink.name)),
                               call('({ip}): Calling socket_timer.stop()'.format(ip=pjlink.name))]
            # timer and socket_timer not available until instantiation, so mock here
            with patch.object(pjlink, 'socket_timer') as mock_socket_timer, \
                    patch.object(pjlink, 'poll_timer') as mock_timer:

                pjlink.power = S_ON
                pjlink.pjlink_name = 'OPENLPTEST'
                pjlink.manufacturer = 'PJLINK'
                pjlink.model = '1'
                pjlink.shutter = True
                pjlink.mute = True
                pjlink.lamp = True
                pjlink.fan = True
                pjlink.source_available = True
                pjlink.other_info = 'ANOTHER TEST'
                pjlink.send_queue = True
                pjlink.send_busy = True

                # WHEN: reset_information() is called
                pjlink.reset_information()

                # THEN: All information should be reset and timers stopped
                assert pjlink.power == S_OFF, 'Projector power should be OFF'
                assert pjlink.pjlink_name is None, 'Projector pjlink_name should be None'
                assert pjlink.manufacturer is None, 'Projector manufacturer should be None'
                assert pjlink.model is None, 'Projector model should be None'
                assert pjlink.shutter is None, 'Projector shutter should be None'
                assert pjlink.mute is None, 'Projector shuttter should be None'
                assert pjlink.lamp is None, 'Projector lamp should be None'
                assert pjlink.fan is None, 'Projector fan should be None'
                assert pjlink.source_available is None, 'Projector source_available should be None'
                assert pjlink.source is None, 'Projector source should be None'
                assert pjlink.other_info is None, 'Projector other_info should be None'
                assert pjlink.send_queue == [], 'Projector send_queue should be an empty list'
                assert pjlink.send_busy is False, 'Projector send_busy should be False'
                assert mock_timer.stop.called is True, 'Projector timer.stop()  should have been called'
                assert mock_socket_timer.stop.called is True, 'Projector socket_timer.stop() should have been called'
                mock_log.debug.assert_has_calls(log_debug_calls)
    def test_local_send_command_no_data(self, mock_log):
        """
        Test _send_command with no data to send
        """
        # GIVEN: Test object
        log_debug_calls = [
            call(
                'PJlink(projector="< Projector(id="None", ip="111.111.111.111", port="1111", '
                'mac_adx="11:11:11:11:11:11", pin="1111", name="___TEST_ONE___", '
                'location="location one", notes="notes one", pjlink_name="None", '
                'pjlink_class="None", manufacturer="None", model="None", '
                'serial_no="Serial Number 1", other="None", sources="None", source_list="[]", '
                'model_filter="Filter type 1", model_lamp="Lamp type 1", '
                'sw_version="Version 1") >", args="()" kwargs="{\'no_poll\': True}")'
            ),
            call('PJlinkCommands(args=() kwargs={})'),
            call(
                '(___TEST_ONE___) reset_information() connect status is S_NOT_CONNECTED'
            ),
            call(
                '(___TEST_ONE___) _send_command(): Nothing to send - returning'
            )
        ]

        pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
        pjlink.send_queue = []
        pjlink.priority_queue = []

        # WHEN: _send_command called with no data and queue's emtpy
        # Patch here since pjlink does not have socket_timer until after instantiation
        with patch.object(pjlink, 'socket_timer') as mock_timer:
            pjlink._send_command(data=None, utf8=False)

            # THEN:
            mock_log.debug.assert_has_calls(log_debug_calls)
            assert mock_timer.called is False
    def test_send_command_no_data(self, mock_log, mock_send_command,
                                  mock_reset, mock_state):
        """
        Test _send_command with no data to send
        """
        # GIVEN: Test object
        log_warning_calls = [
            call('({ip}) send_command(): Not connected - returning'.format(
                ip=TEST1_DATA['name']))
        ]

        log_debug_calls = [
            call(
                'PJlink(projector="< Projector(id="None", ip="111.111.111.111", port="1111", '
                'mac_adx="11:11:11:11:11:11", pin="1111", name="___TEST_ONE___", '
                'location="location one", notes="notes one", pjlink_name="None", '
                'pjlink_class="None", manufacturer="None", model="None", '
                'serial_no="Serial Number 1", other="None", sources="None", source_list="[]", '
                'model_filter="Filter type 1", model_lamp="Lamp type 1", '
                'sw_version="Version 1") >", args="()" kwargs="{\'no_poll\': True}")'
            ),
            call('PJlinkCommands(args=() kwargs={})')
        ]
        mock_state.return_value = S_NOT_CONNECTED
        pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True)
        pjlink.send_queue = []
        pjlink.priority_queue = []

        # WHEN: _send_command called with no data and queue's empty
        pjlink.send_command(cmd='DONTCARE')

        # THEN:
        mock_log.debug.assert_has_calls(log_debug_calls)
        mock_log.warning.assert_has_calls(log_warning_calls)
        assert mock_reset.called is True
        assert mock_reset.called is True