This returns a Deferred that will fire with an instance that provides
either IDirectoryNode or IFileNode, as appropriate."""
+ def create_directory():
+ """Return a new IDirectoryNode that is empty and not linked by
+ anything."""
+
+
class NotCapableError(Exception):
"""You have tried to write to a read-only node."""
name = "vdrive"
public_root = None
private_root = None
- def __init__(self, nodes):
+ def __init__(self, nodes, files):
self._my_nodes = nodes
+ self._my_files = files
def have_public_root(self):
return bool(self.public_root)
def have_private_root(self):
return self._my_nodes[uri]
return defer.maybeDeferred(_try)
+ def create_directory(self):
+ # the dirnode adds itself to self.nodes
+ dirnode = MyDirectoryNode(self._my_nodes, self._my_files, self.parent)
+ return defer.succeed(dirnode)
+
+
class WebMixin(object):
def setUp(self):
self.s = MyClient()
self.nodes = {} # maps URI to node
self.files = {} # maps file URI to contents
- v = MyVirtualDrive(self.nodes)
+ v = MyVirtualDrive(self.nodes, self.files)
v.setServiceParent(self.s)
dl = MyDownloader(self.files)
d.addCallback(_check2)
return d
+ def test_PUT_NEWDIR_URI(self):
+ d = self.PUT("/uri?t=mkdir", "")
+ def _check(uri):
+ self.failUnless(uri in self.nodes)
+ self.failUnless(isinstance(self.nodes[uri], MyDirectoryNode))
+ return self.GET("/uri/%s?t=json" % uri.replace("/","!"))
+ d.addCallback(_check)
+ d.addCallback(self.failUnlessIsEmptyJSON)
+ return d
+
def test_XMLRPC(self):
raise unittest.SkipTest("not yet")
pass
% furl_file)
return
+ self.global_vdrive_furl = global_vdrive_furl
tub.connectTo(global_vdrive_furl,
self._got_vdrive_server, global_vdrive_furl)
return d
return root
+
+ def create_directory(self):
+ # return a new+empty+unlinked dirnode
+ assert self.global_vdrive_furl
+ d = dirnode.create_directory(self.parent, self.global_vdrive_furl)
+ return d