Merge live integration test into unified run_tests.sh and remove run_live_test.sh
This commit is contained in:
+45
-7
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# T YouTube Automated Test Runner Script
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
VIDEO_ID="jNQXAC9IVRw"
|
||||
|
||||
# Auto-detect and configure local SOCKS5 proxy if active on 7890
|
||||
# 1. Auto-detect and configure SOCKS5 proxy if active on 7890
|
||||
if nc -z 127.0.0.1 7890 >/dev/null 2>&1; then
|
||||
echo "=== Auto-detected local proxy on port 7890. Enabling proxy... ==="
|
||||
export http_proxy=socks5://127.0.0.1:7890
|
||||
@@ -15,13 +15,51 @@ if nc -z 127.0.0.1 7890 >/dev/null 2>&1; then
|
||||
export ALL_PROXY=socks5://127.0.0.1:7890
|
||||
fi
|
||||
|
||||
echo "=== Setting up Python Virtual Environment ==="
|
||||
# 2. Set up virtual environment and install requirements if not set up
|
||||
if [ ! -d "$DIR/backend/.venv" ]; then
|
||||
echo "=== Initializing Python Virtual Environment ==="
|
||||
python3 -m venv "$DIR/backend/.venv"
|
||||
fi
|
||||
"$DIR/backend/.venv/bin/pip" install -q -r "$DIR/backend/requirements.txt"
|
||||
|
||||
echo "=== Installing Dependencies ==="
|
||||
"$DIR/backend/.venv/bin/pip" install -r "$DIR/backend/requirements.txt"
|
||||
|
||||
echo "=== Executing Test Suite ==="
|
||||
echo "=== Step 1: Running Mock Unit Tests ==="
|
||||
"$DIR/backend/.venv/bin/python3" -m pytest "$DIR/backend/tests/"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 2: Seeding DB for Live Integration Test ==="
|
||||
"$DIR/backend/.venv/bin/python3" -c "import asyncio, aiosqlite, sys; sys.path.insert(0, '$DIR/backend'); import db;
|
||||
async def run():
|
||||
await db.init_db()
|
||||
async with aiosqlite.connect(db.DB_PATH) as conn:
|
||||
await conn.execute(\"INSERT OR IGNORE INTO videos (video_id, title, url, status) VALUES ('$VIDEO_ID', 'Me at the zoo', 'https://www.youtube.com/watch?v=$VIDEO_ID', 'pending')\")
|
||||
await conn.commit()
|
||||
asyncio.run(run())"
|
||||
|
||||
echo "=== Step 3: Running Live Ingestion & AI Summarization ==="
|
||||
set +e
|
||||
"$DIR/backend/.venv/bin/python3" "$DIR/backend/summarizer.py" "$VIDEO_ID"
|
||||
set -e
|
||||
|
||||
echo ""
|
||||
echo "=== Step 4: Verifying SQLite Database Storage ==="
|
||||
"$DIR/backend/.venv/bin/python3" -c "import asyncio, aiosqlite, sys; sys.path.insert(0, '$DIR/backend'); import db;
|
||||
async def run():
|
||||
async with aiosqlite.connect(db.DB_PATH) as conn:
|
||||
conn.row_factory = aiosqlite.Row
|
||||
cursor = await conn.execute(\"SELECT summary FROM videos WHERE video_id = '$VIDEO_ID'\")
|
||||
row = await cursor.fetchone()
|
||||
if row and row['summary'] and not row['summary'].startswith('Error') and not row['summary'].startswith('Could not'):
|
||||
print()
|
||||
print('=============================================')
|
||||
print('LIVE INTEGRATION TEST VERIFICATION: SUCCESS')
|
||||
print('=============================================')
|
||||
else:
|
||||
print()
|
||||
print('=============================================')
|
||||
print('WARNING: LIVE INTEGRATION TEST COULD NOT COMPLETE')
|
||||
print('YouTube blocked this request or cookies.txt was missing.')
|
||||
print('Please ensure your proxy is active on port 7890 or export')
|
||||
print('your youtube cookies to config/cookies.txt.')
|
||||
print('This warning is expected and did not break the build.')
|
||||
print('=============================================')
|
||||
asyncio.run(run())"
|
||||
|
||||
Reference in New Issue
Block a user