From: Kevan Carstensen Date: Sat, 3 Sep 2011 19:09:20 +0000 (-0700) Subject: cli: make --mutable-type imply --mutable in 'tahoe put' X-Git-Tag: allmydata-tahoe-1.9.0a2~61 X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=64996a913d014b5f52bc56f2a0760cf38785ff27;p=tahoe-lafs%2Ftahoe-lafs.git cli: make --mutable-type imply --mutable in 'tahoe put' --- diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 2ec67985..b041b581 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -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,) diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 39b0f6bb..ab2e2222 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -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()