Skip to content

Commit

Permalink
feat: Add the is_torrent property to Download objects.
Browse files Browse the repository at this point in the history
Reference: issue #53.
  • Loading branch information
pawamoy committed Apr 7, 2020
1 parent 74106fe commit 0c7760e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/aria2p/downloads.py
Expand Up @@ -349,6 +349,10 @@ def is_metadata(self):
"""Return True if this download is only composed of metadata, and no actual files."""
return all(_.is_metadata for _ in self.files)

@property
def is_torrent(self):
return "bittorrent" in self._struct

@property
def total_length(self):
"""Total length of the download in bytes."""
Expand Down
5 changes: 5 additions & 0 deletions tests/test_downloads.py
Expand Up @@ -378,6 +378,11 @@ def test_verified_length_string(self):
def test_verify_integrity_pending(self):
assert self.download.verify_integrity_pending is None

def test_is_torrent(self):
assert self.download.is_torrent
del self.download._struct["bittorrent"]
assert not self.download.is_torrent


class TestFileClass:
def setup_method(self):
Expand Down

0 comments on commit 0c7760e

Please sign in to comment.