[Tests] Move test torrents into data subdir
@ -75,9 +75,6 @@ def add_watchdog(deferred, timeout=0.05, message=None):
|
|||||||
return watchdog
|
return watchdog
|
||||||
|
|
||||||
|
|
||||||
def rpath(*args):
|
|
||||||
return os.path.join(os.path.dirname(__file__), *args)
|
|
||||||
|
|
||||||
# Initialize gettext
|
# Initialize gettext
|
||||||
lang.setup_translations()
|
lang.setup_translations()
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 722 B |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 2.5 KiB |
@ -33,7 +33,7 @@ class CookieResource(Resource):
|
|||||||
return
|
return
|
||||||
|
|
||||||
request.setHeader("Content-Type", "application/x-bittorrent")
|
request.setHeader("Content-Type", "application/x-bittorrent")
|
||||||
with open(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent")) as _file:
|
with open(common.get_test_data_file("ubuntu-9.04-desktop-i386.iso.torrent")) as _file:
|
||||||
data = _file.read()
|
data = _file.read()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ class CookieResource(Resource):
|
|||||||
class PartialDownload(Resource):
|
class PartialDownload(Resource):
|
||||||
|
|
||||||
def render(self, request):
|
def render(self, request):
|
||||||
with open(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent")) as _file:
|
with open(common.get_test_data_file("ubuntu-9.04-desktop-i386.iso.torrent")) as _file:
|
||||||
data = _file.read()
|
data = _file.read()
|
||||||
request.setHeader("Content-Type", len(data))
|
request.setHeader("Content-Type", len(data))
|
||||||
request.setHeader("Content-Type", "application/x-bittorrent")
|
request.setHeader("Content-Type", "application/x-bittorrent")
|
||||||
@ -67,7 +67,7 @@ class TopLevelResource(Resource):
|
|||||||
self.putChild("partial", PartialDownload())
|
self.putChild("partial", PartialDownload())
|
||||||
self.putChild("redirect", RedirectResource())
|
self.putChild("redirect", RedirectResource())
|
||||||
self.putChild("ubuntu-9.04-desktop-i386.iso.torrent",
|
self.putChild("ubuntu-9.04-desktop-i386.iso.torrent",
|
||||||
File(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent")))
|
File(common.get_test_data_file("ubuntu-9.04-desktop-i386.iso.torrent")))
|
||||||
|
|
||||||
|
|
||||||
class CoreTestCase(BaseTestCase):
|
class CoreTestCase(BaseTestCase):
|
||||||
@ -109,7 +109,7 @@ class CoreTestCase(BaseTestCase):
|
|||||||
filenames = ["test.torrent", "test_torrent.file.torrent"]
|
filenames = ["test.torrent", "test_torrent.file.torrent"]
|
||||||
files_to_add = []
|
files_to_add = []
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
filename = common.rpath(f)
|
filename = common.get_test_data_file(f)
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
files_to_add.append((filename, filedump, options))
|
files_to_add.append((filename, filedump, options))
|
||||||
@ -122,7 +122,7 @@ class CoreTestCase(BaseTestCase):
|
|||||||
filenames = ["test.torrent", "test.torrent"]
|
filenames = ["test.torrent", "test.torrent"]
|
||||||
files_to_add = []
|
files_to_add = []
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
filename = common.rpath(f)
|
filename = common.get_test_data_file(f)
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
files_to_add.append((filename, filedump, options))
|
files_to_add.append((filename, filedump, options))
|
||||||
@ -133,7 +133,7 @@ class CoreTestCase(BaseTestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_add_torrent_file(self):
|
def test_add_torrent_file(self):
|
||||||
options = {}
|
options = {}
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
||||||
@ -146,7 +146,7 @@ class CoreTestCase(BaseTestCase):
|
|||||||
|
|
||||||
def test_add_torrent_file_invalid_filedump(self):
|
def test_add_torrent_file_invalid_filedump(self):
|
||||||
options = {}
|
options = {}
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
self.assertRaises(AddTorrentError, self.core.add_torrent_file, filename, False, options)
|
self.assertRaises(AddTorrentError, self.core.add_torrent_file, filename, False, options)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@ -201,7 +201,7 @@ class CoreTestCase(BaseTestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_remove_torrent(self):
|
def test_remove_torrent(self):
|
||||||
options = {}
|
options = {}
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
||||||
@ -215,12 +215,12 @@ class CoreTestCase(BaseTestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_remove_torrents(self):
|
def test_remove_torrents(self):
|
||||||
options = {}
|
options = {}
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
||||||
|
|
||||||
filename2 = common.rpath("unicode_filenames.torrent")
|
filename2 = common.get_test_data_file("unicode_filenames.torrent")
|
||||||
with open(filename2) as _file:
|
with open(filename2) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id2 = yield self.core.add_torrent_file(filename2, filedump, options)
|
torrent_id2 = yield self.core.add_torrent_file(filename2, filedump, options)
|
||||||
@ -238,7 +238,7 @@ class CoreTestCase(BaseTestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_remove_torrents_invalid(self):
|
def test_remove_torrents_invalid(self):
|
||||||
options = {}
|
options = {}
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
||||||
|
@ -52,7 +52,7 @@ class TorrentTestCase(BaseTestCase):
|
|||||||
self.assertEquals(torrent.state, state)
|
self.assertEquals(torrent.state, state)
|
||||||
|
|
||||||
def get_torrent_atp(self, filename):
|
def get_torrent_atp(self, filename):
|
||||||
filename = common.rpath(filename)
|
filename = common.get_test_data_file(filename)
|
||||||
with open(filename, 'rb') as _file:
|
with open(filename, 'rb') as _file:
|
||||||
info = lt.torrent_info(lt.bdecode(_file.read()))
|
info = lt.torrent_info(lt.bdecode(_file.read()))
|
||||||
atp = {"ti": info}
|
atp = {"ti": info}
|
||||||
@ -117,7 +117,7 @@ class TorrentTestCase(BaseTestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_torrent_error_data_missing(self):
|
def test_torrent_error_data_missing(self):
|
||||||
options = {"seed_mode": True}
|
options = {"seed_mode": True}
|
||||||
filename = common.rpath("test_torrent.file.torrent")
|
filename = common.get_test_data_file("test_torrent.file.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
||||||
@ -133,7 +133,7 @@ class TorrentTestCase(BaseTestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_torrent_error_resume_original_state(self):
|
def test_torrent_error_resume_original_state(self):
|
||||||
options = {"seed_mode": True, "add_paused": True}
|
options = {"seed_mode": True, "add_paused": True}
|
||||||
filename = common.rpath("test_torrent.file.torrent")
|
filename = common.get_test_data_file("test_torrent.file.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, options)
|
||||||
@ -178,7 +178,7 @@ class TorrentTestCase(BaseTestCase):
|
|||||||
is_finished=True,
|
is_finished=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
filename = common.rpath("test_torrent.file.torrent")
|
filename = common.get_test_data_file("test_torrent.file.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = _file.read()
|
filedump = _file.read()
|
||||||
torrent_id = yield self.core.torrentmanager.add(state=torrent_state, filedump=filedump,
|
torrent_id = yield self.core.torrentmanager.add(state=torrent_state, filedump=filedump,
|
||||||
|
@ -29,7 +29,7 @@ class TorrentmanagerTestCase(BaseTestCase):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_remove_torrent(self):
|
def test_remove_torrent(self):
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
with open(filename) as _file:
|
with open(filename) as _file:
|
||||||
filedump = base64.encodestring(_file.read())
|
filedump = base64.encodestring(_file.read())
|
||||||
torrent_id = yield self.core.add_torrent_file(filename, filedump, {})
|
torrent_id = yield self.core.add_torrent_file(filename, filedump, {})
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
@ -10,7 +8,6 @@ from . import common
|
|||||||
from .basetest import BaseTestCase
|
from .basetest import BaseTestCase
|
||||||
|
|
||||||
common.set_tmp_config_dir()
|
common.set_tmp_config_dir()
|
||||||
dirname = os.path.dirname(__file__)
|
|
||||||
deluge.ui.tracker_icons.PIL_INSTALLED = False
|
deluge.ui.tracker_icons.PIL_INSTALLED = False
|
||||||
common.disable_new_release_check()
|
common.disable_new_release_check()
|
||||||
|
|
||||||
@ -26,7 +23,7 @@ class TrackerIconsTestCase(BaseTestCase):
|
|||||||
|
|
||||||
def test_get_deluge_png(self):
|
def test_get_deluge_png(self):
|
||||||
# Deluge has a png favicon link
|
# Deluge has a png favicon link
|
||||||
icon = TrackerIcon(os.path.join(dirname, "deluge.png"))
|
icon = TrackerIcon(common.get_test_data_file("deluge.png"))
|
||||||
d = self.icons.fetch("deluge-torrent.org")
|
d = self.icons.fetch("deluge-torrent.org")
|
||||||
d.addCallback(self.assertNotIdentical, None)
|
d.addCallback(self.assertNotIdentical, None)
|
||||||
d.addCallback(self.assertEquals, icon)
|
d.addCallback(self.assertEquals, icon)
|
||||||
@ -35,7 +32,7 @@ class TrackerIconsTestCase(BaseTestCase):
|
|||||||
def test_get_google_ico(self):
|
def test_get_google_ico(self):
|
||||||
# Google doesn't have any icon links
|
# Google doesn't have any icon links
|
||||||
# So instead we'll grab its favicon.ico
|
# So instead we'll grab its favicon.ico
|
||||||
icon = TrackerIcon(os.path.join(dirname, "google.ico"))
|
icon = TrackerIcon(common.get_test_data_file("google.ico"))
|
||||||
d = self.icons.fetch("www.google.com")
|
d = self.icons.fetch("www.google.com")
|
||||||
d.addCallback(self.assertNotIdentical, None)
|
d.addCallback(self.assertNotIdentical, None)
|
||||||
d.addCallback(self.assertEquals, icon)
|
d.addCallback(self.assertEquals, icon)
|
||||||
@ -43,7 +40,7 @@ class TrackerIconsTestCase(BaseTestCase):
|
|||||||
|
|
||||||
def test_get_google_ico_with_redirect(self):
|
def test_get_google_ico_with_redirect(self):
|
||||||
# google.com redirects to www.google.com
|
# google.com redirects to www.google.com
|
||||||
icon = TrackerIcon(os.path.join(dirname, "google.ico"))
|
icon = TrackerIcon(common.get_test_data_file("google.ico"))
|
||||||
d = self.icons.fetch("google.com")
|
d = self.icons.fetch("google.com")
|
||||||
d.addCallback(self.assertNotIdentical, None)
|
d.addCallback(self.assertNotIdentical, None)
|
||||||
d.addCallback(self.assertEquals, icon)
|
d.addCallback(self.assertEquals, icon)
|
||||||
@ -51,7 +48,7 @@ class TrackerIconsTestCase(BaseTestCase):
|
|||||||
|
|
||||||
def test_get_ubuntu_ico(self):
|
def test_get_ubuntu_ico(self):
|
||||||
# ubuntu.com has inline css which causes HTMLParser issues
|
# ubuntu.com has inline css which causes HTMLParser issues
|
||||||
icon = TrackerIcon(os.path.join(dirname, "ubuntu.png"))
|
icon = TrackerIcon(common.get_test_data_file("ubuntu.png"))
|
||||||
d = self.icons.fetch("www.ubuntu.com")
|
d = self.icons.fetch("www.ubuntu.com")
|
||||||
d.addCallback(self.assertNotIdentical, None)
|
d.addCallback(self.assertNotIdentical, None)
|
||||||
d.addCallback(self.assertEquals, icon)
|
d.addCallback(self.assertEquals, icon)
|
||||||
|
@ -22,12 +22,12 @@ class UICommonTestCase(unittest.TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def test_utf8_encoded_paths(self):
|
def test_utf8_encoded_paths(self):
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
ti = TorrentInfo(filename)
|
ti = TorrentInfo(filename)
|
||||||
self.assertTrue("azcvsupdater_2.6.2.jar" in ti.files_tree)
|
self.assertTrue("azcvsupdater_2.6.2.jar" in ti.files_tree)
|
||||||
|
|
||||||
def test_utf8_encoded_paths2(self):
|
def test_utf8_encoded_paths2(self):
|
||||||
filename = common.rpath("unicode_filenames.torrent")
|
filename = common.get_test_data_file("unicode_filenames.torrent")
|
||||||
ti = TorrentInfo(filename)
|
ti = TorrentInfo(filename)
|
||||||
|
|
||||||
files = ti.files_tree["unicode_filenames"]
|
files = ti.files_tree["unicode_filenames"]
|
||||||
|
@ -121,7 +121,7 @@ class WebAPITestCase(WebServerTestBase):
|
|||||||
self.assertFalse(self.deluge_web.web_api.remove_host(conn[0]))
|
self.assertFalse(self.deluge_web.web_api.remove_host(conn[0]))
|
||||||
|
|
||||||
def test_get_torrent_info(self):
|
def test_get_torrent_info(self):
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
ret = self.deluge_web.web_api.get_torrent_info(filename)
|
ret = self.deluge_web.web_api.get_torrent_info(filename)
|
||||||
self.assertEquals(ret["name"], "azcvsupdater_2.6.2.jar")
|
self.assertEquals(ret["name"], "azcvsupdater_2.6.2.jar")
|
||||||
self.assertEquals(ret["info_hash"], "ab570cdd5a17ea1b61e970bb72047de141bce173")
|
self.assertEquals(ret["info_hash"], "ab570cdd5a17ea1b61e970bb72047de141bce173")
|
||||||
@ -136,7 +136,7 @@ class WebAPITestCase(WebServerTestBase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_get_torrent_files(self):
|
def test_get_torrent_files(self):
|
||||||
yield self.deluge_web.web_api.connect(self.host_id)
|
yield self.deluge_web.web_api.connect(self.host_id)
|
||||||
filename = common.rpath("test.torrent")
|
filename = common.get_test_data_file("test.torrent")
|
||||||
torrents = [{"path": filename, "options": {"download_location": "/home/deluge/"}}]
|
torrents = [{"path": filename, "options": {"download_location": "/home/deluge/"}}]
|
||||||
yield self.deluge_web.web_api.add_torrents(torrents)
|
yield self.deluge_web.web_api.add_torrents(torrents)
|
||||||
ret = yield self.deluge_web.web_api.get_torrent_files("ab570cdd5a17ea1b61e970bb72047de141bce173")
|
ret = yield self.deluge_web.web_api.get_torrent_files("ab570cdd5a17ea1b61e970bb72047de141bce173")
|
||||||
@ -148,7 +148,7 @@ class WebAPITestCase(WebServerTestBase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_download_torrent_from_url(self):
|
def test_download_torrent_from_url(self):
|
||||||
filename = "ubuntu-9.04-desktop-i386.iso.torrent"
|
filename = "ubuntu-9.04-desktop-i386.iso.torrent"
|
||||||
self.deluge_web.top_level.putChild(filename, File(common.rpath(filename)))
|
self.deluge_web.top_level.putChild(filename, File(common.get_test_data_file(filename)))
|
||||||
url = "http://localhost:%d/%s" % (self.webserver_listen_port, filename)
|
url = "http://localhost:%d/%s" % (self.webserver_listen_port, filename)
|
||||||
res = yield self.deluge_web.web_api.download_torrent_from_url(url)
|
res = yield self.deluge_web.web_api.download_torrent_from_url(url)
|
||||||
self.assertTrue(res.endswith(filename))
|
self.assertTrue(res.endswith(filename))
|
||||||
|