From 64996a913d014b5f52bc56f2a0760cf38785ff27 Mon Sep 17 00:00:00 2001 From: Kevan Carstensen <kevan@isnotajoke.com> Date: Sat, 3 Sep 2011 12:09:20 -0700 Subject: [PATCH] cli: make --mutable-type imply --mutable in 'tahoe put' --- src/allmydata/scripts/cli.py | 3 +++ src/allmydata/test/test_cli.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) 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() -- 2.45.2