2007-10-11 07:30:36 +00:00
|
|
|
|
|
|
|
from twisted.trial import unittest
|
|
|
|
|
|
|
|
from allmydata.util import fileutil
|
|
|
|
from allmydata import uri
|
|
|
|
|
|
|
|
# at least import the CLI scripts, even if we don't have any real tests for
|
|
|
|
# them yet.
|
|
|
|
|
|
|
|
from allmydata.scripts import cli, tahoe_ls, tahoe_get, tahoe_put, tahoe_rm
|
2007-10-11 08:55:29 +00:00
|
|
|
_hush_pyflakes = [tahoe_ls, tahoe_get, tahoe_put, tahoe_rm]
|
2007-10-11 07:30:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CLI(unittest.TestCase):
|
|
|
|
def test_options(self):
|
|
|
|
fileutil.rm_dir("cli/test_options")
|
|
|
|
fileutil.make_dirs("cli/test_options")
|
2008-01-04 00:48:53 +00:00
|
|
|
fileutil.make_dirs("cli/test_options/private")
|
2007-10-11 07:30:36 +00:00
|
|
|
open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
|
2007-12-05 00:00:58 +00:00
|
|
|
filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
|
|
|
|
fingerprint="\x00"*32)
|
|
|
|
private_uri = uri.NewDirectoryURI(filenode_uri).to_string()
|
2008-01-04 00:48:53 +00:00
|
|
|
open("cli/test_options/private/root_dir.cap", "w").write(private_uri + "\n")
|
2007-10-11 07:30:36 +00:00
|
|
|
o = cli.ListOptions()
|
|
|
|
o.parseOptions(["--node-directory", "cli/test_options"])
|
|
|
|
self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
|
2008-01-04 00:02:05 +00:00
|
|
|
self.failUnlessEqual(o['dir-uri'], private_uri)
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['vdrive_pathname'], "")
|
|
|
|
|
|
|
|
o = cli.ListOptions()
|
|
|
|
o.parseOptions(["--node-directory", "cli/test_options",
|
|
|
|
"--node-url", "http://example.org:8111/"])
|
|
|
|
self.failUnlessEqual(o['node-url'], "http://example.org:8111/")
|
2008-01-04 00:02:05 +00:00
|
|
|
self.failUnlessEqual(o['dir-uri'], private_uri)
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['vdrive_pathname'], "")
|
|
|
|
|
|
|
|
o = cli.ListOptions()
|
|
|
|
o.parseOptions(["--node-directory", "cli/test_options",
|
2008-01-04 00:02:05 +00:00
|
|
|
"--dir-uri", "root"])
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
|
2008-01-04 00:02:05 +00:00
|
|
|
self.failUnlessEqual(o['dir-uri'], private_uri)
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['vdrive_pathname'], "")
|
|
|
|
|
|
|
|
o = cli.ListOptions()
|
2007-12-03 21:52:42 +00:00
|
|
|
o.parseOptions(["--node-directory", "cli/test_options"])
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
|
|
|
|
self.failUnlessEqual(o['vdrive_pathname'], "")
|
|
|
|
|
|
|
|
o = cli.ListOptions()
|
2007-12-05 00:00:58 +00:00
|
|
|
other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
|
|
|
|
fingerprint="\x11"*32)
|
|
|
|
other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string()
|
2007-10-11 07:30:36 +00:00
|
|
|
o.parseOptions(["--node-directory", "cli/test_options",
|
2008-01-04 00:02:05 +00:00
|
|
|
"--dir-uri", other_uri])
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
|
2008-01-04 00:02:05 +00:00
|
|
|
self.failUnlessEqual(o['dir-uri'], other_uri)
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['vdrive_pathname'], "")
|
|
|
|
|
|
|
|
o = cli.ListOptions()
|
|
|
|
o.parseOptions(["--node-directory", "cli/test_options",
|
2008-01-04 00:02:05 +00:00
|
|
|
"--dir-uri", other_uri, "subdir"])
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
|
2008-01-04 00:02:05 +00:00
|
|
|
self.failUnlessEqual(o['dir-uri'], other_uri)
|
2007-10-11 07:30:36 +00:00
|
|
|
self.failUnlessEqual(o['vdrive_pathname'], "subdir")
|