]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_filetable: fix to match new vdrive approach
authorBrian Warner <warner@allmydata.com>
Fri, 15 Jun 2007 07:01:01 +0000 (00:01 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 15 Jun 2007 07:01:01 +0000 (00:01 -0700)
src/allmydata/test/test_filetable.py

index ab19baafb788a484640187ea3a2304f2d7ad9261..8b9123838170031c9d3859ac18afd863c860a7e2 100644 (file)
@@ -9,18 +9,19 @@ from allmydata.interfaces import FileNode, DirectoryNode
 class FileTable(unittest.TestCase):
     def test_files(self):
         os.mkdir("filetable")
-        root = MutableDirectoryNode(os.path.abspath("filetable"), "root")
+        basedir = os.path.abspath("filetable")
+        root = MutableDirectoryNode(basedir, "root")
         self.failUnlessEqual(root.list(), [])
         root.add("one", FileNode("vid-one"))
         root.add("two", FileNode("vid-two"))
         self.failUnlessEqual(root.list(), [("one", FileNode("vid-one")),
                                            ("two", FileNode("vid-two"))])
         root.remove("two")
-        self.failUnlessEqual(root.list(), [("one", "vid-one")])
+        self.failUnlessEqual(root.list(), [("one", FileNode("vid-one"))])
         self.failUnlessRaises(BadFileError, root.remove, "two")
         self.failUnlessRaises(BadFileError, root.remove, "three")
 
-        self.failUnlessEqual(root.get("one"), "vid-one")
+        self.failUnlessEqual(root.get("one"), FileNode("vid-one"))
         self.failUnlessRaises(BadFileError, root.get, "missing")
         self.failUnlessRaises(BadNameError, root.get, "/etc/passwd") # evil
         self.failUnlessRaises(BadNameError, root.get, "..") # sneaky
@@ -28,32 +29,26 @@ class FileTable(unittest.TestCase):
 
         # now play with directories
         subdir1 = root.add("subdir1", DirectoryNode("subdir1.furl"))
-        self.failUnless(isinstance(subdir1, MutableDirectoryNode))
+        self.failUnless(isinstance(subdir1, DirectoryNode))
         subdir1a = root.get("subdir1")
-        self.failUnless(isinstance(subdir1a, MutableDirectoryNode))
-        self.failUnlessEqual(subdir1a._basedir, subdir1._basedir)
+        self.failUnless(isinstance(subdir1a, DirectoryNode))
+        self.failUnlessEqual(subdir1a, subdir1)
         entries = root.list()
         self.failUnlessEqual(len(entries), 2)
-        one_index = entries.index( ("one", "vid-one") )
+        one_index = entries.index( ("one", FileNode("vid-one")) )
         subdir_index = 1 - one_index
         self.failUnlessEqual(entries[subdir_index][0], "subdir1")
         subdir2 = entries[subdir_index][1]
-        self.failUnless(isinstance(subdir2, MutableDirectoryNode))
-
-        self.failUnlessEqual(subdir1.list(), [])
-        self.failUnlessEqual(subdir2.list(), [])
-
-        subdir1.add_file("subone", "vid-subone")
-        self.failUnlessEqual(subdir1.list(), [("subone", "vid-subone")])
-        self.failUnlessEqual(subdir2.list(), [("subone", "vid-subone")])
+        self.failUnless(isinstance(subdir2, DirectoryNode))
 
         self.failUnlessEqual(len(root.list()), 2)
 
-        self.failUnlessRaises(BadDirectoryError, root.add_directory, "subdir1")
-        self.failUnlessRaises(BadDirectoryError, root.add_directory, "one")
+        self.failUnlessRaises(BadNameError, # replacing an existing child
+                              root.add,
+                              "subdir1", DirectoryNode("subdir1.furl"))
 
         root.remove("subdir1")
-        self.failUnlessEqual(root.list(), [("one", "vid-one")])
+        self.failUnlessEqual(root.list(), [("one", FileNode("vid-one"))])