Fix gettext setup in test_common and log in test_transfer so tests run standalone
Add extra tests to test_config Run the test files through flake8 to tidy up code
This commit is contained in:
parent
28d7c5d44a
commit
e2e09200c4
|
@ -10,21 +10,20 @@ import deluge.log
|
|||
|
||||
deluge.log.setupLogger("none")
|
||||
|
||||
|
||||
def set_tmp_config_dir():
|
||||
config_directory = tempfile.mkdtemp()
|
||||
deluge.configmanager.set_config_dir(config_directory)
|
||||
return config_directory
|
||||
|
||||
|
||||
def rpath(*args):
|
||||
return os.path.join(os.path.dirname(__file__), *args)
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
import pkg_resources
|
||||
|
||||
# Initialize gettext
|
||||
deluge.common.setup_translations()
|
||||
|
||||
|
||||
def start_core():
|
||||
CWD = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
DAEMON_SCRIPT = """
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
from twisted.trial import unittest
|
||||
|
||||
import common
|
||||
|
||||
from deluge.core.alertmanager import AlertManager
|
||||
from deluge.core.core import Core
|
||||
import deluge.component as component
|
||||
from deluge.core.core import Core
|
||||
|
||||
|
||||
class AlertManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from twisted.trial import unittest
|
||||
|
||||
import common
|
||||
|
||||
from deluge.core.authmanager import AuthManager, AUTH_LEVEL_ADMIN
|
||||
|
||||
|
||||
class AuthManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.auth = AuthManager()
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
import common
|
||||
|
||||
from twisted.internet import defer
|
||||
from twisted.trial import unittest
|
||||
|
||||
import deluge.tests.common as common
|
||||
from deluge import error
|
||||
from deluge.core.authmanager import AUTH_LEVEL_ADMIN
|
||||
from deluge.ui.client import client, Client, DaemonSSLProxy
|
||||
|
@ -23,6 +21,7 @@ class NoVersionSendingDaemonSSLProxy(DaemonSSLProxy):
|
|||
def __on_login_fail(self, result):
|
||||
self.login_deferred.errback(result)
|
||||
|
||||
|
||||
class NoVersionSendingClient(Client):
|
||||
|
||||
def connect(self, host="127.0.0.1", port=58846, username="", password="",
|
||||
|
@ -61,6 +60,7 @@ class NoVersionSendingClient(Client):
|
|||
if self.disconnect_callback:
|
||||
self.disconnect_callback()
|
||||
|
||||
|
||||
class ClientTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -100,7 +100,7 @@ class ClientTestCase(unittest.TestCase):
|
|||
from deluge.ui import common
|
||||
username, password = common.get_localhost_auth()
|
||||
d = client.connect(
|
||||
"localhost", 58846, username=username, password=password+'1'
|
||||
"localhost", 58846, username=username, password=password + "1"
|
||||
)
|
||||
|
||||
def on_failure(failure):
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from twisted.trial import unittest
|
||||
from deluge.common import *
|
||||
import os
|
||||
from twisted.trial import unittest
|
||||
from deluge.common import (setup_translations, VersionSplit, fsize, fpcnt, fspeed, fpeer,
|
||||
ftime, fdate, is_url, is_magnet, get_path_size, is_ip)
|
||||
|
||||
|
||||
class CommonTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
setup_translations()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
|
|
@ -2,6 +2,7 @@ from twisted.trial import unittest
|
|||
from twisted.internet import threads
|
||||
import deluge.component as component
|
||||
|
||||
|
||||
class testcomponent(component.Component):
|
||||
def __init__(self, name, depend=None):
|
||||
component.Component.__init__(self, name, depend=depend)
|
||||
|
@ -14,16 +15,19 @@ class testcomponent(component.Component):
|
|||
def stop(self):
|
||||
self.stop_count += 1
|
||||
|
||||
|
||||
class testcomponent_delaystart(testcomponent):
|
||||
def start(self):
|
||||
def do_sleep():
|
||||
import time
|
||||
time.sleep(1)
|
||||
d = threads.deferToThread(do_sleep)
|
||||
|
||||
def on_done(result):
|
||||
self.start_count += 1
|
||||
return d.addCallback(on_done)
|
||||
|
||||
|
||||
class testcomponent_update(component.Component):
|
||||
def __init__(self, name):
|
||||
component.Component.__init__(self, name)
|
||||
|
@ -37,6 +41,7 @@ class testcomponent_update(component.Component):
|
|||
def stop(self):
|
||||
self.stop_count += 1
|
||||
|
||||
|
||||
class testcomponent_shutdown(component.Component):
|
||||
def __init__(self, name):
|
||||
component.Component.__init__(self, name)
|
||||
|
@ -49,6 +54,7 @@ class testcomponent_shutdown(component.Component):
|
|||
def stop(self):
|
||||
self.stop_count += 1
|
||||
|
||||
|
||||
class ComponentTestClass(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
component.stop()
|
||||
|
@ -112,7 +118,7 @@ class ComponentTestClass(unittest.TestCase):
|
|||
return ret[0]
|
||||
|
||||
def test_register_exception(self):
|
||||
c1 = testcomponent("test_register_exception_c1")
|
||||
testcomponent("test_register_exception_c1")
|
||||
self.assertRaises(
|
||||
component.ComponentAlreadyRegistered,
|
||||
testcomponent,
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from twisted.trial import unittest
|
||||
from twisted.python.failure import Failure
|
||||
|
||||
import common
|
||||
import os
|
||||
|
||||
from twisted.trial import unittest
|
||||
from deluge.tests.common import set_tmp_config_dir
|
||||
from deluge.config import Config
|
||||
|
||||
DEFAULTS = {"string": "foobar", "int": 1, "float": 0.435, "bool": True, "unicode": u"foobar"}
|
||||
|
||||
|
||||
class ConfigTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.config_dir = common.set_tmp_config_dir()
|
||||
self.config_dir = set_tmp_config_dir()
|
||||
|
||||
def test_init(self):
|
||||
config = Config("test.conf", defaults=DEFAULTS, config_dir=self.config_dir)
|
||||
|
@ -26,12 +24,19 @@ class ConfigTestCase(unittest.TestCase):
|
|||
config["foo"] = 1
|
||||
self.assertEquals(config["foo"], 1)
|
||||
self.assertRaises(ValueError, config.set_item, "foo", "bar")
|
||||
|
||||
config["foo"] = 2
|
||||
self.assertEquals(config.get_item("foo"), 2)
|
||||
|
||||
config["foo"] = "3"
|
||||
self.assertEquals(config.get_item("foo"), 3)
|
||||
|
||||
config["unicode"] = u"ВИДЕОФИЛЬМЫ"
|
||||
self.assertEquals(config["unicode"], u"ВИДЕОФИЛЬМЫ")
|
||||
|
||||
config["unicode"] = "foostring"
|
||||
self.assertTrue(isinstance(config.get_item("unicode"), unicode))
|
||||
|
||||
config._save_timer.cancel()
|
||||
|
||||
def test_get(self):
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
import os
|
||||
import warnings
|
||||
|
||||
try:
|
||||
from hashlib import sha1 as sha
|
||||
except ImportError:
|
||||
from sha import sha
|
||||
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import reactor
|
||||
from twisted.python.failure import Failure
|
||||
|
@ -6,16 +14,7 @@ from twisted.web.resource import Resource
|
|||
from twisted.web.server import Site
|
||||
from twisted.web.static import File
|
||||
|
||||
try:
|
||||
from hashlib import sha1 as sha
|
||||
except ImportError:
|
||||
from sha import sha
|
||||
|
||||
import os
|
||||
import common
|
||||
import warnings
|
||||
rpath = common.rpath
|
||||
|
||||
import deluge.tests.common as common
|
||||
from deluge.core.rpcserver import RPCServer
|
||||
from deluge.core.core import Core
|
||||
warnings.filterwarnings("ignore", category=RuntimeWarning)
|
||||
|
@ -24,6 +23,9 @@ warnings.resetwarnings()
|
|||
import deluge.component as component
|
||||
import deluge.error
|
||||
|
||||
rpath = common.rpath
|
||||
|
||||
|
||||
class TestCookieResource(Resource):
|
||||
|
||||
def render(self, request):
|
||||
|
@ -34,6 +36,7 @@ class TestCookieResource(Resource):
|
|||
request.setHeader("Content-Type", "application/x-bittorrent")
|
||||
return open(rpath("ubuntu-9.04-desktop-i386.iso.torrent")).read()
|
||||
|
||||
|
||||
class TestPartialDownload(Resource):
|
||||
|
||||
def render(self, request):
|
||||
|
@ -44,12 +47,14 @@ class TestPartialDownload(Resource):
|
|||
return compress(data, request)
|
||||
return data
|
||||
|
||||
|
||||
class TestRedirectResource(Resource):
|
||||
|
||||
def render(self, request):
|
||||
request.redirect("/ubuntu-9.04-desktop-i386.iso.torrent")
|
||||
return ""
|
||||
|
||||
|
||||
class TopLevelResource(Resource):
|
||||
|
||||
addSlash = True
|
||||
|
@ -59,7 +64,9 @@ class TopLevelResource(Resource):
|
|||
self.putChild("cookie", TestCookieResource())
|
||||
self.putChild("partial", TestPartialDownload())
|
||||
self.putChild("redirect", TestRedirectResource())
|
||||
self.putChild("ubuntu-9.04-desktop-i386.iso.torrent", File(common.rpath("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")))
|
||||
|
||||
|
||||
class CoreTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -2,6 +2,7 @@ from twisted.trial import unittest
|
|||
|
||||
from deluge.decorators import proxy
|
||||
|
||||
|
||||
class DecoratorsTestCase(unittest.TestCase):
|
||||
def test_proxy_with_simple_functions(self):
|
||||
def negate(func, *args, **kwargs):
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import os
|
||||
import warnings
|
||||
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import reactor
|
||||
from twisted.python.failure import Failure
|
||||
from twisted.web.http import FORBIDDEN, NOT_MODIFIED
|
||||
from twisted.web.http import NOT_MODIFIED
|
||||
try:
|
||||
from twisted.web.resource import Resource, ForbiddenResource
|
||||
from twisted.web.resource import Resource
|
||||
except ImportError:
|
||||
# twisted 8
|
||||
from twisted.web.error import Resource, ForbiddenResource
|
||||
from twisted.web.error import Resource
|
||||
from twisted.web.server import Site
|
||||
|
||||
from deluge.httpdownloader import download_file
|
||||
|
@ -21,14 +20,16 @@ warnings.resetwarnings()
|
|||
|
||||
from email.utils import formatdate
|
||||
|
||||
import common
|
||||
import deluge.tests.common as common
|
||||
rpath = common.rpath
|
||||
|
||||
|
||||
class TestRedirectResource(Resource):
|
||||
|
||||
def render(self, request):
|
||||
request.redirect("http://localhost:51242/")
|
||||
|
||||
|
||||
class TestRenameResource(Resource):
|
||||
|
||||
def render(self, request):
|
||||
|
@ -38,6 +39,7 @@ class TestRenameResource(Resource):
|
|||
filename)
|
||||
return "This file should be called " + filename
|
||||
|
||||
|
||||
class TestCookieResource(Resource):
|
||||
|
||||
def render(self, request):
|
||||
|
@ -50,6 +52,7 @@ class TestCookieResource(Resource):
|
|||
|
||||
return request.getCookie("password")
|
||||
|
||||
|
||||
class TestGzipResource(Resource):
|
||||
|
||||
def render(self, request):
|
||||
|
@ -57,6 +60,7 @@ class TestGzipResource(Resource):
|
|||
request.setHeader("Content-Type", "text/plain")
|
||||
return compress(message, request)
|
||||
|
||||
|
||||
class TopLevelResource(Resource):
|
||||
|
||||
addSlash = True
|
||||
|
@ -79,6 +83,7 @@ class TopLevelResource(Resource):
|
|||
request.setResponseCode(NOT_MODIFIED)
|
||||
return "<h1>Deluge HTTP Downloader tests webserver here</h1>"
|
||||
|
||||
|
||||
class DownloadFileTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -3,6 +3,7 @@ from twisted.internet import defer
|
|||
from twisted.trial import unittest
|
||||
from deluge.log import setupLogger
|
||||
|
||||
|
||||
class LogTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
setupLogger(logging.DEBUG)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
from twisted.trial import unittest
|
||||
from twisted.python.failure import Failure
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
|
@ -14,7 +12,8 @@ def check_torrent(filename):
|
|||
|
||||
# Test loading with our internal TorrentInfo class
|
||||
from deluge.ui.common import TorrentInfo
|
||||
ti = TorrentInfo(filename)
|
||||
TorrentInfo(filename)
|
||||
|
||||
|
||||
class MakeTorrentTestCase(unittest.TestCase):
|
||||
def test_save_multifile(self):
|
||||
|
|
|
@ -4,6 +4,7 @@ from twisted.internet.defer import maybeDeferred, succeed
|
|||
import deluge.ui.sessionproxy
|
||||
import deluge.component as component
|
||||
|
||||
|
||||
class Core(object):
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
|
@ -70,18 +71,22 @@ class Core(object):
|
|||
self.prev_status[torrent] = dict(self.torrents[torrent])
|
||||
return succeed(ret)
|
||||
|
||||
|
||||
class Client(object):
|
||||
def __init__(self):
|
||||
self.core = Core()
|
||||
|
||||
def __noop__(self, *args, **kwargs):
|
||||
return None
|
||||
|
||||
def __getattr__(self, *args, **kwargs):
|
||||
return self.__noop__
|
||||
|
||||
client = Client()
|
||||
|
||||
deluge.ui.sessionproxy.client = client
|
||||
|
||||
|
||||
class SessionProxyTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.sp = deluge.ui.sessionproxy.SessionProxy()
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
|
||||
import deluge.core.torrent
|
||||
import test_torrent
|
||||
import common
|
||||
import deluge.tests.common as common
|
||||
from deluge.core.rpcserver import RPCServer
|
||||
from deluge.core.core import Core
|
||||
|
||||
|
@ -16,6 +16,7 @@ config_setup = False
|
|||
core = None
|
||||
rpcserver = None
|
||||
|
||||
|
||||
# This is called by torrent.py when calling component.get("...")
|
||||
def get(key):
|
||||
if key is "Core":
|
||||
|
@ -25,13 +26,15 @@ def get(key):
|
|||
else:
|
||||
return None
|
||||
|
||||
|
||||
class TorrentTestCase(unittest.TestCase):
|
||||
|
||||
def setup_config(self):
|
||||
global config_setup
|
||||
config_setup = True
|
||||
config_dir = common.set_tmp_config_dir()
|
||||
core_config = deluge.config.Config("core.conf", defaults=deluge.core.preferencesmanager.DEFAULT_PREFS, config_dir=config_dir)
|
||||
core_config = deluge.config.Config("core.conf", defaults=deluge.core.preferencesmanager.DEFAULT_PREFS,
|
||||
config_dir=config_dir)
|
||||
core_config.save()
|
||||
|
||||
def setUp(self):
|
||||
|
@ -52,6 +55,7 @@ class TorrentTestCase(unittest.TestCase):
|
|||
self.torrent.prev_status_cleanup_loop.stop()
|
||||
|
||||
deluge.core.torrent.component = self.original_component
|
||||
|
||||
def on_shutdown(result):
|
||||
component._ComponentRegistry.components = {}
|
||||
return component.shutdown().addCallback(on_shutdown)
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import os
|
||||
|
||||
from twisted.trial import unittest
|
||||
|
||||
from deluge.ui.tracker_icons import TrackerIcons, TrackerIcon
|
||||
from deluge.tests.common import set_tmp_config_dir
|
||||
|
||||
import common
|
||||
|
||||
common.set_tmp_config_dir()
|
||||
set_tmp_config_dir()
|
||||
icons = TrackerIcons()
|
||||
|
||||
dirname = os.path.dirname(__file__)
|
||||
|
@ -14,6 +11,7 @@ dirname = os.path.dirname(__file__)
|
|||
import deluge.ui.tracker_icons
|
||||
deluge.ui.tracker_icons.PIL_INSTALLED = False
|
||||
|
||||
|
||||
class TrackerIconsTestCase(unittest.TestCase):
|
||||
|
||||
def test_get_deluge_png(self):
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
|
||||
from twisted.trial import unittest
|
||||
|
||||
from deluge.transfer import DelugeTransferProtocol
|
||||
|
||||
import base64
|
||||
|
||||
from twisted.trial import unittest
|
||||
import deluge.rencode as rencode
|
||||
from deluge.transfer import DelugeTransferProtocol
|
||||
import deluge.log
|
||||
|
||||
deluge.log.setupLogger("none")
|
||||
|
||||
class TransferTestClass(DelugeTransferProtocol):
|
||||
|
||||
|
@ -77,7 +77,6 @@ class TransferTestClass(DelugeTransferProtocol):
|
|||
:param data: a zlib compressed string encoded with rencode.
|
||||
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import zlib
|
||||
print "\n=== New Data Received ===\nBytes received:", len(data)
|
||||
|
||||
|
@ -109,8 +108,8 @@ class TransferTestClass(DelugeTransferProtocol):
|
|||
try:
|
||||
request = rencode.loads(dobj.decompress(data))
|
||||
print "Successfully loaded message",
|
||||
print " - Buffer length: %d, data length: %d, unused length: %d" % (len(data), \
|
||||
len(data) - len(dobj.unused_data), len(dobj.unused_data))
|
||||
print " - Buffer length: %d, data length: %d, unused length: %d" % \
|
||||
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data))
|
||||
print "Packet count:", self.packet_count
|
||||
except Exception, e:
|
||||
#log.debug("Received possible invalid message (%r): %s", data, e)
|
||||
|
@ -125,6 +124,7 @@ class TransferTestClass(DelugeTransferProtocol):
|
|||
|
||||
self.message_received(request)
|
||||
|
||||
|
||||
class DelugeTransferProtocolTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -191,7 +191,8 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
and lets DelugeTransferProtocol receive the data as one string.
|
||||
|
||||
"""
|
||||
two_concatenated = base64.b64decode(self.msg1_expected_compressed_base64) + base64.b64decode(self.msg2_expected_compressed_base64)
|
||||
two_concatenated = base64.b64decode(self.msg1_expected_compressed_base64) + \
|
||||
base64.b64decode(self.msg2_expected_compressed_base64)
|
||||
self.transfer.dataReceived(two_concatenated)
|
||||
|
||||
# Get the data as sent by DelugeTransferProtocol
|
||||
|
@ -212,8 +213,10 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
packet_size = 40
|
||||
|
||||
one_message_byte_count = len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
two_messages_byte_count = one_message_byte_count + len(base64.b64decode(self.msg2_expected_compressed_base64))
|
||||
three_messages_byte_count = two_messages_byte_count + len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
two_messages_byte_count = one_message_byte_count + \
|
||||
len(base64.b64decode(self.msg2_expected_compressed_base64))
|
||||
three_messages_byte_count = two_messages_byte_count + \
|
||||
len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
|
||||
for d in self.receive_parts_helper(msg_bytes, packet_size):
|
||||
bytes_received = self.transfer.get_bytes_recv()
|
||||
|
@ -237,7 +240,6 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
message3 = self.transfer.get_messages_in().pop(0)
|
||||
self.assertEquals(rencode.dumps(self.msg1), rencode.dumps(message3))
|
||||
|
||||
|
||||
# Remove underscore to enable test, or run the test directly:
|
||||
# tests $ trial test_transfer.DelugeTransferProtocolTestCase._test_rencode_fail_protocol
|
||||
def _test_rencode_fail_protocol(self):
|
||||
|
@ -251,8 +253,10 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
packet_size = 149
|
||||
|
||||
one_message_byte_count = len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
two_messages_byte_count = one_message_byte_count + len(base64.b64decode(self.msg2_expected_compressed_base64))
|
||||
three_messages_byte_count = two_messages_byte_count + len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
two_messages_byte_count = one_message_byte_count + \
|
||||
len(base64.b64decode(self.msg2_expected_compressed_base64))
|
||||
three_messages_byte_count = two_messages_byte_count + \
|
||||
len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
|
||||
print
|
||||
|
||||
|
@ -277,8 +281,8 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
expected_msgs_received_count = 0
|
||||
# Verify that the expected number of complete messages has arrived
|
||||
if expected_msgs_received_count != len(self.transfer.get_messages_in()):
|
||||
print "Expected number of messages received is %d, but %d have been received."\
|
||||
% (expected_msgs_received_count, len(self.transfer.get_messages_in()))
|
||||
print "Expected number of messages received is %d, but %d have been received." % \
|
||||
(expected_msgs_received_count, len(self.transfer.get_messages_in()))
|
||||
|
||||
# Get the data as received by DelugeTransferProtocol
|
||||
message1 = self.transfer.get_messages_in().pop(0)
|
||||
|
@ -288,7 +292,6 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
message3 = self.transfer.get_messages_in().pop(0)
|
||||
self.assertEquals(rencode.dumps(self.msg1), rencode.dumps(message3))
|
||||
|
||||
|
||||
def test_receive_middle_of_header(self):
|
||||
"""
|
||||
This test concatenates two messsages (as they're sent over the network),
|
||||
|
@ -301,7 +304,8 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
to read and parse the size of the payload.
|
||||
|
||||
"""
|
||||
two_concatenated = base64.b64decode(self.msg1_expected_compressed_base64) + base64.b64decode(self.msg2_expected_compressed_base64)
|
||||
two_concatenated = base64.b64decode(self.msg1_expected_compressed_base64) + \
|
||||
base64.b64decode(self.msg2_expected_compressed_base64)
|
||||
first_len = len(base64.b64decode(self.msg1_expected_compressed_base64))
|
||||
|
||||
# Now found the entire first message, and half the header of the next message (2 bytes into the header)
|
||||
|
@ -322,7 +326,6 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
message2 = self.transfer.get_messages_in().pop(0)
|
||||
self.assertEquals(rencode.dumps(self.msg2), rencode.dumps(message2))
|
||||
|
||||
|
||||
# Needs file containing big data structure e.g. like thetorrent list as it is transfered by the daemon
|
||||
#def test_simulate_big_transfer(self):
|
||||
# filename = "../deluge.torrentlist"
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from twisted.trial import unittest
|
||||
import os
|
||||
import os.path
|
||||
from deluge.ui.common import TorrentInfo
|
||||
|
||||
|
||||
class UICommonTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
|
@ -13,18 +14,18 @@ class UICommonTestCase(unittest.TestCase):
|
|||
def test_utf8_encoded_paths(self):
|
||||
filename = os.path.join(os.path.dirname(__file__), "test.torrent")
|
||||
ti = TorrentInfo(filename)
|
||||
self.assertTrue(ti.files_tree.has_key("azcvsupdater_2.6.2.jar"))
|
||||
self.assertTrue("azcvsupdater_2.6.2.jar" in ti.files_tree)
|
||||
|
||||
def test_utf8_encoded_paths2(self):
|
||||
filename = os.path.join(os.path.dirname(__file__), "unicode_filenames.torrent")
|
||||
ti = TorrentInfo(filename)
|
||||
|
||||
files = ti.files_tree["unicode_filenames"]
|
||||
self.assertTrue(files.has_key("\xe3\x83\x86\xe3\x82\xaf\xe3\x82\xb9\xe3\x83\xbb\xe3\x83"
|
||||
"\x86\xe3\x82\xaf\xe3\x82\xb5\xe3\x83\xb3.mkv"))
|
||||
self.assertTrue(files.has_key("\xd0\x9c\xd0\xb8\xd1\x85\xd0\xb0\xd0\xb8\xd0\xbb \xd0\x93"
|
||||
"\xd0\xbe\xd1\x80\xd0\xb1\xd0\xb0\xd1\x87\xd1\x91\xd0\xb2.mkv"))
|
||||
self.assertTrue(files.has_key("Alisher ibn G'iyosiddin Navoiy.mkv"))
|
||||
self.assertTrue(files.has_key("Ascii title.mkv"))
|
||||
self.assertTrue(files.has_key("\xe0\xa6\xb8\xe0\xa7\x81\xe0\xa6\x95\xe0\xa7\x81\xe0\xa6"
|
||||
"\xae\xe0\xa6\xbe\xe0\xa6\xb0 \xe0\xa6\xb0\xe0\xa6\xbe\xe0\xa7\x9f.mkv"))
|
||||
self.assertTrue("\xe3\x83\x86\xe3\x82\xaf\xe3\x82\xb9\xe3\x83\xbb\xe3\x83"
|
||||
"\x86\xe3\x82\xaf\xe3\x82\xb5\xe3\x83\xb3.mkv" in files)
|
||||
self.assertTrue("\xd0\x9c\xd0\xb8\xd1\x85\xd0\xb0\xd0\xb8\xd0\xbb \xd0\x93"
|
||||
"\xd0\xbe\xd1\x80\xd0\xb1\xd0\xb0\xd1\x87\xd1\x91\xd0\xb2.mkv" in files)
|
||||
self.assertTrue("Alisher ibn G'iyosiddin Navoiy.mkv" in files)
|
||||
self.assertTrue("Ascii title.mkv" in files)
|
||||
self.assertTrue("\xe0\xa6\xb8\xe0\xa7\x81\xe0\xa6\x95\xe0\xa7\x81\xe0\xa6"
|
||||
"\xae\xe0\xa6\xbe\xe0\xa6\xb0 \xe0\xa6\xb0\xe0\xa6\xbe\xe0\xa7\x9f.mkv" in files)
|
||||
|
|
Loading…
Reference in New Issue