[feat] Add comprehensive unit tests for TaskQueue operations
- Add MockTaskQueue class with dependency injection for isolated testing - Test core operations: queueing, processing, batch tracking, state management - Test thread safety: concurrent access, worker lifecycle, exception handling - Test integration workflows: full task processing with WebSocket updates - Test edge cases: empty queues, invalid data, cleanup scenarios - Solve heapq compatibility by wrapping items in priority tuples - Include pytest configuration and test runner script - All 15 tests passing with proper async/threading support Testing covers: ✅ Task queueing with Pydantic validation ✅ Batch history tracking and persistence ✅ Thread-safe concurrent operations ✅ Worker thread lifecycle management ✅ WebSocket message delivery tracking ✅ State snapshots and error conditions
This commit is contained in:
42
run_tests.py
Normal file
42
run_tests.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple test runner for ComfyUI-Manager tests.
|
||||
|
||||
Usage:
|
||||
python run_tests.py # Run all tests
|
||||
python run_tests.py -k test_task_queue # Run specific tests
|
||||
python run_tests.py --cov # Run with coverage
|
||||
"""
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
def main():
|
||||
"""Run pytest with appropriate arguments"""
|
||||
# Ensure we're in the project directory
|
||||
project_root = Path(__file__).parent
|
||||
|
||||
# Base pytest command
|
||||
cmd = [sys.executable, "-m", "pytest"]
|
||||
|
||||
# Add any command line arguments passed to this script
|
||||
cmd.extend(sys.argv[1:])
|
||||
|
||||
# Add default arguments if none provided
|
||||
if len(sys.argv) == 1:
|
||||
cmd.extend([
|
||||
"tests/",
|
||||
"-v",
|
||||
"--tb=short"
|
||||
])
|
||||
|
||||
print(f"Running: {' '.join(cmd)}")
|
||||
print(f"Working directory: {project_root}")
|
||||
|
||||
# Run pytest
|
||||
result = subprocess.run(cmd, cwd=project_root)
|
||||
sys.exit(result.returncode)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user