mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 13:56:47 +00:00
Merge branch 'master' of deluge-torrent.org:deluge
This commit is contained in:
commit
4b9209674e
@ -1,6 +1,10 @@
|
|||||||
import tempfile
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
import signal
|
import signal
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
import common
|
import common
|
||||||
|
|
||||||
@ -8,20 +12,48 @@ from twisted.trial import unittest
|
|||||||
|
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
# Start a daemon to test with and wait a couple seconds to make sure it's started
|
CWD = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||||
config_directory = common.set_tmp_config_dir()
|
|
||||||
client.start_daemon(58847, config_directory)
|
|
||||||
import time
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
|
DAEMON_SCRIPT = """
|
||||||
|
import sys
|
||||||
|
import deluge.main
|
||||||
|
|
||||||
|
sys.argv.extend(['-d', '-c', '%s', '-Linfo'])
|
||||||
|
|
||||||
|
deluge.main.start_daemon()
|
||||||
|
"""
|
||||||
|
|
||||||
class ClientTestCase(unittest.TestCase):
|
class ClientTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
config_directory = common.set_tmp_config_dir()
|
||||||
|
|
||||||
|
fp = tempfile.TemporaryFile()
|
||||||
|
fp.write(DAEMON_SCRIPT % config_directory)
|
||||||
|
fp.seek(0)
|
||||||
|
|
||||||
|
self.core = Popen([sys.executable], cwd=CWD,
|
||||||
|
stdin=fp, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
|
listening = False
|
||||||
|
while not listening:
|
||||||
|
line = self.core.stderr.readline()
|
||||||
|
if "Factory starting on 58846" in line:
|
||||||
|
listening = True
|
||||||
|
time.sleep(0.1) # Slight pause just incase
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.core.terminate()
|
||||||
|
|
||||||
def test_connect_no_credentials(self):
|
def test_connect_no_credentials(self):
|
||||||
d = client.connect("localhost", 58847)
|
d = client.connect("localhost", 58846)
|
||||||
d.addCallback(self.assertEquals, 10)
|
d.addCallback(self.assertEquals, 10)
|
||||||
|
|
||||||
def on_connect(result):
|
def on_connect(result):
|
||||||
self.addCleanup(client.disconnect)
|
self.addCleanup(client.disconnect)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
d.addCallback(on_connect)
|
d.addCallback(on_connect)
|
||||||
return d
|
return d
|
||||||
|
Loading…
x
Reference in New Issue
Block a user