diff --git a/deluge/core/core.py b/deluge/core/core.py index cf86d0dd2..8bb872187 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -271,8 +271,7 @@ class Core(component.Component): :param options: dict, the options to apply to the torrent on add :param headers: dict, any optional headers to send - :returns: the torrent_id as a str or None, if calling locally, then it - will return a Deferred that fires once the torrent has been added + :returns: a Deferred which returns the torrent_id as a str or None """ log.info("Attempting to add url %s", url) def on_get_file(result): diff --git a/tests/test_core.py b/tests/test_core.py index 72bd9261a..1dcdc7e5d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,4 +1,5 @@ from twisted.trial import unittest +from twisted.python.failure import Failure try: from hashlib import sha1 as sha @@ -45,6 +46,20 @@ class CoreTestCase(unittest.TestCase): d.addCallback(self.assertEquals, info_hash) return d + def test_add_torrent_url_with_cookie(self): + url = "http://cgi.cse.unsw.edu.au/~johnnyg/torrent.php" + options = {} + headers = { "Cookie" : "password=deluge" } + info_hash = "60d5d82328b4547511fdeac9bf4d0112daa0ce00" + + d = self.core.add_torrent_url(url, options) + d.addCallbacks(self.fail, self.assertIsInstance, Failure) + + d = self.core.add_torrent_url(url, options, headers) + d.addCallback(self.assertEquals, info_hash) + + return d + def test_add_magnet(self): info_hash = "60d5d82328b4547511fdeac9bf4d0112daa0ce00" import deluge.common