Show live repair progress on requests
Magent CI/CD / verify (push) Canceled after 4m53s
Magent CI/CD / deploy-prod (push) Canceled after 0s
Magent CI/CD / deploy-beta (push) Canceled after 0s

This commit is contained in:
2026-09-01 21:17:50 +12:00
parent 6391fbfd81
commit 3fc52f70c7
5 changed files with 469 additions and 5 deletions
+88
View File
@@ -36,6 +36,7 @@ from backend.app.services.operation_progress import (
from backend.app.services.snapshot import (
_apply_arr_identity,
_build_presentation,
_build_repair_activity,
_episode_availability,
_torrent_progress,
)
@@ -396,6 +397,93 @@ class RequestVisibilityTests(unittest.TestCase):
class RequestPresentationTests(unittest.TestCase):
def test_repair_activity_shows_collector_search_before_download(self) -> None:
snapshot = Snapshot(
request_id="144",
title="Toy Story 2",
request_type=RequestType.movie,
state=NormalizedState.searching,
)
activity = _build_repair_activity(
snapshot,
action={
"action_id": "replace_media",
"status": "ok",
"message": "Radarr removed the file and started a replacement search.",
"created_at": "2026-09-01T09:06:55+00:00",
},
arr_state="searching",
arr_details={"availability": {"available": 0, "missing": 1, "total": 1}},
download={"visible": False, "state": "not_started", "torrents": []},
jellyfin_found=False,
)
self.assertIsNotNone(activity)
self.assertEqual(activity["state"], "searching")
self.assertEqual(activity["headline"], "Replacement search in progress")
self.assertEqual(activity["steps"][1]["state"], "complete")
self.assertEqual(activity["steps"][2]["state"], "waiting")
def test_repair_activity_tracks_replacement_download(self) -> None:
snapshot = Snapshot(
request_id="144",
title="Toy Story 2",
request_type=RequestType.movie,
state=NormalizedState.downloading,
)
activity = _build_repair_activity(
snapshot,
action={
"action_id": "replace_media",
"status": "ok",
"message": "Radarr started a replacement search.",
"created_at": "2026-09-01T09:06:55+00:00",
},
arr_state="searching",
arr_details={"availability": {"available": 0, "missing": 1, "total": 1}},
download={
"visible": True,
"state": "downloading",
"summary": "Downloading (1 active).",
"torrents": [{"progress": 0.25}],
},
jellyfin_found=False,
)
self.assertIsNotNone(activity)
self.assertEqual(activity["state"], "downloading")
self.assertEqual(activity["headline"], "Replacement download in progress")
self.assertEqual(activity["steps"][2]["state"], "active")
def test_repair_activity_reports_collected_file_and_media_index(self) -> None:
snapshot = Snapshot(
request_id="144",
title="Toy Story 2",
request_type=RequestType.movie,
state=NormalizedState.importing,
)
activity = _build_repair_activity(
snapshot,
action={
"action_id": "replace_media",
"status": "ok",
"message": "Radarr started a replacement search.",
"created_at": "2026-09-01T09:06:55+00:00",
},
arr_state="available",
arr_details={"availability": {"available": 1, "missing": 0, "total": 1}},
download={"visible": False, "state": "not_started", "torrents": []},
jellyfin_found=False,
)
self.assertIsNotNone(activity)
self.assertEqual(activity["state"], "indexing")
self.assertEqual(activity["steps"][2]["state"], "complete")
self.assertEqual(activity["steps"][3]["state"], "active")
def test_torrent_progress_keeps_tenths_for_live_updates(self) -> None:
self.assertEqual(_torrent_progress({"progress": 0.1344}), 13.4)