Beispiel #1
0
    def test_cli_disconnect_encrypt(self):

        start_device(
            "DisconnectEncryptMock",
            "strip",
            "testkey",
            None,
            None,
            "Disconnect",
        )
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(
            cli.cli,
            [
                "--device_id",
                "DisconnectEncryptMock",
                "--api_key",
                "testkey",
                "-l",
                "INFO",
                "--wait",
                "3",
                "listen",
            ],
        )

        print(result.output)

        assert "removed" in result.output
        assert "added" in result.output
        assert "sending 'available'" in result.output.partition("removed")[2]

        stop_device()
Beispiel #2
0
    def test_cli_reconnect_strip(self):

        start_device("ReconnectStripMock", "strip", None, None, None,
                     "Reconnect")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(
            cli.cli,
            [
                "--device_id",
                "ReconnectStripMock",
                "-l",
                "DEBUG",
                "--wait",
                "2",
                "listen",
            ],
        )

        print(result.output)

        assert "still active!" in result.output
        assert "added again" in result.output

        stop_device()
Beispiel #3
0
    def test_cli_off(self):

        start_device("PlugOffMock", "plug")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(cli.cli, ["--device_id", "PlugOffMock", "off"])

        print(result.output)

        assert "info: State: OFF" in result.output

        stop_device()
Beispiel #4
0
    def test_cli_on_strip(self):

        start_device("StripOnMock", "strip")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(cli.cli, ["--device_id", "StripOnMock", "on"])

        print(result.output)

        assert "info: State: ON" in result.output

        stop_device()
Beispiel #5
0
    def test_cli_discover(self):

        start_device("DiscoverMock", "plug")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(cli.cli, ["discover"])

        print(result.output)

        assert ("Attempting to discover Sonoff LAN Mode devices on the local "
                "network" in result.output)
        assert "DiscoverMock" in result.output

        stop_device()
Beispiel #6
0
    def test_cli_on_strip_encrypt(self):

        start_device("StripEncryptMock", "strip", "testkey")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(
            cli.cli,
            [
                "--device_id",
                "StripEncryptMock",
                "--api_key",
                "testkey",
                "-l",
                "DEBUG",
                "on",
            ],
        )

        print(result.output)

        assert "info: State: ON" in result.output

        stop_device()