mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-27 06:20:25 +00:00
test_runner.py: add some coverage for allmydata.scripts.runner, to create nodes
This commit is contained in:
parent
be8eeadb7a
commit
491f96258e
@ -89,16 +89,16 @@ class Options(usage.Options):
|
|||||||
if not hasattr(self, 'subOptions'):
|
if not hasattr(self, 'subOptions'):
|
||||||
raise usage.UsageError("must specify a command")
|
raise usage.UsageError("must specify a command")
|
||||||
|
|
||||||
def run():
|
def runner(argv):
|
||||||
config = Options()
|
config = Options()
|
||||||
try:
|
try:
|
||||||
config.parseOptions()
|
config.parseOptions(argv)
|
||||||
except usage.error, e:
|
except usage.error, e:
|
||||||
print "%s: %s" % (sys.argv[0], e)
|
print "%s: %s" % (sys.argv[0], e)
|
||||||
print
|
print
|
||||||
c = getattr(config, 'subOptions', config)
|
c = getattr(config, 'subOptions', config)
|
||||||
print str(c)
|
print str(c)
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
|
||||||
command = config.subCommand
|
command = config.subCommand
|
||||||
so = config.subOptions
|
so = config.subOptions
|
||||||
@ -114,6 +114,10 @@ def run():
|
|||||||
elif command == "restart":
|
elif command == "restart":
|
||||||
rc = restart(so)
|
rc = restart(so)
|
||||||
rc = rc or 0
|
rc = rc or 0
|
||||||
|
return rc
|
||||||
|
|
||||||
|
def run():
|
||||||
|
rc = runner(sys.argv[1:])
|
||||||
sys.exit(rc)
|
sys.exit(rc)
|
||||||
|
|
||||||
def create_client(config):
|
def create_client(config):
|
||||||
|
29
src/allmydata/test/test_runner.py
Normal file
29
src/allmydata/test/test_runner.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
from twisted.trial import unittest
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
from allmydata.scripts import runner
|
||||||
|
from allmydata.util import fileutil
|
||||||
|
|
||||||
|
class CreateNode(unittest.TestCase):
|
||||||
|
def workdir(self, name):
|
||||||
|
basedir = os.path.join("test_runner", name)
|
||||||
|
fileutil.make_dirs(basedir)
|
||||||
|
return basedir
|
||||||
|
|
||||||
|
def test_client(self):
|
||||||
|
basedir = self.workdir("test_client")
|
||||||
|
c1 = os.path.join(basedir, "c1")
|
||||||
|
argv = ["create-client", "--basedir", c1]
|
||||||
|
runner.runner(argv)
|
||||||
|
self.failUnless(os.path.exists(c1))
|
||||||
|
self.failUnless(os.path.exists(os.path.join(c1, "client.tac")))
|
||||||
|
|
||||||
|
def test_introducer(self):
|
||||||
|
basedir = self.workdir("test_introducer")
|
||||||
|
c1 = os.path.join(basedir, "c1")
|
||||||
|
argv = ["create-introducer", "--basedir", c1]
|
||||||
|
runner.runner(argv)
|
||||||
|
self.failUnless(os.path.exists(c1))
|
||||||
|
self.failUnless(os.path.exists(os.path.join(c1, "introducer.tac")))
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user