]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_client.py: improve test coverage a bit
authorBrian Warner <warner@allmydata.com>
Fri, 8 Jun 2007 05:09:02 +0000 (22:09 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 8 Jun 2007 05:09:02 +0000 (22:09 -0700)
src/allmydata/test/test_client.py

index 2f42468972bda1b8b0e9af1d6b3a7768ed251eba..167454cc8126d98558fb35c791813f6f32452f37 100644 (file)
@@ -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
+