From e26a3dc0e7e017d6324966bed76ebab4d80bdaeb Mon Sep 17 00:00:00 2001 From: bendikro Date: Sun, 30 Oct 2016 12:11:36 +0100 Subject: [PATCH] [Tests] Move test torrents into data subdir --- deluge/tests/common.py | 3 --- deluge/tests/{ => data}/deluge.png | Bin .../tests/{ => data}/dir_with_6_files.torrent | Bin deluge/tests/{ => data}/google.ico | Bin deluge/tests/{ => data}/test.torrent | 0 .../{ => data}/test_torrent.file.torrent | 0 .../ubuntu-9.04-desktop-i386.iso.torrent | Bin deluge/tests/{ => data}/ubuntu.png | Bin .../{ => data}/unicode_filenames.torrent | Bin deluge/tests/openbt.png | Bin 673 -> 0 bytes deluge/tests/publicbt.ico | Bin 2550 -> 0 bytes deluge/tests/test_core.py | 22 +++++++++--------- deluge/tests/test_torrent.py | 8 +++---- deluge/tests/test_torrentmanager.py | 2 +- deluge/tests/test_tracker_icons.py | 11 ++++----- deluge/tests/test_ui_common.py | 4 ++-- deluge/tests/test_web_api.py | 6 ++--- 17 files changed, 25 insertions(+), 31 deletions(-) rename deluge/tests/{ => data}/deluge.png (100%) rename deluge/tests/{ => data}/dir_with_6_files.torrent (100%) rename deluge/tests/{ => data}/google.ico (100%) rename deluge/tests/{ => data}/test.torrent (100%) rename deluge/tests/{ => data}/test_torrent.file.torrent (100%) rename deluge/tests/{ => data}/ubuntu-9.04-desktop-i386.iso.torrent (100%) rename deluge/tests/{ => data}/ubuntu.png (100%) rename deluge/tests/{ => data}/unicode_filenames.torrent (100%) delete mode 100644 deluge/tests/openbt.png delete mode 100644 deluge/tests/publicbt.ico diff --git a/deluge/tests/common.py b/deluge/tests/common.py index 9f3fd1790..d751b85c6 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -75,9 +75,6 @@ def add_watchdog(deferred, timeout=0.05, message=None): return watchdog -def rpath(*args): - return os.path.join(os.path.dirname(__file__), *args) - # Initialize gettext lang.setup_translations() diff --git a/deluge/tests/deluge.png b/deluge/tests/data/deluge.png similarity index 100% rename from deluge/tests/deluge.png rename to deluge/tests/data/deluge.png diff --git a/deluge/tests/dir_with_6_files.torrent b/deluge/tests/data/dir_with_6_files.torrent similarity index 100% rename from deluge/tests/dir_with_6_files.torrent rename to deluge/tests/data/dir_with_6_files.torrent diff --git a/deluge/tests/google.ico b/deluge/tests/data/google.ico similarity index 100% rename from deluge/tests/google.ico rename to deluge/tests/data/google.ico diff --git a/deluge/tests/test.torrent b/deluge/tests/data/test.torrent similarity index 100% rename from deluge/tests/test.torrent rename to deluge/tests/data/test.torrent diff --git a/deluge/tests/test_torrent.file.torrent b/deluge/tests/data/test_torrent.file.torrent similarity index 100% rename from deluge/tests/test_torrent.file.torrent rename to deluge/tests/data/test_torrent.file.torrent diff --git a/deluge/tests/ubuntu-9.04-desktop-i386.iso.torrent b/deluge/tests/data/ubuntu-9.04-desktop-i386.iso.torrent similarity index 100% rename from deluge/tests/ubuntu-9.04-desktop-i386.iso.torrent rename to deluge/tests/data/ubuntu-9.04-desktop-i386.iso.torrent diff --git a/deluge/tests/ubuntu.png b/deluge/tests/data/ubuntu.png similarity index 100% rename from deluge/tests/ubuntu.png rename to deluge/tests/data/ubuntu.png diff --git a/deluge/tests/unicode_filenames.torrent b/deluge/tests/data/unicode_filenames.torrent similarity index 100% rename from deluge/tests/unicode_filenames.torrent rename to deluge/tests/data/unicode_filenames.torrent diff --git a/deluge/tests/openbt.png b/deluge/tests/openbt.png deleted file mode 100644 index 270d617aec02a1f51da388ad978afe47022a11d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 673 zcmV;S0$%-zP)L} zXWR!2*4JG$k{Q!}{*v~>`(;x5W{K+hBpJCvxY9XlU%x@_W0jqEhJU%!ojS_@aHb>-SfzW=34#>5fw z@4`4dV>Yx2YM09NuhG6$CjSmQXiBiyLT3{e@1k|_G6vsk2YTjyUSrGx?4=4sIu+z( z_!S__fhFLpk-rc_5Jp z`ywLXrlDRBp0PCq?kwGbb^pOo&fBbWEpF6k5doN>`}%DJ?0x(MZ_C7BV*`U~HOdDV zzpOt5%3cXFn?;N}%vpKLdf2ck%aHL{(7w&$Jd*QsTxNRD)W5fx$E2^&A|!w}{@mRdipyVIpnYCulNA5BlD+LV@-VQZP*Z z@*Jm87IK=2!e ztzN(cpiB3|R&U@e*CKU|5=PN;e`{9N1&6>x`Z^SK`;jHluQlyl={u z`tMbu!~VTm@|*6<`HxBNzH-!oBj&E60rITjk~DVI$nBbaa>6>-*q^D0m0LA?#NP2) z@)|BnN>PB*Pj~yAx^!vjY>DXTyYV-r8qot{%R-V>h>|uYpB1T#}?NZg2 zF9pqyWOs3}bhp<$=o_lP6-aYOoupUB86S@LFYH(3ZQ~td_n|q*_&HP-Y2qKV&Jt_u z8!2gdE_+Lc%ImK;rzy2sb~U0bTu zwwD{+^cMf9HA-sQOC-DYh%<)c{(4?>bjNnkVCZ>6mSk3KH2J$+y_vYoH0$?j(_}}X zpS!&a{x!~%`g5#z9Abr4rz4*+op<{!*C z$aN5#luWRuVE+KQ3gQps7|2DCiy*(io&|Co;sLz!Ol`+xC&2L9y?B=;ERw!a#N?ok~% zKh6@rU=(Mn`b=LvHpDV4JR!=L3&5nr0r0W(L;tnYR3ExNcA-CYzXi+J4W~XU+J8}O zfMsyZ;=Xg|QC}7Y?>X_7glHd(UP(P^5PRH2%T!Nb;0CW`#AqD#2aH(G{ppjPdgN^C zK}kVf`+-Rz)G=;Vh&dm;g8y68JtGolhFZqVNF2{LXzm|8WyzYQQ-_%Qn+49y;PaHa OxqQf<_F6r!c0U2}z(JM( diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py index c2d47022e..6d9165dac 100644 --- a/deluge/tests/test_core.py +++ b/deluge/tests/test_core.py @@ -33,7 +33,7 @@ class CookieResource(Resource): return 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() return data @@ -41,7 +41,7 @@ class CookieResource(Resource): class PartialDownload(Resource): 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() request.setHeader("Content-Type", len(data)) request.setHeader("Content-Type", "application/x-bittorrent") @@ -67,7 +67,7 @@ class TopLevelResource(Resource): self.putChild("partial", PartialDownload()) self.putChild("redirect", RedirectResource()) 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): @@ -109,7 +109,7 @@ class CoreTestCase(BaseTestCase): filenames = ["test.torrent", "test_torrent.file.torrent"] files_to_add = [] for f in filenames: - filename = common.rpath(f) + filename = common.get_test_data_file(f) with open(filename) as _file: filedump = base64.encodestring(_file.read()) files_to_add.append((filename, filedump, options)) @@ -122,7 +122,7 @@ class CoreTestCase(BaseTestCase): filenames = ["test.torrent", "test.torrent"] files_to_add = [] for f in filenames: - filename = common.rpath(f) + filename = common.get_test_data_file(f) with open(filename) as _file: filedump = base64.encodestring(_file.read()) files_to_add.append((filename, filedump, options)) @@ -133,7 +133,7 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_add_torrent_file(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) 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): 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) @defer.inlineCallbacks @@ -201,7 +201,7 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrent(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -215,12 +215,12 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrents(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) 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: filedump = base64.encodestring(_file.read()) torrent_id2 = yield self.core.add_torrent_file(filename2, filedump, options) @@ -238,7 +238,7 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrents_invalid(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py index 572e1afa5..7d864c067 100644 --- a/deluge/tests/test_torrent.py +++ b/deluge/tests/test_torrent.py @@ -52,7 +52,7 @@ class TorrentTestCase(BaseTestCase): self.assertEquals(torrent.state, state) def get_torrent_atp(self, filename): - filename = common.rpath(filename) + filename = common.get_test_data_file(filename) with open(filename, 'rb') as _file: info = lt.torrent_info(lt.bdecode(_file.read())) atp = {"ti": info} @@ -117,7 +117,7 @@ class TorrentTestCase(BaseTestCase): @defer.inlineCallbacks def test_torrent_error_data_missing(self): 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: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -133,7 +133,7 @@ class TorrentTestCase(BaseTestCase): @defer.inlineCallbacks def test_torrent_error_resume_original_state(self): 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: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -178,7 +178,7 @@ class TorrentTestCase(BaseTestCase): 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: filedump = _file.read() torrent_id = yield self.core.torrentmanager.add(state=torrent_state, filedump=filedump, diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py index cabd0bb57..b1c90fdbd 100644 --- a/deluge/tests/test_torrentmanager.py +++ b/deluge/tests/test_torrentmanager.py @@ -29,7 +29,7 @@ class TorrentmanagerTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrent(self): - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, {}) diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index aeebd64df..ac76a1dcb 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -1,5 +1,3 @@ -import os - import pytest import deluge.component as component @@ -10,7 +8,6 @@ from . import common from .basetest import BaseTestCase common.set_tmp_config_dir() -dirname = os.path.dirname(__file__) deluge.ui.tracker_icons.PIL_INSTALLED = False common.disable_new_release_check() @@ -26,7 +23,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_deluge_png(self): # 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.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) @@ -35,7 +32,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_google_ico(self): # Google doesn't have any icon links # 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.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) @@ -43,7 +40,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_google_ico_with_redirect(self): # 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.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) @@ -51,7 +48,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_ubuntu_ico(self): # 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.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py index 55541e82b..a2c98c298 100644 --- a/deluge/tests/test_ui_common.py +++ b/deluge/tests/test_ui_common.py @@ -22,12 +22,12 @@ class UICommonTestCase(unittest.TestCase): pass def test_utf8_encoded_paths(self): - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") ti = TorrentInfo(filename) self.assertTrue("azcvsupdater_2.6.2.jar" in ti.files_tree) def test_utf8_encoded_paths2(self): - filename = common.rpath("unicode_filenames.torrent") + filename = common.get_test_data_file("unicode_filenames.torrent") ti = TorrentInfo(filename) files = ti.files_tree["unicode_filenames"] diff --git a/deluge/tests/test_web_api.py b/deluge/tests/test_web_api.py index a2cc54bd0..dfcbce77f 100644 --- a/deluge/tests/test_web_api.py +++ b/deluge/tests/test_web_api.py @@ -121,7 +121,7 @@ class WebAPITestCase(WebServerTestBase): self.assertFalse(self.deluge_web.web_api.remove_host(conn[0])) 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) self.assertEquals(ret["name"], "azcvsupdater_2.6.2.jar") self.assertEquals(ret["info_hash"], "ab570cdd5a17ea1b61e970bb72047de141bce173") @@ -136,7 +136,7 @@ class WebAPITestCase(WebServerTestBase): @defer.inlineCallbacks def test_get_torrent_files(self): 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/"}}] yield self.deluge_web.web_api.add_torrents(torrents) ret = yield self.deluge_web.web_api.get_torrent_files("ab570cdd5a17ea1b61e970bb72047de141bce173") @@ -148,7 +148,7 @@ class WebAPITestCase(WebServerTestBase): @defer.inlineCallbacks def test_download_torrent_from_url(self): 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) res = yield self.deluge_web.web_api.download_torrent_from_url(url) self.assertTrue(res.endswith(filename))