def test_signal_command(self, request, get_environment, monkeypatch,
                            get_bus):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires initially when the sources are set up
        """
        recieved_signals = []

        # Append tuple to recieved_signals
        def catchall_handler(*args, **kwargs):  # pragma: no cover
            """
            Catch all handler. Catch and print information about all signals.
            """
            # unpack tuple to variables ( Taken from Tasker )
            for i, v in enumerate(args):
                if isinstance(v, tuple):
                    tuple_args = len(v)
                    if tuple_args == 1:
                        msg = v
                    elif tuple_args == 2:
                        msg, scarlett_sound = v
                    elif tuple_args == 3:
                        msg, scarlett_sound, command = v

            # Add value to list so we can assert later
            recieved_signals.append(v)

        self.setup_tasker(monkeypatch, get_bus)

        self.log.info("setting callback")

        self.tasker.prepare(catchall_handler, catchall_handler,
                            catchall_handler)
        # Sleep to give time for connection to be established
        # time.sleep(1)
        self.tasker.configure()

        run_emitter_signal(request, get_environment, sig_name="cmd-rec")

        self.log.info(
            "waiting for initial callback with"
            "('  ScarlettListener caught a command match', 'pi-response', 'what time is it')"
        )
        self.run_mainloop(timeout=3)

        assert recieved_signals[0] == (
            "  ScarlettListener caught a command match",
            "pi-response",
            "what time is it",
        )
    def test_signal_ready(
        self, request, service_on_outside, get_environment, monkeypatch, get_bus
    ):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires initially when the sources are set up
        """
        recieved_signals = []

        # Append tuple to recieved_signals
        # FIXME:
        # /home/pi/dev/bossjones-github/scarlett_os/tests/integration/test_integration_tasker.py in catchall_handler(*args=(':1.0', '/org/scarlett/Listener', 'org.scarlett.Listener', 'SttFailedSignal', ('  ScarlettListener hit Max STT failures', 'pi-response2')), **kwargs={})
        def catchall_handler(*args, **kwargs):  # pragma: no cover
            """
            Catch all handler. Catch and print information about all signals.
            """
            # unpack tuple to variables ( Taken from Tasker )
            for i, v in enumerate(args):
                if isinstance(v, tuple):
                    tuple_args = len(v)
                    if tuple_args == 1:
                        msg = v
                    elif tuple_args == 2:
                        msg, scarlett_sound = v
                    elif tuple_args == 3:
                        msg, scarlett_sound, command = v

            # Add value to list so we can assert later
            recieved_signals.append(v)

        self.setup_tasker(monkeypatch, get_bus)

        self.log.info("setting callback")

        self.tasker.prepare(catchall_handler, catchall_handler, catchall_handler)
        # Sleep to give time for connection to be established
        time.sleep(2)
        self.tasker.configure()

        run_emitter_signal(request, get_environment, sig_name="ready")

        self.log.info(
            "waiting for initial callback with"
            "('  ScarlettListener is ready', 'pi-listening')"
        )
        self.run_mainloop(timeout=3)

        assert recieved_signals[0] == ("  ScarlettListener is ready", "pi-listening")
    def test_signal_command(self, request, get_environment, monkeypatch, get_bus):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires initially when the sources are set up
        """
        recieved_signals = []

        # Append tuple to recieved_signals
        def catchall_handler(*args, **kwargs):  # pragma: no cover
            """
            Catch all handler. Catch and print information about all signals.
            """
            # unpack tuple to variables ( Taken from Tasker )
            for i, v in enumerate(args):
                if isinstance(v, tuple):
                    tuple_args = len(v)
                    if tuple_args == 1:
                        msg = v
                    elif tuple_args == 2:
                        msg, scarlett_sound = v
                    elif tuple_args == 3:
                        msg, scarlett_sound, command = v

            # Add value to list so we can assert later
            recieved_signals.append(v)

        self.setup_tasker(monkeypatch, get_bus)

        self.log.info("setting callback")

        self.tasker.prepare(catchall_handler, catchall_handler, catchall_handler)
        # Sleep to give time for connection to be established
        # time.sleep(1)
        self.tasker.configure()

        run_emitter_signal(request, get_environment, sig_name="cmd-rec")

        self.log.info(
            "waiting for initial callback with"
            "('  ScarlettListener caught a command match', 'pi-response', 'what time is it')"
        )
        self.run_mainloop(timeout=3)

        assert recieved_signals[0] == (
            "  ScarlettListener caught a command match",
            "pi-response",
            "what time is it",
        )
    def test_signal_ready(self, request, service_on_outside, get_environment,
                          monkeypatch, get_bus):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires initially when the sources are set up
        """
        recieved_signals = []

        # Append tuple to recieved_signals
        # FIXME:
        # /home/pi/dev/bossjones-github/scarlett_os/tests/integration/test_integration_tasker.py in catchall_handler(*args=(':1.0', '/org/scarlett/Listener', 'org.scarlett.Listener', 'SttFailedSignal', ('  ScarlettListener hit Max STT failures', 'pi-response2')), **kwargs={})
        def catchall_handler(*args, **kwargs):  # pragma: no cover
            """
            Catch all handler. Catch and print information about all signals.
            """
            # unpack tuple to variables ( Taken from Tasker )
            for i, v in enumerate(args):
                if isinstance(v, tuple):
                    tuple_args = len(v)
                    if tuple_args == 1:
                        msg = v
                    elif tuple_args == 2:
                        msg, scarlett_sound = v
                    elif tuple_args == 3:
                        msg, scarlett_sound, command = v

            # Add value to list so we can assert later
            recieved_signals.append(v)

        self.setup_tasker(monkeypatch, get_bus)

        self.log.info("setting callback")

        self.tasker.prepare(catchall_handler, catchall_handler,
                            catchall_handler)
        # Sleep to give time for connection to be established
        time.sleep(2)
        self.tasker.configure()

        run_emitter_signal(request, get_environment, sig_name="ready")

        self.log.info("waiting for initial callback with"
                      "('  ScarlettListener is ready', 'pi-listening')")
        self.run_mainloop(timeout=3)

        assert recieved_signals[0] == ("  ScarlettListener is ready",
                                       "pi-listening")
    def test_real_signal_kw_rec(self, request, get_environment, monkeypatch,
                                get_bus):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires initially when the sources are set up
        """

        recieved_signals = []

        monkeypatch.setattr(tasker.player.ScarlettPlayer, "DEFAULT_SINK",
                            "fakesink")

        # Append tuple to recieved_signals
        def catchall_handler(*args, **kwargs):  # pragma: no cover
            """
            Catch all handler. Catch and print information about all signals.
            """
            # unpack tuple to variables ( Taken from Tasker )
            for i, v in enumerate(args):
                if isinstance(v, tuple):
                    tuple_args = len(v)
                    if tuple_args == 1:
                        msg = v
                    elif tuple_args == 2:
                        msg, scarlett_sound = v
                    elif tuple_args == 3:
                        msg, scarlett_sound, command = v

            # Add value to list so we can assert later
            recieved_signals.append(v)

        self.setup_tasker(monkeypatch, get_bus)

        self.log.info("setting callback")

        self.tasker.prepare(on_signal_recieved, on_signal_recieved,
                            on_signal_recieved)
        self.tasker.configure()

        run_emitter_signal(request, get_environment, sig_name="kw-rec")

        self.log.info(
            "waiting for initial callback with"
            "('  ScarlettListener caught a keyword match', 'pi-listening')")
        self.run_mainloop(timeout=3)
    def test_real_signal_kw_rec(self, request, get_environment, monkeypatch, get_bus):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires initially when the sources are set up
        """

        recieved_signals = []

        monkeypatch.setattr(tasker.player.ScarlettPlayer, "DEFAULT_SINK", "fakesink")

        # Append tuple to recieved_signals
        def catchall_handler(*args, **kwargs):  # pragma: no cover
            """
            Catch all handler. Catch and print information about all signals.
            """
            # unpack tuple to variables ( Taken from Tasker )
            for i, v in enumerate(args):
                if isinstance(v, tuple):
                    tuple_args = len(v)
                    if tuple_args == 1:
                        msg = v
                    elif tuple_args == 2:
                        msg, scarlett_sound = v
                    elif tuple_args == 3:
                        msg, scarlett_sound, command = v

            # Add value to list so we can assert later
            recieved_signals.append(v)

        self.setup_tasker(monkeypatch, get_bus)

        self.log.info("setting callback")

        self.tasker.prepare(on_signal_recieved, on_signal_recieved, on_signal_recieved)
        self.tasker.configure()

        run_emitter_signal(request, get_environment, sig_name="kw-rec")

        self.log.info(
            "waiting for initial callback with"
            "('  ScarlettListener caught a keyword match', 'pi-listening')"
        )
        self.run_mainloop(timeout=3)