Implement Phases 1-5: skeleton, OAuth, categories, video sync/feed, playback
- FastAPI + PostgreSQL + Alembic + React/Vite skeleton, Docker Compose, healthcheck - Google OAuth (single allowed account), encrypted refresh token storage - Subscriptions sync with pagination, uploads playlist batch fetch - Categories CRUD, many-to-many channel assignment, category filtering - Video sync (playlistItems + videos.list batching), cached feed with cursor pagination, background scheduler (APScheduler) - Video detail page with YouTube embed player - SPA fallback routing, optimistic UI updates, client-side query caching 40 backend tests covering OAuth allow-list, sync idempotency, cascade deletes, cursor pagination, and category filtering. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
commit
0ed20bb838
90 changed files with 8545 additions and 0 deletions
43
tests/test_health.py
Normal file
43
tests/test_health.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.db import get_db
|
||||
from app.main import app
|
||||
|
||||
|
||||
def _fake_db():
|
||||
session = MagicMock()
|
||||
session.execute.return_value = None
|
||||
yield session
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_get_db():
|
||||
app.dependency_overrides[get_db] = _fake_db
|
||||
yield
|
||||
del app.dependency_overrides[get_db]
|
||||
|
||||
|
||||
def test_health_ok():
|
||||
with patch("app.api.health.httpx.get") as mock_get:
|
||||
mock_get.return_value = MagicMock(status_code=200)
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/health")
|
||||
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["status"] == "ok"
|
||||
assert body["database"] == "ok"
|
||||
assert body["metube"] == "ok"
|
||||
|
||||
|
||||
def test_health_metube_unreachable():
|
||||
with patch("app.api.health.httpx.get", side_effect=ConnectionError):
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/health")
|
||||
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["metube"] == "error"
|
||||
Loading…
Add table
Add a link
Reference in a new issue