Skip to content

Commit

Permalink
feat(torrent): wrap Torrent.status to support simple comparison wit…
Browse files Browse the repository at this point in the history
…h attribute (#75)

`assert Torrent().status.downloading`
  • Loading branch information
trim21 committed Mar 31, 2021
1 parent de972f5 commit 36aa54b
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 51 deletions.
14 changes: 13 additions & 1 deletion docs/source/torrent.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
Torrent
============================================

.. autoclass:: transmission_rpc.torrent.Torrent
.. automodule:: transmission_rpc.torrent

.. autoclass:: Torrent
:members:

.. autoclass:: Status

.. autoattribute:: Status.stopped
.. autoattribute:: Status.check_pending
.. autoattribute:: Status.checking
.. autoattribute:: Status.download_pending
.. autoattribute:: Status.downloading
.. autoattribute:: Status.seed_pending
.. autoattribute:: Status.seeding

.. toctree::
:maxdepth: 2
:caption: Contents:
128 changes: 103 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ flake8-mutable = "1.2.0"
pytest-github-actions-annotate-failures = "==0.1.2"
flake8-pytest-style = "1.4.0"
pylint = "2.7.4"
sphinx-autobuild = "2021.3.14"

[tool.isort]
default_section = 'THIRDPARTY'
Expand Down
8 changes: 8 additions & 0 deletions tests/test_torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import transmission_rpc
import transmission_rpc.utils
import transmission_rpc.constants
from transmission_rpc.torrent import Status


def test_initial():
Expand Down Expand Up @@ -95,3 +96,10 @@ def test_attributes():

torrent = transmission_rpc.Torrent(None, data)
assert torrent.date_done is None


def test_status():
assert Status("downloading").downloading
assert not Status("downloading").download_pending
assert Status("download pending").download_pending
assert Status("some thing") == "some thing"

0 comments on commit 36aa54b

Please sign in to comment.