38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Tests for script execution progress stats (done/remaining vs success/total)."""
|
|
|
|
from server.infrastructure.redis.script_execution_store import execution_progress_stats
|
|
|
|
|
|
def test_progress_stats_empty_results():
|
|
stats = execution_progress_stats({}, [1, 2, 3])
|
|
assert stats["total"] == 3
|
|
assert stats["done"] == 0
|
|
assert stats["remaining"] == 3
|
|
assert stats["success"] == 0
|
|
assert stats["progress"] == "0/3"
|
|
|
|
|
|
def test_progress_stats_mixed_success_and_failure():
|
|
results = {
|
|
"1": {"exit_code": 0, "status": "success"},
|
|
"2": {"exit_code": 1, "status": "failed"},
|
|
"3": {"phase": "pending"},
|
|
}
|
|
stats = execution_progress_stats(results, [1, 2, 3])
|
|
assert stats["done"] == 2
|
|
assert stats["remaining"] == 1
|
|
assert stats["success"] == 1
|
|
assert stats["failed"] == 1
|
|
assert stats["progress"] == "1/3"
|
|
|
|
|
|
def test_progress_stats_long_task_pending_not_done():
|
|
results = {
|
|
"10": {"phase": "pending", "exit_code": 0},
|
|
"11": {"phase": "done", "exit_code": 0, "status": "completed"},
|
|
}
|
|
stats = execution_progress_stats(results, [10, 11])
|
|
assert stats["done"] == 1
|
|
assert stats["remaining"] == 1
|
|
assert stats["success"] == 1
|