]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
cli: make --mutable-type imply --mutable in 'tahoe put'
authorKevan Carstensen <kevan@isnotajoke.com>
Sat, 3 Sep 2011 19:09:20 +0000 (12:09 -0700)
committerKevan Carstensen <kevan@isnotajoke.com>
Sat, 3 Sep 2011 19:09:20 +0000 (12:09 -0700)
src/allmydata/scripts/cli.py
src/allmydata/test/test_cli.py

index 2ec679857a8fc188e33c59e91f8e19d9d7b14658..b041b581f4cd0f3d1109b6344fc8480822dcd92e 100644 (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,)
index 39b0f6bb664163cc21cbc77c76883b9db9529330..ab2e2222da27ed2b20c072ad1ca364576832e816 100644 (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()