cli: make --mutable-type imply --mutable in 'tahoe put'

This commit is contained in:
Kevan Carstensen 2011-09-03 12:09:20 -07:00
parent 1b7b3bd0d4
commit 64996a913d
2 changed files with 22 additions and 0 deletions

View File

@ -193,6 +193,9 @@ class PutOptions(VDriveOptions):
if self['mutable-type'] and self['mutable-type'] not in ("sdmf", "mdmf"):
raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
if self['mutable-type']:
self['mutable'] = True
def getSynopsis(self):
return "Usage: %s put [options] LOCAL_FILE REMOTE_FILE" % (self.command_name,)

View File

@ -1198,6 +1198,25 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
d.addCallback(self._check_sdmf_json)
return d
def test_mutable_type_implies_mutable(self):
self.basedir = "cli/Put/mutable_type_implies_mutable"
self.set_up_grid()
data = "data" * 100000
fn1 = os.path.join(self.basedir, "data")
fileutil.write(fn1, data)
d = self.do_cli("put", "--mutable-type=mdmf", fn1)
d.addCallback(lambda (rc, cap, err):
self.do_cli("ls", "--json", cap))
# This will fail if an immutable file is created instead of a
# mutable file.
d.addCallback(self._check_mdmf_json)
d.addCallback(lambda ignored:
self.do_cli("put", "--mutable-type=sdmf", fn1))
d.addCallback(lambda (rc, cap, err):
self.do_cli("ls", "--json", cap))
d.addCallback(self._check_sdmf_json)
return d
def test_put_to_mdmf_cap(self):
self.basedir = "cli/Put/put_to_mdmf_cap"
self.set_up_grid()