Skip to content

Commit

Permalink
Fix Download following API refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 22, 2019
1 parent 887416d commit 37f3b71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/aria2p/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,19 @@ def move_to_bottom(self):
return self.api.move_to_bottom(self)

def remove(self):
return self.api.remove([self])
result = self.api.remove([self])[0]
if not result:
raise result
return result

def pause(self):
return self.api.pause([self])
result = self.api.pause([self])[0]
if not result:
raise result
return result

def resume(self):
return self.api.resume([self])
result = self.api.resume([self])[0]
if not result:
raise result
return result
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,24 @@ def test_pause_all_method():
# raise AssertionError


def test_purge_method():
def test_autopurge_method():
with Aria2Server(port=7117, session=SESSIONS_DIR / "3-dls.txt") as server:
assert server.api.purge()
assert server.api.autopurge()


def test_remove_method():
with Aria2Server(port=7118, session=SESSIONS_DIR / "3-dls.txt") as server:
downloads = server.api.get_downloads()
assert server.api.remove(downloads) == [d.gid for d in downloads]
assert server.api.remove(downloads) == [True for _ in downloads]
downloads = server.api.get_downloads()
assert all([d.is_removed for d in downloads])
assert not downloads


def test_remove_all_method():
with Aria2Server(port=7119, session=SESSIONS_DIR / "3-dls.txt") as server:
assert server.api.remove_all()
downloads = server.api.get_downloads()
assert all([d.is_removed for d in downloads])
assert not downloads


def test_resume_method():
Expand Down

0 comments on commit 37f3b71

Please sign in to comment.