From 9e7dbf20bc696639b2d8fc9f708f16f64b43056e Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 21 Jan 2007 04:50:37 -0700 Subject: [PATCH] filetree: test NoSuchDirectoryError in vdrive.list() --- src/allmydata/filetree/interfaces.py | 3 +++ src/allmydata/test/test_filetree_new.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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 -- 2.45.2