[Tests] Fix tests to run on Twisted < 13
* Also includes pylint fixes for W0233(non-parent-init-called) * Remove failing openbittorent icon test
This commit is contained in:
parent
d579efa041
commit
81334389a9
|
@ -1,4 +1,5 @@
|
||||||
from twisted.internet import defer, threads
|
from twisted.internet import defer, threads
|
||||||
|
from twisted.trial.unittest import SkipTest
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
|
||||||
|
@ -200,7 +201,10 @@ class ComponentTestClass(BaseTestCase):
|
||||||
yield component.start(["test_pause_c1"])
|
yield component.start(["test_pause_c1"])
|
||||||
yield component.pause(["test_pause_c1"])
|
yield component.pause(["test_pause_c1"])
|
||||||
test_comp = component.get("test_pause_c1")
|
test_comp = component.get("test_pause_c1")
|
||||||
|
try:
|
||||||
result = self.failureResultOf(test_comp._component_start())
|
result = self.failureResultOf(test_comp._component_start())
|
||||||
|
except AttributeError:
|
||||||
|
raise SkipTest("This test requires trial failureResultOf() in Twisted version >= 13")
|
||||||
self.assertEqual(result.check(component.ComponentException), component.ComponentException)
|
self.assertEqual(result.check(component.ComponentException), component.ComponentException)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from twisted.trial.unittest import SkipTest
|
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.ui.tracker_icons
|
import deluge.ui.tracker_icons
|
||||||
|
@ -58,15 +57,6 @@ class TrackerIconsTestCase(BaseTestCase):
|
||||||
d.addCallback(self.assertEquals, icon)
|
d.addCallback(self.assertEquals, icon)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_get_openbt_png(self):
|
|
||||||
raise SkipTest("openbittorrent.com site is down, possibly permanently")
|
|
||||||
# openbittorrent.com has an incorrect type (image/gif) pylint: disable=unreachable
|
|
||||||
icon = TrackerIcon(os.path.join(dirname, "openbt.png"))
|
|
||||||
d = self.icons.fetch("openbittorrent.com")
|
|
||||||
d.addCallback(self.assertNotIdentical, None)
|
|
||||||
d.addCallback(self.assertEquals, icon)
|
|
||||||
return d
|
|
||||||
|
|
||||||
def test_get_empty_string_tracker(self):
|
def test_get_empty_string_tracker(self):
|
||||||
d = self.icons.fetch("")
|
d = self.icons.fetch("")
|
||||||
d.addCallback(self.assertIdentical, None)
|
d.addCallback(self.assertIdentical, None)
|
||||||
|
|
|
@ -17,7 +17,6 @@ import sys
|
||||||
import mock
|
import mock
|
||||||
import pytest
|
import pytest
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from twisted.logger import Logger
|
|
||||||
|
|
||||||
import deluge
|
import deluge
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -32,8 +31,6 @@ from . import common
|
||||||
from .basetest import BaseTestCase
|
from .basetest import BaseTestCase
|
||||||
from .daemon_base import DaemonBase
|
from .daemon_base import DaemonBase
|
||||||
|
|
||||||
log = Logger()
|
|
||||||
|
|
||||||
DEBUG_COMMAND = False
|
DEBUG_COMMAND = False
|
||||||
|
|
||||||
sys_stdout = sys.stdout
|
sys_stdout = sys.stdout
|
||||||
|
@ -165,8 +162,9 @@ class GtkUIBaseTestCase(UIBaseTestCase):
|
||||||
class GtkUIDelugeScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
|
class GtkUIDelugeScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(GtkUIDelugeScriptEntryTestCase, self).__init__(testname)
|
||||||
GtkUIBaseTestCase.__init__(self)
|
GtkUIBaseTestCase.__init__(self)
|
||||||
|
|
||||||
self.var["cmd_name"] = "deluge gtk"
|
self.var["cmd_name"] = "deluge gtk"
|
||||||
self.var["start_cmd"] = ui_entry.start_ui
|
self.var["start_cmd"] = ui_entry.start_ui
|
||||||
self.var["sys_arg_cmd"] = ["./deluge", "gtk"]
|
self.var["sys_arg_cmd"] = ["./deluge", "gtk"]
|
||||||
|
@ -182,7 +180,7 @@ class GtkUIDelugeScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
|
||||||
class GtkUIScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
|
class GtkUIScriptEntryTestCase(BaseTestCase, GtkUIBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(GtkUIScriptEntryTestCase, self).__init__(testname)
|
||||||
GtkUIBaseTestCase.__init__(self)
|
GtkUIBaseTestCase.__init__(self)
|
||||||
from deluge.ui import gtkui
|
from deluge.ui import gtkui
|
||||||
self.var["cmd_name"] = "deluge-gtk"
|
self.var["cmd_name"] = "deluge-gtk"
|
||||||
|
@ -231,7 +229,7 @@ class WebUIBaseTestCase(UIBaseTestCase):
|
||||||
class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
|
class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(WebUIScriptEntryTestCase, self).__init__(testname)
|
||||||
WebUIBaseTestCase.__init__(self)
|
WebUIBaseTestCase.__init__(self)
|
||||||
self.var["cmd_name"] = "deluge-web"
|
self.var["cmd_name"] = "deluge-web"
|
||||||
self.var["start_cmd"] = deluge.ui.web.start
|
self.var["start_cmd"] = deluge.ui.web.start
|
||||||
|
@ -247,7 +245,7 @@ class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
|
||||||
class WebUIDelugeScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
|
class WebUIDelugeScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(WebUIDelugeScriptEntryTestCase, self).__init__(testname)
|
||||||
WebUIBaseTestCase.__init__(self)
|
WebUIBaseTestCase.__init__(self)
|
||||||
self.var["cmd_name"] = "deluge web"
|
self.var["cmd_name"] = "deluge web"
|
||||||
self.var["start_cmd"] = ui_entry.start_ui
|
self.var["start_cmd"] = ui_entry.start_ui
|
||||||
|
@ -368,7 +366,7 @@ Total torrents: 0
|
||||||
class ConsoleScriptEntryWithDaemonTestCase(BaseTestCase, ConsoleUIWithDaemonBaseTestCase):
|
class ConsoleScriptEntryWithDaemonTestCase(BaseTestCase, ConsoleUIWithDaemonBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(ConsoleScriptEntryWithDaemonTestCase, self).__init__(testname)
|
||||||
ConsoleUIWithDaemonBaseTestCase.__init__(self)
|
ConsoleUIWithDaemonBaseTestCase.__init__(self)
|
||||||
self.var["cmd_name"] = "deluge-console"
|
self.var["cmd_name"] = "deluge-console"
|
||||||
self.var["sys_arg_cmd"] = ["./deluge-console"]
|
self.var["sys_arg_cmd"] = ["./deluge-console"]
|
||||||
|
@ -391,7 +389,7 @@ class ConsoleScriptEntryWithDaemonTestCase(BaseTestCase, ConsoleUIWithDaemonBase
|
||||||
class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
|
class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(ConsoleScriptEntryTestCase, self).__init__(testname)
|
||||||
ConsoleUIBaseTestCase.__init__(self)
|
ConsoleUIBaseTestCase.__init__(self)
|
||||||
self.var["cmd_name"] = "deluge-console"
|
self.var["cmd_name"] = "deluge-console"
|
||||||
self.var["start_cmd"] = deluge.ui.console.start
|
self.var["start_cmd"] = deluge.ui.console.start
|
||||||
|
@ -407,7 +405,7 @@ class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
|
||||||
class ConsoleDelugeScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
|
class ConsoleDelugeScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
|
||||||
|
|
||||||
def __init__(self, testname):
|
def __init__(self, testname):
|
||||||
BaseTestCase.__init__(self, testname)
|
super(ConsoleDelugeScriptEntryTestCase, self).__init__(testname)
|
||||||
ConsoleUIBaseTestCase.__init__(self)
|
ConsoleUIBaseTestCase.__init__(self)
|
||||||
self.var["cmd_name"] = "deluge console"
|
self.var["cmd_name"] = "deluge console"
|
||||||
self.var["start_cmd"] = ui_entry.start_ui
|
self.var["start_cmd"] = ui_entry.start_ui
|
||||||
|
|
|
@ -12,6 +12,7 @@ from StringIO import StringIO
|
||||||
|
|
||||||
import twisted.web.client
|
import twisted.web.client
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
|
from twisted.trial.unittest import SkipTest
|
||||||
from twisted.web.client import Agent, FileBodyProducer
|
from twisted.web.client import Agent, FileBodyProducer
|
||||||
from twisted.web.http_headers import Headers
|
from twisted.web.http_headers import Headers
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ class WebServerTestCase(WebServerTestBase, WebServerMockBase):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_get_torrent_info(self):
|
def test_get_torrent_info(self):
|
||||||
|
|
||||||
agent = Agent(reactor)
|
agent = Agent(reactor)
|
||||||
|
|
||||||
self.mock_authentication_ignore(self.deluge_web.auth)
|
self.mock_authentication_ignore(self.deluge_web.auth)
|
||||||
|
@ -42,7 +44,10 @@ class WebServerTestCase(WebServerTestBase, WebServerMockBase):
|
||||||
Headers({'User-Agent': ['Twisted Web Client Example'],
|
Headers({'User-Agent': ['Twisted Web Client Example'],
|
||||||
'Content-Type': ['application/json']}),
|
'Content-Type': ['application/json']}),
|
||||||
FileBodyProducer(StringIO('{"params": ["%s"], "method": "web.get_torrent_info", "id": 22}' % filename)))
|
FileBodyProducer(StringIO('{"params": ["%s"], "method": "web.get_torrent_info", "id": 22}' % filename)))
|
||||||
|
try:
|
||||||
body = yield twisted.web.client.readBody(d)
|
body = yield twisted.web.client.readBody(d)
|
||||||
|
except AttributeError:
|
||||||
|
raise SkipTest("This test requires 't.w.c.readBody()' in Twisted version >= 13.2")
|
||||||
|
|
||||||
json = json_lib.loads(body)
|
json = json_lib.loads(body)
|
||||||
self.assertEqual(None, json["error"])
|
self.assertEqual(None, json["error"])
|
||||||
|
|
Loading…
Reference in New Issue