Files
FitTrack2/FitnessSync/backend/tests/api/test_discovery.py
sstent d1cfd0fd8e feat: implement Fitbit OAuth, Garmin MFA, and optimize segment discovery
- Add Fitbit authentication flow (save credentials, OAuth callback handling)
- Implement Garmin MFA support with successful session/cookie handling
- Optimize segment discovery with new sampling and activity query services
- Refactor database session management in discovery API for better testability
- Enhance activity data parsing for charts and analysis
- Update tests to use testcontainers and proper dependency injection
- Clean up repository by ignoring and removing tracked transient files (.pyc, .db)
2026-01-16 15:35:26 -08:00

31 lines
1016 B
Python

from fastapi.testclient import TestClient
from main import app
from unittest.mock import MagicMock, patch
def test_discovery_endpoint(client):
# 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(client):
response = client.get("/discovery")
assert response.status_code == 200
assert "Segment Discovery" in response.text