1e67eeb25b
- Configure conftest.py with pytest tmp_path DB isolation fixtures - Add test_db.py for schema connection validations - Add test_fetcher.py with mocked yt-dlp subprocess parser checks - Add test_summarizer.py with mocked transcripts and Claude API requests - Add test_main.py for FastAPI router endpoints and state updates Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
1002 B
Python
29 lines
1002 B
Python
import pytest
|
|
import aiosqlite
|
|
import db
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_init_db(test_db):
|
|
# Verify that the table is created
|
|
cursor = await test_db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='videos'")
|
|
table = await cursor.fetchone()
|
|
assert table is not None
|
|
assert table["name"] == "videos"
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_insert_video(test_db):
|
|
# Insert a video and check constraints/defaults
|
|
await test_db.execute("""
|
|
INSERT INTO videos (video_id, title, url, status)
|
|
VALUES ('test1234', 'Test Video Title', 'https://www.youtube.com/watch?v=test1234', 'pending')
|
|
""")
|
|
await test_db.commit()
|
|
|
|
cursor = await test_db.execute("SELECT * FROM videos WHERE video_id = 'test1234'")
|
|
video = await cursor.fetchone()
|
|
assert video is not None
|
|
assert video["title"] == "Test Video Title"
|
|
assert video["status"] == "pending"
|
|
assert video["created_at"] is not None
|
|
assert video["summary"] is None
|