Show Jellyfin handoff jobs in queue

This commit is contained in:
Dymas
2026-07-17 12:30:23 +02:00
parent ba408877b5
commit 604265c44f
7 changed files with 198 additions and 11 deletions
+42
View File
@@ -389,6 +389,7 @@ class QueueApiTests(unittest.TestCase):
self.queue = APP.DOWNLOAD_QUEUE
with self.queue._connect() as conn:
conn.execute("DELETE FROM jobs")
conn.execute("DELETE FROM jellyfin_sync_jobs")
def test_download_queue_get_returns_single_job(self):
created = self.queue.add(
@@ -429,6 +430,42 @@ class QueueApiTests(unittest.TestCase):
self.assertEqual(handler.json_status, HTTPStatus.OK)
self.assertEqual(handler.json_payload["id"], created["id"])
def test_queue_route_includes_jellyfin_handoff_jobs(self):
APP.WATCHLIST_JELLYFIN_SYNC.start(
config={
"download_dir": "/tmp/downloads",
"jellyfin_sync_enabled": True,
"jellyfin_tv_dir": "/tmp/jellyfin-tv",
"jellyfin_movie_dir": "/tmp/jellyfin-movies",
}
)
handler = DummyHandler("/api/queue?page=1&per_page=10")
APP.Handler.do_GET(handler)
self.assertEqual(handler.json_status, HTTPStatus.OK)
jellyfin_jobs = [job for job in handler.json_payload["jobs"] if job.get("job_type") == "jellyfin_handoff"]
self.assertEqual(len(jellyfin_jobs), 1)
self.assertEqual(jellyfin_jobs[0]["title"], "Jellyfin handoff")
self.assertEqual(jellyfin_jobs[0]["mode"], "copy")
def test_queue_item_get_route_returns_jellyfin_handoff_job(self):
created = APP.WATCHLIST_JELLYFIN_SYNC.start(
config={
"download_dir": "/tmp/downloads",
"jellyfin_sync_enabled": True,
"jellyfin_tv_dir": "/tmp/jellyfin-tv",
"jellyfin_movie_dir": "",
}
)["job"]
handler = DummyHandler(f"/api/queue/{created['id']}")
APP.Handler.do_GET(handler)
self.assertEqual(handler.json_status, HTTPStatus.OK)
self.assertEqual(handler.json_payload["id"], created["id"])
self.assertEqual(handler.json_payload["job_type"], "jellyfin_handoff")
def test_retry_rejects_done_jobs(self):
created = self.queue.add(
{
@@ -3528,6 +3565,11 @@ class TemplateHelperTests(unittest.TestCase):
self.assertIn('/api/queue/clear-failed', APP.QUEUE_HTML)
self.assertIn('Removed failed jobs', APP.QUEUE_HTML)
def test_queue_page_formats_jellyfin_handoff_jobs(self):
self.assertIn('job.job_type === "jellyfin_handoff"', APP.QUEUE_HTML)
self.assertIn('const progress = `${job.completed || 0}/${job.total || 0} entries`;', APP.QUEUE_HTML)
self.assertIn('const moved = `${job.moved || 0} moved`;', APP.QUEUE_HTML)
def test_search_page_queues_selected_title_without_result_index(self):
self.assertIn('query: state.selected.title,', APP.INDEX_HTML)
self.assertNotIn('index: state.selected.index,', APP.INDEX_HTML)