Files
soleprint/station/tools/tester/tests/example/test_health.py
2025-12-31 09:07:27 -03:00

37 lines
1.1 KiB
Python

"""
Example health check test.
This is a fallback test that works without room-specific configuration.
Replace with room tests via cfg/<room>/tester/tests/
"""
import httpx
import pytest
class TestHealth:
"""Basic health check tests."""
@pytest.fixture
def base_url(self):
"""Base URL for the API under test."""
import os
return os.getenv("TEST_BASE_URL", "http://localhost:8000")
def test_health_endpoint(self, base_url):
"""Test that /health endpoint responds."""
try:
response = httpx.get(f"{base_url}/health", timeout=5)
assert response.status_code == 200
except httpx.ConnectError:
pytest.skip("API not running - set TEST_BASE_URL or start the service")
def test_root_endpoint(self, base_url):
"""Test that root endpoint responds."""
try:
response = httpx.get(base_url, timeout=5)
assert response.status_code in [200, 301, 302, 307, 308]
except httpx.ConnectError:
pytest.skip("API not running - set TEST_BASE_URL or start the service")