release: nexus btpanel session fix and app-v2
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""Tests for script execution progress summary (success/total, failures excluded)."""
|
||||
|
||||
from server.infrastructure.redis.script_execution_store import execution_progress_summary
|
||||
|
||||
|
||||
def test_all_success():
|
||||
ids = [1, 2, 3]
|
||||
results = {
|
||||
"1": {"status": "success", "exit_code": 0},
|
||||
"2": {"status": "success", "exit_code": 0},
|
||||
"3": {"phase": "done", "status": "completed", "exit_code": 0},
|
||||
}
|
||||
assert execution_progress_summary(results, ids) == "3/3"
|
||||
|
||||
|
||||
def test_partial_failure():
|
||||
ids = list(range(1, 367))
|
||||
results = {str(i): {"status": "success", "exit_code": 0} for i in ids[:-1]}
|
||||
results[str(ids[-1])] = {"status": "failed", "exit_code": 1, "stderr": "error"}
|
||||
assert execution_progress_summary(results, ids) == "365/366"
|
||||
|
||||
|
||||
def test_all_failed():
|
||||
ids = [10, 20]
|
||||
results = {
|
||||
"10": {"status": "failed", "exit_code": 1},
|
||||
"20": {"status": "error", "exit_code": -1},
|
||||
}
|
||||
assert execution_progress_summary(results, ids) == "0/2"
|
||||
|
||||
|
||||
def test_pending_not_counted():
|
||||
ids = [1, 2, 3]
|
||||
results = {
|
||||
"1": {"status": "success", "exit_code": 0},
|
||||
"2": {"phase": "pending", "status": "started"},
|
||||
"3": {"status": "failed", "exit_code": 1},
|
||||
}
|
||||
assert execution_progress_summary(results, ids) == "1/3"
|
||||
|
||||
|
||||
def test_skipped_not_counted():
|
||||
ids = [1, 2]
|
||||
results = {
|
||||
"1": {"status": "success", "exit_code": 0},
|
||||
"2": {"status": "skipped", "exit_code": -1, "stderr": "no ssh"},
|
||||
}
|
||||
assert execution_progress_summary(results, ids) == "1/2"
|
||||
|
||||
|
||||
def test_missing_result_not_success():
|
||||
ids = [1, 2, 3]
|
||||
results = {"1": {"status": "success", "exit_code": 0}}
|
||||
assert execution_progress_summary(results, ids) == "1/3"
|
||||
|
||||
|
||||
def test_empty_total():
|
||||
assert execution_progress_summary({}, []) == "—"
|
||||
Reference in New Issue
Block a user