32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from fastapi.testclient import TestClient
|
|
from main import app
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
client = TestClient(app)
|
|
|
|
def test_discovery_endpoint():
|
|
# Mock the service to avoid DB calls
|
|
with patch('src.api.discovery.SegmentDiscoveryService') as MockService:
|
|
instance = MockService.return_value
|
|
instance.discover_segments.return_value = ([], []) # Empty candidates, empty debug paths
|
|
|
|
|
|
response = client.post("/api/discovery/segments", json={
|
|
"activity_type": "cycling",
|
|
"start_date": "2025-01-01T00:00:00"
|
|
})
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert "candidates" in data
|
|
assert isinstance(data["candidates"], list)
|
|
assert "debug_paths" in data
|
|
assert isinstance(data["debug_paths"], list)
|
|
|
|
|
|
def test_discovery_page_render():
|
|
response = client.get("/discovery")
|
|
assert response.status_code == 200
|
|
assert "Segment Discovery" in response.text
|