Ejemplo n.º 1
0
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                DeviceMessages.SetPower(level=65535),
            ],
            ir: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                DeviceMessages.SetPower(level=65535),
            ],
        }

        await self.assertScript(sender, msg, expected=expected)

    async it "can send to negative capability", sender:

        msg = ForCapability(hev=LightMessages.GetHevCycle(), not_hev=LightMessages.GetLightPower())

        expected = {
            a19: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.GetLightPower(),
            ],
            clean: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.GetHevCycle(),
            ],
            ir: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
Ejemplo n.º 2
0
        return assertUnhandled

    async it "responds to label messages", device, assertResponse:
        await assertResponse(DeviceMessages.GetLabel(), [DeviceMessages.StateLabel(label="")])
        await assertResponse(
            DeviceMessages.SetLabel(label="sam"),
            [DeviceMessages.StateLabel(label="sam")],
            label="sam",
        )
        await assertResponse(
            DeviceMessages.GetLabel(), [DeviceMessages.StateLabel(label="sam")], label="sam"
        )

    async it "replies to light messages with a StateUnhandled packet", device, assertUnhandled:
        await assertUnhandled(LightMessages.GetColor())
        await assertUnhandled(LightMessages.GetLightPower())


describe "LightState":

    @pytest.fixture()
    def device(self):
        device = devices["a19"]
        devices.store(device).assertAttrs(label="", power=0, color=hp.Color(0, 0, 1, 3500))
        return device

    @pytest.fixture()
    def assertResponse(self, device, **attrs):
        return makeAssertResponse(device, **attrs)

    async it "responds to light power messages", device, assertResponse: