From: Brian Warner Date: Sun, 21 Jan 2007 20:39:40 +0000 (-0700) Subject: test_filetree: more vdrive._get_file_uri() coverage X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~337 X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/frontends/using.html?a=commitdiff_plain;h=a8ecaf45b6ddf6c25f73381b4cdc2ad6eed8bfae;p=tahoe-lafs%2Ftahoe-lafs.git test_filetree: more vdrive._get_file_uri() coverage --- diff --git a/src/allmydata/test/test_filetree_new.py b/src/allmydata/test/test_filetree_new.py index 3d23f843..8b61abef 100644 --- a/src/allmydata/test/test_filetree_new.py +++ b/src/allmydata/test/test_filetree_new.py @@ -316,7 +316,8 @@ 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, NoSuchDirectoryError) + IFileNode, NoSuchDirectoryError, + NoSuchChildError) from allmydata.filetree.file import CHKFileNode from allmydata.util import bencode @@ -432,6 +433,13 @@ class Stuff(unittest.TestCase): d.addCallback(_opened) return d + def shouldFail(self, res, expected_failure, which): + if isinstance(res, Failure): + res.trap(expected_failure) + else: + self.fail("%s was supposed to raise %s, not get '%s'" % + (which, expected_failure, res)) + def testVdrive(self): topdir = directory.LocalFileSubTree().new("vdrive-dirtree.save") topdir.update_now(None) @@ -473,12 +481,10 @@ class Stuff(unittest.TestCase): 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) + d.addBoth(self.shouldFail, NoSuchDirectoryError, "list(bogus)") + + d.addCallback(lambda res: v._get_file_uri(["b", "bogus"])) + d.addBoth(self.shouldFail, NoSuchChildError, "_get_file_uri(b/bogus)") return d