Esempio n. 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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 5
0
    def test_cli_wrong_key(self):

        start_device("PlugEncryptMock3", "plug", "testkey")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(
            cli.cli,
            ["--device_id", "PlugEncryptMock3", "--api_key", "bad", "state"],
        )

        print(result.output)

        assert "Probably wrong API key" in result.output
Esempio n. 6
0
    def test_cli_no_key(self):

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

        print(result.output)

        assert "Missing api_key for encrypted device" in result.output
Esempio n. 7
0
    def test_cli_on_encrypt(self):

        start_device("PlugEncryptMock", "plug", "testkey")
        """Test the CLI."""
        runner = CliRunner()
        result = runner.invoke(
            cli.cli,
            ["--device_id", "PlugEncryptMock", "--api_key", "testkey", "on"],
        )

        print(result.output)

        assert "info: State: ON" in result.output
Esempio n. 8
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()
Esempio n. 9
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()