Пример #1
0
    def test_assumed_state_should_be_true_if_command_state_is_none(self):
        """Test with state value."""
        # args: hass, device_name, friendly_name, command_on, command_off,
        #       command_state, value_template
        init_args = [
            self.hass,
            "test_device_name",
            "Test friendly name!",
            "echo 'on command'",
            "echo 'off command'",
            None,
            None,
        ]

        no_state_device = command_line.CommandSwitch(*init_args)
        assert no_state_device.assumed_state

        # Set state command
        init_args[-2] = "cat {}"

        state_device = command_line.CommandSwitch(*init_args)
        assert not state_device.assumed_state
Пример #2
0
    def test_entity_id_set_correctly(self):
        """Test that entity_id is set correctly from object_id."""
        init_args = [
            self.hass,
            "test_device_name",
            "Test friendly name!",
            "echo 'on command'",
            "echo 'off command'",
            False,
            None,
        ]

        test_switch = command_line.CommandSwitch(*init_args)
        assert test_switch.entity_id == "switch.test_device_name"
        assert test_switch.name == "Test friendly name!"