29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""Run with the Godot console executable as the first argument. No physical GPIO."""
|
|
import subprocess
|
|
import sys
|
|
import threading
|
|
from pathlib import Path
|
|
from http.server import HTTPServer
|
|
from test_bridge import FakePin, bridge
|
|
|
|
outputs = bridge.Outputs(FakePin, "cabinet_01_gpio", [17])
|
|
server = HTTPServer(("127.0.0.1", 8765), bridge.handler_for(outputs))
|
|
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
|
thread.start()
|
|
try:
|
|
root = Path(__file__).resolve().parents[2]
|
|
result = subprocess.run([
|
|
sys.argv[1], "--headless", "--path", str(root),
|
|
"--log-file", str(root / ".godot/gpio_integration.log"),
|
|
"--script", "tests/gpio/check_gpio.gd", "--", "--gpio=real",
|
|
], timeout=15)
|
|
assert result.returncode == 0, "Godot integration failed"
|
|
assert 17 in outputs.pins, "Bridge never received BCM17"
|
|
assert outputs.pins[17]["polarity"] is True, "Expected active-high output"
|
|
print("Godot -> HTTP -> GPIO backend integration passed (fake pin)")
|
|
finally:
|
|
server.shutdown()
|
|
thread.join()
|
|
outputs.close()
|
|
server.server_close()
|