return node
raise RuntimeError("unable to handle node type '%s'" % prefix)
+
+
all_openable_subtree_types = [
directory.LocalFileSubTree,
directory.CHKDirectorySubTree,
return subtree
+
class VirtualDrive(object):
implements(IVirtualDrive)
return d
def _get_closest_node_1(self, subtree, path):
- d = subtree.get_node_for_path(path)
- d.addCallback(self._get_closest_node_2, subtree.is_mutable())
- return d
-
- def _get_closest_node_2(self, res, parent_is_mutable):
- (found_path, node, remaining_path) = res
+ (found_path, node, remaining_path) = subtree.get_node_for_path(path)
+ parent_is_mutable = subtree.is_mutable()
if IDirectoryNode.providedBy(node):
# traversal done
return (node, remaining_path)
v = vdrive.VirtualDrive(wq, dl, root_node)
return v
+ def failUnlessListsAreEqual(self, list1, list2):
+ self.failUnlessEqual(sorted(list1), sorted(list2))
+
def testDirectory(self):
- # TODO: we only need this VirtualDrive for the opener. Perhaps
- # make_subtree_from_node should move out of that class and into a
- # module-level function.
stm = vdrive.SubTreeMaker(None, None)
# create an empty directory (stored locally)
self.failUnlessEqual(remaining_path, [])
self.failUnless(INode.providedBy(root))
self.failUnless(IDirectoryNode.providedBy(root))
- self.failUnlessEqual(root.list(), [])
+ self.failUnlessListsAreEqual(root.list().keys(), [])
self.failUnlessIdentical(root.get_subtree(), subtree)
# now add some children to it
file1 = CHKFileNode()
file1.new("uri1")
root.add("foo.txt", file1)
- self.failUnlessEqual(root.list(), ["foo.txt", "subdir1"])
+ self.failUnlessListsAreEqual(root.list().keys(),
+ ["foo.txt", "subdir1"])
self.failUnlessIdentical(root.get("foo.txt"), file1)
subdir1a = root.get("subdir1")
self.failUnlessIdentical(subdir1, subdir1a)
del subdir1a
self.failUnless(IDirectoryNode.providedBy(subdir1))
- self.failUnlessEqual(subdir1.list(), [])
+ self.failUnlessListsAreEqual(subdir1.list().keys(), [])
self.failUnlessIdentical(subdir1.get_subtree(), subtree)
subdir2 = subdir1.add_subdir("subdir2")
subdir4 = subdir2.add_subdir("subdir4")
subdir2.delete("subdir4")
- self.failUnlessEqual(subdir2.list(), ["subdir3"])
+ self.failUnlessListsAreEqual(subdir2.list().keys(), ["subdir3"])
del root, subdir1, subdir2, subdir3, subdir4
# leaving file1 for later use
self.failUnlessEqual(remaining_path, [])
self.failUnless(INode.providedBy(root))
self.failUnless(IDirectoryNode.providedBy(root))
- self.failUnlessEqual(root.list(), ["foo.txt", "subdir1"])
+ self.failUnlessListsAreEqual(root.list().keys(),
+ ["foo.txt", "subdir1"])
file1a = root.get("foo.txt")
self.failUnless(INode(file1a))
self.failUnless(isinstance(file1a, CHKFileNode))
self.failUnlessEqual(file1a.get_uri(), "uri1")
subdir1 = root.get("subdir1")
subdir2 = subdir1.get("subdir2")
- self.failUnlessEqual(subdir2.list(), ["subdir3"])
+ self.failUnlessListsAreEqual(subdir2.list().keys(), ["subdir3"])
subdir2.delete("subdir3")
- self.failUnlessEqual(subdir2.list(), [])
+ self.failUnlessListsAreEqual(subdir2.list().keys(), [])
d.addCallback(_opened)
return d
def testVdrive(self):
- # create some stuff, see if we can import everything
-
- # create an empty directory (stored locally) as our root
- root = directory.LocalFileSubTree()
- root.new("dirtree.save")
-
- # and a node to point to it
- root_node = directory.LocalFileSubTreeNode()
- root_node.new("dirtree.save")
-
- v = self.makeVirtualDrive("test_filetree_new/testVdrive", root_node)
+ topdir = directory.LocalFileSubTree().new("vdrive-dirtree.save")
+ topdir.update_now(None)
+ root = redirect.LocalFileRedirection().new("vdrive-root",
+ topdir.create_node_now())
+ root.update_now(None)
+ wq = self.makeVirtualDrive("vdrive", root.create_node_now())
+
+ d = wq.list([])
+ def _listed(contents):
+ self.failUnlessEqual(contents, {})
+ d.addCallback(_listed)
+ return d
- def start():
- root_node = redirect.LocalFileRedirectionNode()
-# root_node.new("handle", dirtree)
- root = redirect.LocalFileRedirection()
- # wow, bootstrapping is hard