test_cli.py: factor out CLITestMixin
authorBrian Warner <warner@lothar.com>
Sat, 2 Aug 2008 02:29:38 +0000 (19:29 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 2 Aug 2008 02:29:38 +0000 (19:29 -0700)
src/allmydata/test/test_cli.py

index fb59478b3b9fb17d5143e4c7bb34bd798669babd..d7a62e840a86f86d8f75637460354f3ce988e0ab 100644 (file)
@@ -217,8 +217,7 @@ class CLI(unittest.TestCase):
         self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
         self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
 
-class CreateAlias(SystemTestMixin, unittest.TestCase):
-
+class CLITestMixin:
     def do_cli(self, verb, *args, **kwargs):
         nodeargs = [
             "--node-directory", self.getdir("client0"),
@@ -234,6 +233,8 @@ class CreateAlias(SystemTestMixin, unittest.TestCase):
         d.addCallback(_done)
         return d
 
+class CreateAlias(SystemTestMixin, CLITestMixin, unittest.TestCase):
+
     def test_create(self):
         self.basedir = os.path.dirname(self.mktemp())
         d = self.set_up_nodes()
@@ -247,22 +248,7 @@ class CreateAlias(SystemTestMixin, unittest.TestCase):
         d.addCallback(_done)
         return d
 
-class Put(SystemTestMixin, unittest.TestCase):
-
-    def do_cli(self, verb, *args, **kwargs):
-        nodeargs = [
-            "--node-directory", self.getdir("client0"),
-            ]
-        argv = [verb] + nodeargs + list(args)
-        stdin = kwargs.get("stdin", "")
-        stdout, stderr = StringIO(), StringIO()
-        d = threads.deferToThread(runner.runner, argv, run_by_human=False,
-                                  stdin=StringIO(stdin),
-                                  stdout=stdout, stderr=stderr)
-        def _done(res):
-            return stdout.getvalue(), stderr.getvalue()
-        d.addCallback(_done)
-        return d
+class Put(SystemTestMixin, CLITestMixin, unittest.TestCase):
 
     def test_unlinked_immutable_stdin(self):
         # tahoe get `echo DATA | tahoe put`