From afce63727d881fb6ff8a963a7982b08eaa95a8b3 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sun, 25 Sep 2016 01:53:18 +0300 Subject: [PATCH] Automatically update progress status when updating stage --- tests/test_ditem.py | 4 ++++ youtube_dl_gui/downloadmanager.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/test_ditem.py b/tests/test_ditem.py index ad7229e..66cd758 100644 --- a/tests/test_ditem.py +++ b/tests/test_ditem.py @@ -102,15 +102,19 @@ class TestSetItemStage(unittest.TestCase): def test_set_stage_valid(self): self.ditem.stage = "Queued" self.assertEqual(self.ditem.stage, "Queued") + self.assertEqual(self.ditem.progress_stats["status"], "Queued") self.ditem.stage = "Active" self.assertEqual(self.ditem.stage, "Active") + self.assertEqual(self.ditem.progress_stats["status"], "Pre Processing") self.ditem.stage = "Completed" self.assertEqual(self.ditem.stage, "Completed") + self.assertEqual(self.ditem.progress_stats["status"], "Finished") self.ditem.stage = "Paused" self.assertEqual(self.ditem.stage, "Paused") + self.assertEqual(self.ditem.progress_stats["status"], "Paused") def test_set_stage_invalid(self): raised = False diff --git a/youtube_dl_gui/downloadmanager.py b/youtube_dl_gui/downloadmanager.py index 090ae31..e38ba54 100644 --- a/youtube_dl_gui/downloadmanager.py +++ b/youtube_dl_gui/downloadmanager.py @@ -116,6 +116,15 @@ class DownloadItem(object): if value not in self.STAGES: raise ValueError(value) + if value == "Queued": + self.progress_stats["status"] = value + if value == "Active": + self.progress_stats["status"] = self.ACTIVE_STAGES[0] + if value == "Completed": + self.progress_stats["status"] = self.COMPLETED_STAGES[0] + if value == "Paused": + self.progress_stats["status"] = value + self._stage = value def get_files(self):