chore(backend): repair test suite and bring ruff to green

The suite hadn't run green since the routes refactor:
- test_profile_duplicate_names.py imported the pre-refactor module
  layout and broke collection; now imports backend.services.profiles
- tests/conftest.py puts the repo root and backend dir on sys.path so
  files collect standalone instead of depending on run order
- test_cors.py tested a hand-copied mirror of the origin list that had
  drifted from app.py (missing http://tauri.localhost); it now builds
  the app via the real create_app() factory
- test_progress.py simulated a 1KB download, below the tracker's 1MB
  reporting threshold; simulation raised to 5MB
- slow/timeout markers registered in pyproject

Ruff: ~900 violations auto-fixed (typing modernization, import
sorting, unused imports, whitespace). The remaining rules are baselined
in pyproject.toml with per-rule counts to burn down, plus per-file
carve-outs for deliberate env-before-import ordering. ruff check is
now clean; suite is 134 passed, 2 skipped.
This commit is contained in:
Jamie Pine
2026-07-26 23:16:09 -07:00
parent 766c51a8a1
commit b434db22f6
82 changed files with 970 additions and 999 deletions
+13 -13
View File
@@ -4,9 +4,8 @@ Test script to debug model download progress tracking.
import asyncio
import json
import time
from typing import List, Dict
import logging
import time
# Set up logging to see what's happening
logging.basicConfig(
@@ -14,8 +13,8 @@ logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
from utils.progress import ProgressManager, get_progress_manager
from utils.hf_progress import HFProgressTracker, create_hf_progress_callback
from utils.progress import ProgressManager, get_progress_manager
def test_progress_manager_basic():
@@ -61,7 +60,7 @@ async def test_progress_manager_sse():
print("=" * 60)
pm = ProgressManager()
collected_events: List[Dict] = []
collected_events: list[dict] = []
# Simulate SSE client
async def sse_client():
@@ -123,7 +122,7 @@ def test_hf_progress_tracker():
print("Test 3: HFProgressTracker tqdm Patching")
print("=" * 60)
captured_progress: List[tuple] = []
captured_progress: list[tuple] = []
def progress_callback(downloaded: int, total: int, filename: str):
"""Capture progress updates."""
@@ -137,12 +136,14 @@ def test_hf_progress_tracker():
try:
from tqdm import tqdm
# Simulate downloading a file
# Simulate downloading a file. The tracker only reports once the
# combined total crosses MIN_TOTAL_BYTES (1 MB), so the simulated
# file must be larger than that.
print(" Simulating download with tqdm...")
total_size = 1000
total_size = 5_000_000
with tqdm(total=total_size, desc="model.bin", unit="B", unit_scale=True) as pbar:
for chunk in range(0, total_size, 100):
pbar.update(100)
for chunk in range(0, total_size, 500_000):
pbar.update(500_000)
time.sleep(0.01)
print(f" Captured {len(captured_progress)} progress updates")
@@ -170,7 +171,7 @@ async def test_full_integration():
print("=" * 60)
pm = get_progress_manager()
collected_events: List[Dict] = []
collected_events: list[dict] = []
# SSE client
async def sse_client():
@@ -244,9 +245,8 @@ async def test_full_integration():
assert collected_events[-1]["status"] == "complete", "Should end with 'complete'"
print("✓ Test 4 PASSED\n")
return True
else:
print("✗ Test 4 FAILED - No events received\n")
return False
print("✗ Test 4 FAILED - No events received\n")
return False
async def main():