From: Zooko O'Whielacronx Date: Wed, 12 Dec 2007 01:10:29 +0000 (-0700) Subject: editing: change names like "MyThing" to "FakeThing" for fake objects in unit tests X-Git-Url: https://git.rkrishnan.org/provisioning?a=commitdiff_plain;h=a7f954ac068eefb0f34eca15c633a5c2cf910880;p=tahoe-lafs%2Ftahoe-lafs.git editing: change names like "MyThing" to "FakeThing" for fake objects in unit tests --- diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index fd76ce08..f199bcdd 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -9,7 +9,7 @@ from allmydata import client, introducer from allmydata.util import version_class, idlib from foolscap.eventual import flushEventualQueue -class MyIntroducerClient(introducer.IntroducerClient): +class FakeIntroducerClient(introducer.IntroducerClient): def __init__(self): self.connections = {} @@ -99,7 +99,7 @@ class Basic(unittest.TestCase): open(os.path.join(basedir, "introducer.furl"), "w").write("") open(os.path.join(basedir, "vdrive.furl"), "w").write("") c = client.Client(basedir) - c.introducer_client = MyIntroducerClient() + c.introducer_client = FakeIntroducerClient() for k in ["%d" % i for i in range(5)]: c.introducer_client.connections[k] = None self.failUnlessEqual(permute(c, "one"), ['3','1','0','4','2']) @@ -108,7 +108,7 @@ class Basic(unittest.TestCase): self.failUnlessEqual(permute(c, "one"), []) c2 = client.Client(basedir) - c2.introducer_client = MyIntroducerClient() + c2.introducer_client = FakeIntroducerClient() for k in ["%d" % i for i in range(5)]: c2.introducer_client.connections[k] = None self.failUnlessEqual(permute(c2, "one"), ['3','1','0','4','2']) diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index 07bef1a0..0e945c54 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -12,7 +12,7 @@ from allmydata.test.common import make_chk_file_uri, make_mutable_file_uri, \ # contain pointers to fake files. We start with a fake MutableFileNode that # stores all of its data in a static table. -MyDirectoryNode = NonGridDirectoryNode +FakeDirectoryNode = NonGridDirectoryNode class Marker: implements(IFileNode, IMutableFileNode) # sure, why not @@ -52,11 +52,11 @@ class FakeClient: u = IURI(u) if (INewDirectoryURI.providedBy(u) or IReadonlyNewDirectoryURI.providedBy(u)): - return MyDirectoryNode(self).init_from_uri(u) + return FakeDirectoryNode(self).init_from_uri(u) return Marker(u.to_string()) def create_empty_dirnode(self, wait_for_numpeers): - n = MyDirectoryNode(self) + n = FakeDirectoryNode(self) d = n.create(wait_for_numpeers) d.addCallback(lambda res: n) return d @@ -69,7 +69,7 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin): def test_basic(self): d = self.client.create_empty_dirnode(0) def _done(res): - self.failUnless(isinstance(res, MyDirectoryNode)) + self.failUnless(isinstance(res, FakeDirectoryNode)) rep = str(res) self.failUnless("RW" in rep) d.addCallback(_done) @@ -182,7 +182,7 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin): d.addCallback(lambda res: n.create_empty_directory("subdir", wait_for_numpeers=1)) def _created(subdir): - self.failUnless(isinstance(subdir, MyDirectoryNode)) + self.failUnless(isinstance(subdir, FakeDirectoryNode)) self.subdir = subdir new_v = subdir.get_verifier() assert isinstance(new_v, str) @@ -206,7 +206,7 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin): d.addCallback(lambda res: n.get_child_at_path("subdir/subsubdir")) d.addCallback(lambda subsubdir: self.failUnless(isinstance(subsubdir, - MyDirectoryNode))) + FakeDirectoryNode))) d.addCallback(lambda res: n.get_child_at_path("")) d.addCallback(lambda res: self.failUnlessEqual(res.get_uri(), n.get_uri())) diff --git a/src/allmydata/test/test_introducer.py b/src/allmydata/test/test_introducer.py index 0c521222..0e1831bf 100644 --- a/src/allmydata/test/test_introducer.py +++ b/src/allmydata/test/test_introducer.py @@ -12,7 +12,7 @@ from twisted.application import service from allmydata.introducer import IntroducerClient, IntroducerService, IntroducerNode from allmydata.util import testutil -class MyNode(Referenceable): +class FakeNode(Referenceable): pass class LoggingMultiService(service.MultiService): @@ -101,7 +101,7 @@ class TestIntroducer(unittest.TestCase, testutil.PollMixin): portnum = l.getPortnum() tub.setLocation("localhost:%d" % portnum) - n = MyNode() + n = FakeNode() node_furl = tub.registerReference(n) c = IntroducerClient(tub, iurl, node_furl) @@ -205,7 +205,7 @@ class TestIntroducer(unittest.TestCase, testutil.PollMixin): clients = [] for i in range(5): - n = MyNode() + n = FakeNode() node_furl = tub.registerReference(n) c = IntroducerClient(tub, iurl, node_furl) c.setServiceParent(self.parent) @@ -246,7 +246,7 @@ class TestIntroducer(unittest.TestCase, testutil.PollMixin): portnum = l.getPortnum() tub.setLocation("localhost:%d" % portnum) - n = MyNode() + n = FakeNode() node_furl = tub.registerReference(n) c = IntroducerClient(tub, iurl, node_furl) c.setServiceParent(self.parent)