def test_activate_updates(self, port): self.l.port = port async def child(): await self.l.activate_updates() kernel.run(child)
def test_play_sound(self, port, sound): self.l.port = port async def child(): await self.l.play_sound(sound) kernel.run(child) self.l.send_message.ask_called_once() args, kwargs = self.l.send_message.call_args assert args[1] == self.write.get_bytes(port, 1, sound.value)
def test_set_brightness(self, port, brightness): self.l.port = port async def child(): await self.l.set_brightness(brightness) kernel.run(child) self.l.send_message.ask_called_once() args, kwargs = self.l.send_message.call_args assert args[1] == self.write.get_bytes(port, 0, brightness)
def test_set_speed(self, cls, port, speed): self._create_motor(cls) self.m.port = port async def child(): await self.m.set_speed(speed) kernel.run(child) self.m.send_message.ask_called_once() args, kwargs = self.m.send_message.call_args assert args[1] == self.write.get_bytes( port, 0, self.m._convert_speed_to_val(speed))
def test_ramp_speed(self, cls, port, speed): self._create_motor(cls) self.m.port = port async def child(): await self.m.ramp_speed(speed, 200) await self.m.ramp_in_progress_task.join() async def main(): t = await spawn(child()) await t.join() assert self.m.speed == speed kernel.run(main)
def test_ramp_cancel_speed(self, cls, port, speed): self._create_motor(cls) self.m.port = port async def child(): await self.m.ramp_speed(speed, 2000) await sleep(0.1) await self.m.set_speed(speed + 10) async def main(): t = await spawn(child()) await t.join() assert self.m.speed == speed + 10 kernel.run(main)
def test_rotate(self, cls, port, angle, speed): self._create_motor(cls) self.m.port = port max_power = 50 async def child(): await self.m.rotate(angle, speed, max_power) async def main(): t = await spawn(child()) await t.join() kernel.run(main) args, kwargs = self.m.send_message.call_args assert args[1] == self.write.get_bytes_for_rotate( port, angle, self.m._convert_speed_to_val(speed), max_power)
def start_thread(): kernel.run(start_curio)