Ejemplo n.º 1
0
 async def restart_session(self):
     if self.last_final_future is None or self.last_final_future.done():
         raise PhotonsAppError(
             "The IO does not have a valid final future to restart the session from"
         )
     await self.shutting_down(Events.SHUTTING_DOWN(self.device))
     await self.start_session(self.last_final_future, self.parent_ts)
     await self.power_on(Events.POWER_ON(self.device))
Ejemplo n.º 2
0
                    record.pop()
                yield device

        async it "does nothing if the device is offline", device, sent, record, got_event:
            io = device.io["TESTIO"]
            addr = ("memory", device.serial)

            pkt = make_packet(DeviceMessages.GetLabel, source=3, sequence=3, target=device.serial)

            async with device.offline():
                io.received(pkt.pack().tobytes(), True, addr)

            assert record == [
                Events.SHUTTING_DOWN(device),
                Events.POWER_OFF(device),
                Events.POWER_ON(device),
            ]
            record.clear()

            io.received(pkt.pack().tobytes(), True, addr)

            while len(record) != 3:
                await sent
                sent.reset()

            assert record == [
                Events.INCOMING(device, io, pkt=pkt, addr=addr),
                ("send", ("Acknowledgement", 3, 3, device.serial, "{}"), True, addr, "GetLabel"),
                Events.IGNORED(device, io, pkt=pkt, addr=addr),
            ]
            record.clear()