-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add avg max_dl_speed and min_ul_speed condition
Closes #49.
- Loading branch information
1 parent
32bf679
commit 44b9884
Showing
9 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from .base import Comparer | ||
from .base import Condition | ||
|
||
class AverageDownloadSpeedCondition(Condition): | ||
def __init__(self, avg_dl_speed, comp = Comparer.GT): | ||
Condition.__init__(self) # Initialize remain and remove list | ||
self._avg_dl_speed = avg_dl_speed # In KiB | ||
self._comparer = comp | ||
|
||
def apply(self, torrents): | ||
for torrent in torrents: | ||
if self.compare(torrent.average_download_speed, self._avg_dl_speed * 1024, self._comparer): | ||
self.remove.add(torrent) | ||
else: | ||
self.remain.add(torrent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from .base import Comparer | ||
from .base import Condition | ||
|
||
class AverageUploadSpeedCondition(Condition): | ||
def __init__(self, avg_ul_speed, comp = Comparer.LT): | ||
Condition.__init__(self) # Initialize remain and remove list | ||
self._avg_ul_speed = avg_ul_speed # In KiB | ||
self._comparer = comp | ||
|
||
def apply(self, torrents): | ||
for torrent in torrents: | ||
if self.compare(torrent.average_upload_speed, self._avg_ul_speed * 1024, self._comparer): | ||
self.remove.add(torrent) | ||
else: | ||
self.remain.add(torrent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
pytest/test_strategies/cases/max_average_downloadspeed/test_max_average_downloadspeed.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
test: | ||
max_average_downloadspeed: 5120 | ||
remove: | ||
- Torrent - 3 | ||
- Torrent - 5 | ||
- Torrent - 7 | ||
- Torrent - 8 | ||
- Torrent - 9 | ||
- Torrent - 11 | ||
- Torrent - 13 | ||
- Torrent - 14 | ||
- Torrent - 16 |
9 changes: 9 additions & 0 deletions
9
pytest/test_strategies/cases/min_average_uploadspeed/test_min_average_uploadspeed.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
test: | ||
min_average_uploadspeed: 512 | ||
remove: | ||
- Torrent - 1 | ||
- Torrent - 3 | ||
- Torrent - 6 | ||
- Torrent - 10 | ||
- Torrent - 12 | ||
- Torrent - 14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters