async def test_process_mode_event() -> None: """Started hub should emit mode events.""" hub = Hub("1.2.3.4", "1234", "token") await hub.start() handler_called = False def listener(_: Any): nonlocal handler_called handler_called = True hub._process_event(events["mode"]) assert handler_called is False hub.add_mode_listener(listener) hub._process_event(events["mode"]) assert handler_called is True
def test_process_mode_event(self, MockServer) -> None: """Started hub should emit mode events.""" hub = Hub("1.2.3.4", "1234", "token") wait_for(hub.start()) handler_called = False def listener(_: Any): nonlocal handler_called handler_called = True hub._process_event(events["mode"]) self.assertFalse(handler_called) hub.add_mode_listener(listener) hub._process_event(events["mode"]) self.assertTrue(handler_called)