From 1e59930fda64428fce438f06dde733579c9902d0 Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Tue, 6 Sep 2011 11:30:20 -0700
Subject: [PATCH] CLI: improve test for 'tahoe mkdir --mutable-type='. refs
 #1527

---
 src/allmydata/test/test_cli.py | 41 +++++++++++++++-------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py
index 9a60c5fd..d2b503eb 100644
--- a/src/allmydata/test/test_cli.py
+++ b/src/allmydata/test/test_cli.py
@@ -3308,29 +3308,24 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
             self.failUnlessReallyEqual(err, "")
             self.failUnlessIn(st, out)
             return out
-        def _stash_dircap(cap):
-            self._dircap = cap
-            u = uri.from_string(cap)
-            fn_uri = u.get_filenode_cap()
-            self._filecap = fn_uri.to_string()
-        d.addCallback(_check, "URI:DIR2")
-        d.addCallback(_stash_dircap)
-        d.addCallback(lambda ignored:
-            self.do_cli("ls", "--json", "tahoe:foo"))
-        d.addCallback(_check, "URI:DIR2")
-        d.addCallback(lambda ignored:
-            self.do_cli("ls", "--json", self._filecap))
-        d.addCallback(_check, '"mutable-type": "sdmf"')
-        d.addCallback(lambda ignored:
-            self.do_cli("mkdir", "--mutable-type=MDMF", "tahoe:bar"))
-        d.addCallback(_check, "URI:DIR2-MDMF")
-        d.addCallback(_stash_dircap)
-        d.addCallback(lambda ignored:
-            self.do_cli("ls", "--json", "tahoe:bar"))
-        d.addCallback(_check, "URI:DIR2-MDMF")
-        d.addCallback(lambda ignored:
-            self.do_cli("ls", "--json", self._filecap))
-        d.addCallback(_check, '"mutable-type": "mdmf"')
+        def _mkdir(ign, mutable_type, uri_prefix, dirname):
+            d2 = self.do_cli("mkdir", "--mutable-type="+mutable_type, dirname)
+            d2.addCallback(_check, uri_prefix)
+            def _stash_filecap(cap):
+                u = uri.from_string(cap)
+                fn_uri = u.get_filenode_cap()
+                self._filecap = fn_uri.to_string()
+            d2.addCallback(_stash_filecap)
+            d2.addCallback(lambda ign: self.do_cli("ls", "--json", dirname))
+            d2.addCallback(_check, uri_prefix)
+            d2.addCallback(lambda ign: self.do_cli("ls", "--json", self._filecap))
+            d2.addCallback(_check, '"mutable-type": "%s"' % (mutable_type.lower(),))
+            return d2
+
+        d.addCallback(_mkdir, "sdmf", "URI:DIR2", "tahoe:foo")
+        d.addCallback(_mkdir, "SDMF", "URI:DIR2", "tahoe:foo2")
+        d.addCallback(_mkdir, "mdmf", "URI:DIR2-MDMF", "tahoe:bar")
+        d.addCallback(_mkdir, "MDMF", "URI:DIR2-MDMF", "tahoe:bar2")
         return d
 
     def test_mkdir_mutable_type_unlinked(self):
-- 
2.45.2