MCPcopy Create free account
hub / github.com/FastLED/FastLED / main_async

Function main_async

ci/test_void_rpc.py:20–76  ·  view source on GitHub ↗

Test void RPC functionality (async main function).

(port: str, baudrate: int, use_pyserial: bool)

Source from the content-addressed store, hash-verified

18
19
20async def main_async(port: str, baudrate: int, use_pyserial: bool) -> int:
21 """Test void RPC functionality (async main function)."""
22 print(f"🔌 Connecting to {port} at {baudrate} baud...")
23
24 serial_iface = create_serial_interface(
25 port, baud_rate=baudrate, use_pyserial=use_pyserial
26 )
27 async with RpcClient(
28 port, baudrate=baudrate, serial_interface=serial_iface
29 ) as client:
30 print("✅ Connected")
31
32 # Test 1: Call a void function (setPins doesn't return a value)
33 print("\n📡 Test 1: Void function (setPins)")
34 try:
35 response = await client.send("setPins", args=[{"tx": 0, "rx": 1}])
36 print(f" Response success: {response.success}")
37 print(f" Response data: {response.data}")
38 print(f" Response ID: {response._id}")
39
40 # Verify void function response
41 assert response.success, "Void function should be marked as successful"
42 assert isinstance(response.data, dict), (
43 "response.data should always be a dict"
44 )
45 print(f" ✅ Void function handled correctly")
46 except KeyboardInterrupt as ki:
47 handle_keyboard_interrupt(ki)
48 raise
49 except Exception as e:
50 print(f" ❌ Error: {e}")
51 return 1
52
53 # Test 2: Call a non-void function (ping returns data)
54 print("\n📡 Test 2: Non-void function (ping)")
55 try:
56 response = await client.send("ping")
57 print(f" Response success: {response.success}")
58 print(f" Response data: {response.data}")
59 print(f" Response ID: {response._id}")
60
61 # Verify non-void function response
62 assert response.success, "ping should be marked as successful"
63 assert isinstance(response.data, dict), "response.data should be a dict"
64 assert len(response.data) > 0, "ping should return data"
65 print(f" ✅ Non-void function handled correctly")
66 except KeyboardInterrupt as ki:
67 handle_keyboard_interrupt(ki)
68 raise
69 except Exception as e:
70 print(f" ❌ Error: {e}")
71 return 1
72
73 print("\n✅ All void RPC tests passed!")
74 print("\n💡 Void functions return null but are treated as successful execution")
75
76 return 0
77

Callers 1

mainFunction · 0.70

Calls 5

create_serial_interfaceFunction · 0.90
RpcClientClass · 0.90
printFunction · 0.50
sendMethod · 0.45

Tested by

no test coverage detected