示例#1
0
                    "instanceid": mock.ANY,
                },
            }

            serials = [light1.serial, light2.serial, striplcm1.serial]
            with process_outgoing_light1, process_outgoing_striplcm1, process_request_light1, process_request_striplcm1:
                got = await self.gather(sender, serials, "firmware_effects")
            expected = {
                light1.serial: (True, {"firmware_effects": l1}),
                light2.serial: (True, {"firmware_effects": Skip}),
                striplcm1.serial: (True, {"firmware_effects": slcm1}),
            }
            assert got == expected

            expected = {
                light1: [
                    DeviceMessages.GetHostFirmware(),
                    DeviceMessages.GetVersion(),
                    TileMessages.GetTileEffect(),
                ],
                light2: [DeviceMessages.GetHostFirmware(), DeviceMessages.GetVersion()],
                striplcm1: [
                    DeviceMessages.GetHostFirmware(),
                    DeviceMessages.GetVersion(),
                    MultiZoneMessages.GetMultiZoneEffect(),
                ],
            }

            for device, e in expected.items():
                devices.store(device).assertIncoming(*e)
示例#2
0
    describe "MatrixResponder":

        @pytest.fixture
        async def device(self):
            device = Device(
                chp.ProductResponder.from_product(Products.LCM3_TILE), chp.MatrixResponder()
            )

            async with device:
                device.assertAttrs(matrix_effect=TileEffectType.OFF)
                yield device

        async it "responds to tile effect messages", device:
            await device.assertResponse(
                TileMessages.GetTileEffect(),
                [
                    TileMessages.StateTileEffect.empty_normalise(
                        type=TileEffectType.OFF, palette_count=0, parameters={}
                    )
                ],
            )
            await device.assertResponse(
                TileMessages.SetTileEffect(
                    type=TileEffectType.FLAME, palette_count=1, palette=[chp.Color(1, 0, 1, 3500)]
                ),
                [
                    TileMessages.StateTileEffect.empty_normalise(
                        type=TileEffectType.OFF, palette_count=0, parameters={}, palette=[]
                    )
                ],
示例#3
0
 def messages(self):
     if self.is_multizone:
         return [MultiZoneMessages.GetMultiZoneEffect()]
     elif self.is_matrix:
         return [TileMessages.GetTileEffect()]
     return Skip
示例#4
0
        await assertResponse(
            TileMessages.SetUserPosition(tile_index=2, user_x=4, user_y=5),
            [],
        )
        assert device.attrs.chain[2].user_x == 4
        assert device.attrs.chain[2].user_y == 5

        # And can be out of range
        await assertResponse(
            TileMessages.SetUserPosition(tile_index=20, user_x=3, user_y=4),
            [],
        )

    async it "responds to tile effect messages", device, assertResponse:
        await assertResponse(
            TileMessages.GetTileEffect(),
            [
                TileMessages.StateTileEffect.create(
                    type=TileEffectType.OFF, speed=0.005, palette_count=0, parameters={}
                )
            ],
        )
        await assertResponse(
            TileMessages.SetTileEffect(
                type=TileEffectType.FLAME,
                palette_count=1,
                palette=[hp.Color(1, 0, 1, 3500)],
            ),
            [
                TileMessages.StateTileEffect.create(
                    type=TileEffectType.OFF, speed=0.005, palette_count=0, parameters={}, palette=[]