import allmydata
from allmydata import client, introducer
-from allmydata.util import base32
+from allmydata.util import base32, testutil
from foolscap.eventual import flushEventualQueue
class FakeIntroducerClient(introducer.IntroducerClient):
d.addCallback(_done)
return d
-class Run(unittest.TestCase):
+class Run(unittest.TestCase, testutil.StallMixin):
def setUp(self):
self.sparent = service.MultiService()
open(os.path.join(basedir, "suicide_prevention_hotline"), "w")
c = client.Client(basedir)
- def stall(self, res=None, delay=1):
- d = defer.Deferred()
- reactor.callLater(delay, d.callback, res)
- return d
-
def test_reloadable(self):
basedir = "test_client.Run.test_reloadable"
os.mkdir(basedir)
return d
-class Dirnode(unittest.TestCase, testutil.ShouldFailMixin):
+class Dirnode(unittest.TestCase, testutil.ShouldFailMixin, testutil.StallMixin):
def setUp(self):
self.client = FakeClient()
def failUnlessGreaterOrEqualThan(self, a, b):
self.failUnless(a >= b, "%r should be >= %r" % (a, b))
- def stall(self, res, delay=1.0):
- d = defer.Deferred()
- reactor.callLater(delay, d.callback, res)
- return d
-
def test_create(self):
self.expected_manifest = []
return upload.Data.read(self, length)
-class SystemTest(testutil.SignalMixin, testutil.PollMixin, unittest.TestCase):
+class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
+ unittest.TestCase):
def setUp(self):
self.sparent = service.MultiService()
log.msg(msg, **kwargs)
return res
- def stall(self, res, delay=1.0):
- d = defer.Deferred()
- reactor.callLater(delay, d.callback, res)
- return d
-
def _do_publish_private(self, res):
self.smalldata = "sssh, very secret stuff"
ut = upload.Data(self.smalldata, convergence=None)
if check_f():
lc.stop()
+class StallMixin:
+ def stall(self, res=None, delay=1):
+ d = defer.Deferred()
+ reactor.callLater(delay, d.callback, res)
+ return d
+
class ShouldFailMixin:
def shouldFail(self, expected_failure, which, substring,