FastLED 3.10.8
Loading...
Searching...
No Matches
test_quick.py
Go to the documentation of this file.
1import os
2import sys
3import time
4
5import httpx
6from running_process import STDOUT, RunningProcess
7
8
9# Get absolute paths
10cwd = os.getcwd()
11runner_path = os.path.join(
12 cwd, ".build", "meson-quick", "examples", "example_runner.exe"
13)
14dll_path = os.path.join(cwd, ".build", "meson-quick", "examples", "example-Server.dll")
15
16print(f"Starting server...")
17print(f" Runner: {runner_path}")
18print(f" DLL: {dll_path}")
19
20# Start server in background
21proc = RunningProcess(
22 [runner_path, dll_path],
23 auto_run=True,
24 capture=True,
25 stderr=STDOUT,
26 encoding="utf-8",
27 errors="replace",
28)
29
30# Wait for server to start
31time.sleep(1.5)
32
33# Try to connect
34try:
35 print("\nTesting GET /")
36 response = httpx.get("http://localhost:8080/", timeout=5.0)
37 print(f"✓ Status: {response.status_code}")
38 print(f" Response: {response.text!r}\n")
39
40 print("Testing GET /ping")
41 response = httpx.get("http://localhost:8080/ping", timeout=5.0)
42 print(f"✓ Status: {response.status_code}")
43 print(f" Response: {response.text!r}\n")
44
45 print("Testing GET /status")
46 response = httpx.get("http://localhost:8080/status", timeout=5.0)
47 print(f"✓ Status: {response.status_code}")
48 print(f" Response (JSON): {response.json()}\n")
49
50 print("✓ All tests passed!")
51 sys.exit(0)
52except Exception as e:
53 print(f"\n✗ Error: {e}")
54 # Print server output for debugging
55 proc.terminate()
56 try:
57 proc.wait(timeout=1)
58 except TimeoutError:
59 pass
60 print(f"\nServer output:\n{proc.stdout}")
61 sys.exit(1)
62finally:
63 proc.terminate()
64 try:
65 proc.wait(timeout=1)
66 except:
67 proc.kill()
Serial print("Error: ")