From 04dd2c530e569bc07b90ac95853d9221171c77d7 Mon Sep 17 00:00:00 2001 From: drew2a Date: Mon, 29 Jan 2024 16:09:25 +0700 Subject: [PATCH] Refactor download_state.py and test_download_state.py - Remove the `get_session_ratio` method from `DownloadState` class in download_state.py - Remove the assertion for `get_session_ratio()` in test_download_state.py --- .../libtorrent/download_manager/download_state.py | 7 ------- .../components/libtorrent/tests/test_download_state.py | 1 - 2 files changed, 8 deletions(-) diff --git a/src/tribler/core/components/libtorrent/download_manager/download_state.py b/src/tribler/core/components/libtorrent/download_manager/download_state.py index fdeb2f5d015..ce4a4ece66d 100644 --- a/src/tribler/core/components/libtorrent/download_manager/download_state.py +++ b/src/tribler/core/components/libtorrent/download_manager/download_state.py @@ -153,13 +153,6 @@ def total_payload_download(self) -> int: return 0 return self.lt_status.total_payload_download - def get_session_ratio(self) -> float: - """ Returns the seeding ratio of the download for the current session. - """ - if not self.lt_status or not self.total_payload_download: - return 0 - return self.total_payload_upload / self.total_payload_download - def get_all_time_ratio(self) -> float: """ Returns the accumulated seeding ratio of the download across multiple sessions. """ diff --git a/src/tribler/core/components/libtorrent/tests/test_download_state.py b/src/tribler/core/components/libtorrent/tests/test_download_state.py index acf165c3003..a96d9329592 100644 --- a/src/tribler/core/components/libtorrent/tests/test_download_state.py +++ b/src/tribler/core/components/libtorrent/tests/test_download_state.py @@ -58,7 +58,6 @@ def test_getters_setters_2(mock_download, mock_lt_status): assert download_state.total_payload_upload == 30 assert download_state.total_payload_download == 100 - assert download_state.get_session_ratio() == 0.3 assert download_state.all_time_upload == 200 assert download_state.all_time_download == 1000