async def test_call_remote_method(base_server: Server, klippy: KlippyProcess): fut = base_server.get_event_loop().create_future() def method_test(result): fut.set_result(result) base_server.register_remote_method("moonraker_test", method_test) base_server.load_components() await base_server.server_init() ret = base_server.klippy_connection.wait_connected() await asyncio.wait_for(ret, 4.) klippy.send_gcode("TEST_REMOTE_METHOD") await fut await base_server._stop_server("terminate") assert fut.result() == "test"
async def test_register_remote_method_running(full_server: Server): await full_server.start_server(connect_to_klippy=False) with pytest.raises(ServerError): full_server.register_remote_method("moonraker_test", lambda: None)
def test_register_method_exists(self, core_server: Server): with pytest.raises(ServerError): core_server.register_remote_method("shutdown_machine", lambda: None)
def test_register_remote_method(self, core_server: Server): core_server.register_remote_method("moonraker_test", lambda: None) kconn = core_server.klippy_connection assert "moonraker_test" in kconn.remote_methods