From: Zooko O'Whielacronx Date: Thu, 26 Jul 2007 17:48:30 +0000 (-0700) Subject: refactor test_uri and add a test of the empty file X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/flags/reliability?a=commitdiff_plain;h=42d3afffa2b597d36d4506dd61cc4d97c778bf47;p=tahoe-lafs%2Ftahoe-lafs.git refactor test_uri and add a test of the empty file --- diff --git a/src/allmydata/test/test_uri.py b/src/allmydata/test/test_uri.py index a05e8e5e..835d4f2a 100644 --- a/src/allmydata/test/test_uri.py +++ b/src/allmydata/test/test_uri.py @@ -5,8 +5,7 @@ from allmydata.util import hashutil from allmydata.interfaces import IURI, IFileURI, IDirnodeURI class Literal(unittest.TestCase): - def test_pack(self): - data = "This is some small data" + def _help_test(self, data): u = uri.LiteralFileURI(data) self.failUnless(IURI.providedBy(u)) self.failUnless(IFileURI.providedBy(u)) @@ -24,26 +23,18 @@ class Literal(unittest.TestCase): self.failUnlessEqual(u2.get_size(), len(data)) self.failUnless(u.is_readonly()) self.failIf(u.is_mutable()) + + def test_empty(self): + data = "" # This data is some *very* small data! + return self._help_test(data) + + def test_pack(self): + data = "This is some small data" + return self._help_test(data) def test_nonascii(self): data = "This contains \x00 and URI:LIT: and \n, oh my." - u = uri.LiteralFileURI(data) - self.failUnless(IURI.providedBy(u)) - self.failUnless(IFileURI.providedBy(u)) - self.failIf(IDirnodeURI.providedBy(u)) - self.failUnlessEqual(u.data, data) - self.failUnlessEqual(u.get_size(), len(data)) - self.failUnless(u.is_readonly()) - self.failIf(u.is_mutable()) - - u2 = uri.from_string(u.to_string()) - self.failUnless(IURI.providedBy(u2)) - self.failUnless(IFileURI.providedBy(u2)) - self.failIf(IDirnodeURI.providedBy(u2)) - self.failUnlessEqual(u2.data, data) - self.failUnlessEqual(u2.get_size(), len(data)) - self.failUnless(u.is_readonly()) - self.failIf(u.is_mutable()) + return self._help_test(data) class CHKFile(unittest.TestCase): def test_pack(self):