2 from twisted.trial import unittest
4 from allmydata.util import fileutil
5 from allmydata import uri
7 # at least import the CLI scripts, even if we don't have any real tests for
10 from allmydata.scripts import cli, tahoe_ls, tahoe_get, tahoe_put, tahoe_rm
11 _hush_pyflakes = [tahoe_ls, tahoe_get, tahoe_put, tahoe_rm]
14 class CLI(unittest.TestCase):
15 def test_options(self):
16 fileutil.rm_dir("cli/test_options")
17 fileutil.make_dirs("cli/test_options")
18 open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
19 #private_uri = uri.DirnodeURI("furl", "key").to_string()
20 filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
21 fingerprint="\x00"*32)
22 private_uri = uri.NewDirectoryURI(filenode_uri).to_string()
23 open("cli/test_options/my_private_dir.cap", "w").write(private_uri + "\n")
25 o.parseOptions(["--node-directory", "cli/test_options"])
26 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
27 self.failUnlessEqual(o['root-uri'], private_uri)
28 self.failUnlessEqual(o['vdrive_pathname'], "")
31 o.parseOptions(["--node-directory", "cli/test_options",
32 "--node-url", "http://example.org:8111/"])
33 self.failUnlessEqual(o['node-url'], "http://example.org:8111/")
34 self.failUnlessEqual(o['root-uri'], private_uri)
35 self.failUnlessEqual(o['vdrive_pathname'], "")
38 o.parseOptions(["--node-directory", "cli/test_options",
39 "--root-uri", "private"])
40 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
41 self.failUnlessEqual(o['root-uri'], private_uri)
42 self.failUnlessEqual(o['vdrive_pathname'], "")
45 o.parseOptions(["--node-directory", "cli/test_options"])
46 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
47 self.failUnlessEqual(o['vdrive_pathname'], "")
50 other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
51 fingerprint="\x11"*32)
52 other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string()
53 o.parseOptions(["--node-directory", "cli/test_options",
54 "--root-uri", other_uri])
55 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
56 self.failUnlessEqual(o['root-uri'], other_uri)
57 self.failUnlessEqual(o['vdrive_pathname'], "")
60 o.parseOptions(["--node-directory", "cli/test_options",
61 "--root-uri", other_uri, "subdir"])
62 self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
63 self.failUnlessEqual(o['root-uri'], other_uri)
64 self.failUnlessEqual(o['vdrive_pathname'], "subdir")