From: Brian Warner Date: Sun, 21 Jan 2007 11:50:37 +0000 (-0700) Subject: filetree: test NoSuchDirectoryError in vdrive.list() X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~339 X-Git-Url: https://git.rkrishnan.org/pf/reliability?a=commitdiff_plain;h=9e7dbf20bc696639b2d8fc9f708f16f64b43056e;p=tahoe-lafs%2Ftahoe-lafs.git filetree: test NoSuchDirectoryError in vdrive.list() --- diff --git a/src/allmydata/filetree/interfaces.py b/src/allmydata/filetree/interfaces.py index 56079272..665d1b63 100644 --- a/src/allmydata/filetree/interfaces.py +++ b/src/allmydata/filetree/interfaces.py @@ -230,6 +230,9 @@ class IVirtualDrive(Interface): Interfaces: either IDirectoryNode if path+[childname] can be used in a 'list' method, or IFileNode if path+[childname] can be used in a 'download' method. + + The Deferred will errback (with NoSuchDirectoryError) if the path + does not point to an actual directory. """ def download(path, target): diff --git a/src/allmydata/test/test_filetree_new.py b/src/allmydata/test/test_filetree_new.py index 8cc3d2bb..2f1eccb3 100644 --- a/src/allmydata/test/test_filetree_new.py +++ b/src/allmydata/test/test_filetree_new.py @@ -313,8 +313,10 @@ class Redirect(unittest.TestCase): """ import os.path +from twisted.python.failure import Failure from allmydata.filetree import directory, redirect, vdrive -from allmydata.filetree.interfaces import (ISubTree, INode, IDirectoryNode, IFileNode) +from allmydata.filetree.interfaces import (ISubTree, INode, IDirectoryNode, + IFileNode, NoSuchDirectoryError) from allmydata.filetree.file import CHKFileNode from allmydata.util import bencode @@ -467,5 +469,16 @@ class Stuff(unittest.TestCase): {"c": child2, "d": child3}) d.addCallback(_listed4) + #d.addCallback(lambda res: v._get_file_uri(["b","c"])) + #d.addCallback(self.failUnlessEqual, "uri2") + + d.addCallback(lambda res: v.list(["bogus"])) + def _listed_bogus(res): + if isinstance(res, Failure): + res.trap(NoSuchDirectoryError) + else: + self.fail("list(bogus) was supposed to fail") + d.addBoth(_listed_bogus) + return d