]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add some passing unit tests for testutil.PollMixin.
authornejucomo <nejucomo@gmail.com>
Fri, 7 Sep 2007 23:15:41 +0000 (16:15 -0700)
committernejucomo <nejucomo@gmail.com>
Fri, 7 Sep 2007 23:15:41 +0000 (16:15 -0700)
src/allmydata/test/test_util.py

index 118dd6a799b8304e6cf9e7c3d18a2b172e3f2590..9e9ba3d42a34ff6208c8f0164b1cc91d179ded27 100644 (file)
@@ -5,7 +5,7 @@ import os
 from twisted.trial import unittest
 
 from allmydata.util import bencode, idlib, humanreadable, mathutil
-from allmydata.util import assertutil, fileutil
+from allmydata.util import assertutil, fileutil, testutil
 
 
 class IDLib(unittest.TestCase):
@@ -368,3 +368,23 @@ class FileUtil(unittest.TestCase):
         used = fileutil.du(basedir)
         self.failUnlessEqual(10+11+12+13, used)
 
+class PollMixinTests(unittest.TestCase):
+    def setUp(self):
+        self.pm = testutil.PollMixin()
+
+    def _check(self, d):
+        def fail_unless_arg_is_true(arg):
+            self.failUnless(arg is True, repr(arg))
+        d.addCallback(fail_unless_arg_is_true)
+        return d
+
+    def test_PollMixin_True(self):
+        d = self.pm.poll(check_f=lambda : True,
+                         pollinterval=0.1)
+        return self._check(d)
+
+    def test_PollMixin_False_then_True(self):
+        i = iter([False, True])
+        d = self.pm.poll(check_f=i.next,
+                         pollinterval=0.1)
+        return self._check(d)