mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 19:26:25 +00:00
test_client.py: improve test coverage a bit
This commit is contained in:
parent
243300f843
commit
6df5c856ac
@ -1,10 +1,12 @@
|
||||
|
||||
import os
|
||||
from twisted.trial import unittest
|
||||
from twisted.application import service
|
||||
|
||||
import allmydata
|
||||
from allmydata import client, introducer
|
||||
from allmydata.util import version
|
||||
from foolscap.eventual import flushEventualQueue
|
||||
|
||||
class MyIntroducerClient(introducer.IntroducerClient):
|
||||
def __init__(self):
|
||||
@ -56,3 +58,44 @@ class Basic(unittest.TestCase):
|
||||
mine, oldest = c.remote_get_versions()
|
||||
self.failUnlessEqual(version.Version(mine), allmydata.__version__)
|
||||
|
||||
def flush_but_dont_ignore(res):
|
||||
d = flushEventualQueue()
|
||||
def _done(ignored):
|
||||
return res
|
||||
d.addCallback(_done)
|
||||
return d
|
||||
|
||||
class Run(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.sparent = service.MultiService()
|
||||
self.sparent.startService()
|
||||
def tearDown(self):
|
||||
d = self.sparent.stopService()
|
||||
d.addBoth(flush_but_dont_ignore)
|
||||
return d
|
||||
|
||||
def test_loadable(self):
|
||||
basedir = "test_client.Run.test_loadable"
|
||||
os.mkdir(basedir)
|
||||
dummy = "pb://wl74cyahejagspqgy4x5ukrvfnevlknt@127.0.0.1:58889/bogus"
|
||||
open(os.path.join(basedir, "introducer.furl"), "w").write(dummy)
|
||||
open(os.path.join(basedir, "suicide_prevention_hotline"), "w")
|
||||
c = client.Client(basedir)
|
||||
|
||||
def test_reloadable(self):
|
||||
basedir = "test_client.Run.test_reloadable"
|
||||
os.mkdir(basedir)
|
||||
dummy = "pb://wl74cyahejagspqgy4x5ukrvfnevlknt@127.0.0.1:58889/bogus"
|
||||
open(os.path.join(basedir, "introducer.furl"), "w").write(dummy)
|
||||
c1 = client.Client(basedir)
|
||||
c1.setServiceParent(self.sparent)
|
||||
|
||||
d = c1.disownServiceParent()
|
||||
def _restart(res):
|
||||
c2 = client.Client(basedir)
|
||||
c2.setServiceParent(self.sparent)
|
||||
return c2.disownServiceParent()
|
||||
d.addCallback(_restart)
|
||||
return d
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user