Exemple #1
0
        @pytest.fixture()
        async def device(self):
            device = Device(
                chp.ProductResponder.from_product(Products.LCM2_A19_PLUS), chp.InfraredResponder()
            )

            async with device:
                device.assertAttrs(infrared=0)
                yield device

        async it "responds to infrared messages", device:
            await device.assertResponse(
                LightMessages.GetInfrared(), [LightMessages.StateInfrared(brightness=0)]
            )
            await device.assertResponse(
                LightMessages.SetInfrared(brightness=100),
                [LightMessages.StateInfrared(brightness=0)],
                infrared=100,
            )
            await device.assertResponse(
                LightMessages.GetInfrared(),
                [LightMessages.StateInfrared(brightness=100)],
                infrared=100,
            )

        async it "doesn't respond to infrared if the product doesn't have infrared":
            device = Device(
                chp.ProductResponder.from_product(Products.LCM2_A19), chp.InfraredResponder()
            )

            async with device:
Exemple #2
0
    def device(self):
        device = devices["ir"]
        assert device.cap.has_ir
        devices.store(device).assertAttrs(infrared=0)
        return device

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

    async it "responds to infrared messages", device, assertResponse:
        await assertResponse(
            LightMessages.GetInfrared(), [LightMessages.StateInfrared(brightness=0)]
        )
        await assertResponse(
            LightMessages.SetInfrared(brightness=100),
            [LightMessages.StateInfrared(brightness=0)],
            infrared=100,
        )
        await assertResponse(
            LightMessages.GetInfrared(),
            [LightMessages.StateInfrared(brightness=100)],
            infrared=100,
        )

    async it "doesn't respond to infrared if the product doesn't have infrared":
        device = devices["a19"]
        assert not device.cap.has_ir
        assert device.cap.product.family is Family.LCM2
        assert "infrared" not in device.attrs