mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Updated docstring in add_torrent_url.
Wrote test for add_torrent_url which tests sending headers.
This commit is contained in:
parent
698d37f535
commit
c9228c99a7
2 changed files with 16 additions and 2 deletions
|
@ -271,8 +271,7 @@ class Core(component.Component):
|
||||||
:param options: dict, the options to apply to the torrent on add
|
:param options: dict, the options to apply to the torrent on add
|
||||||
:param headers: dict, any optional headers to send
|
:param headers: dict, any optional headers to send
|
||||||
|
|
||||||
:returns: the torrent_id as a str or None, if calling locally, then it
|
:returns: a Deferred which returns the torrent_id as a str or None
|
||||||
will return a Deferred that fires once the torrent has been added
|
|
||||||
"""
|
"""
|
||||||
log.info("Attempting to add url %s", url)
|
log.info("Attempting to add url %s", url)
|
||||||
def on_get_file(result):
|
def on_get_file(result):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
from twisted.python.failure import Failure
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from hashlib import sha1 as sha
|
from hashlib import sha1 as sha
|
||||||
|
@ -45,6 +46,20 @@ class CoreTestCase(unittest.TestCase):
|
||||||
d.addCallback(self.assertEquals, info_hash)
|
d.addCallback(self.assertEquals, info_hash)
|
||||||
return d
|
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):
|
def test_add_magnet(self):
|
||||||
info_hash = "60d5d82328b4547511fdeac9bf4d0112daa0ce00"
|
info_hash = "60d5d82328b4547511fdeac9bf4d0112daa0ce00"
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue