Updated docstring in add_torrent_url.

Wrote test for add_torrent_url which tests sending headers.
This commit is contained in:
John Garland 2009-07-21 02:45:16 +00:00
parent 698d37f535
commit c9228c99a7
2 changed files with 16 additions and 2 deletions

View file

@ -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):

View file

@ -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