FastLED 3.9.15
Loading...
Searching...
No Matches
test_quick.py
Go to the documentation of this file.
1import os
2import subprocess
3import sys
4import time
5
6import httpx
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 = subprocess.Popen(
22 [runner_path, dll_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
23)
24
25# Wait for server to start
26time.sleep(1.5)
27
28# Try to connect
29try:
30 print("\nTesting GET /")
31 response = httpx.get("http://localhost:8080/", timeout=5.0)
32 print(f"✓ Status: {response.status_code}")
33 print(f" Response: {response.text!r}\n")
34
35 print("Testing GET /ping")
36 response = httpx.get("http://localhost:8080/ping", timeout=5.0)
37 print(f"✓ Status: {response.status_code}")
38 print(f" Response: {response.text!r}\n")
39
40 print("Testing GET /status")
41 response = httpx.get("http://localhost:8080/status", timeout=5.0)
42 print(f"✓ Status: {response.status_code}")
43 print(f" Response (JSON): {response.json()}\n")
44
45 print("✓ All tests passed!")
46 sys.exit(0)
47except Exception as e:
48 print(f"\n✗ Error: {e}")
49 # Print server output for debugging
50 output, _ = proc.communicate(timeout=1)
51 print(f"\nServer output:\n{output}")
52 sys.exit(1)
53finally:
54 proc.terminate()
55 try:
56 proc.wait(timeout=1)
57 except:
58 proc.kill()
Serial print("Error: ")