From: Daira Hopwood Date: Thu, 3 Sep 2015 19:20:13 +0000 (+0100) Subject: Remove self.client and stats_provider attributes which could get out-of-sync with... X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/somewhere?a=commitdiff_plain;h=28620433c011a6eaa3739beb5278c896cfb2b423;p=tahoe-lafs%2Ftahoe-lafs.git Remove self.client and stats_provider attributes which could get out-of-sync with self.get_client(). Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index 5b75c6d0..9d3880e6 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -83,9 +83,10 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): return (rc,stdout,stderr) d.addCallback(_done) def get_alice_caps(x): + client = self.get_client() self.collective_dircap, self.upload_dircap = self.get_caps_from_files(0) - self.collective_dirnode = self.client.create_node_from_uri(self.collective_dircap) - self.upload_dirnode = self.client.create_node_from_uri(self.upload_dircap) + self.collective_dirnode = client.create_node_from_uri(self.collective_dircap) + self.upload_dirnode = client.create_node_from_uri(self.upload_dircap) d.addCallback(get_alice_caps) d.addCallback(lambda x: self.check_joined_config(0, self.upload_dircap)) d.addCallback(lambda x: self.check_config(0, local_dir)) diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index fb75114e..3d76799f 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -33,7 +33,8 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual self.magicfolder = None def _get_count(self, name, client=None): - return (client or self).stats_provider.get_stats()["counters"].get('magic_folder.%s' % (name,), 0) + counters = (client or self.get_client()).stats_provider.get_stats()["counters"] + return counters.get('magic_folder.%s' % (name,), 0) def _createdb(self): dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir) @@ -47,19 +48,15 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual d = self.restart_client() def _restarted(ign): print "_restarted" - self.client = self.get_client() - print self.client - print self.client.services - self.magicfolder = self.client.getServiceNamed('magic-folder') - #self.magicfolder.ready() + self.magicfolder = self.get_client().getServiceNamed('magic-folder') d.addCallback(_restarted) return d def _create_magicfolder(self, ign): dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir) - self.magicfolder = MagicFolder(self.client, self.upload_dircap, self.collective_dircap, self.local_dir, + self.magicfolder = MagicFolder(self.get_client(), self.upload_dircap, self.collective_dircap, self.local_dir, dbfile, inotify=self.inotify, pending_delay=0.2) - self.magicfolder.setServiceParent(self.client) + self.magicfolder.setServiceParent(self.get_client()) self.magicfolder.ready() # Prevent unclean reactor errors. @@ -104,9 +101,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual base=self.basedir) self.mkdir_nonascii(self.local_dir) - self.client = self.g.clients[0] - self.stats_provider = self.client.stats_provider - d = self.create_invite_join_magic_folder(u"Alice", self.local_dir) d.addCallback(self._restart_client) @@ -122,9 +116,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual base=self.basedir) self.mkdir_nonascii(self.local_dir) - self.client = self.g.clients[0] - self.stats_provider = self.client.stats_provider - empty_tree_name = self.unicode_or_fallback(u"empty_tr\u00EAe", u"empty_tree") empty_tree_dir = abspath_expanduser_unicode(empty_tree_name, base=self.basedir) new_empty_tree_dir = abspath_expanduser_unicode(empty_tree_name, base=self.local_dir) @@ -203,8 +194,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual self.local_dir = abspath_expanduser_unicode(u"test_persistence", base=self.basedir) self.mkdir_nonascii(self.local_dir) - self.client = self.g.clients[0] - self.stats_provider = self.client.stats_provider self.collective_dircap = "" d = self.create_invite_join_magic_folder(u"Alice", self.local_dir) @@ -232,11 +221,8 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual fileutil.write(os.path.join(client_node_dir, "tahoe.cfg"), tahoe_config) def setup_stats(result): #print "setup_stats" - self.client = None self.set_up_grid(client_config_hooks={0: write_config}) - self.client = self.g.clients[0] - self.stats_provider = self.client.stats_provider - self.magicfolder = self.client.getServiceNamed("magic-folder") + self.magicfolder = self.get_client().getServiceNamed("magic-folder") d3.addBoth(self.cleanup) d3.addCallback(setup_stats) @@ -253,9 +239,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual self.local_dir = os.path.join(self.basedir, self.unicode_or_fallback(u"loc\u0101l_dir", u"local_dir")) self.mkdir_nonascii(self.local_dir) - self.client = self.g.clients[0] - self.stats_provider = self.client.stats_provider - d = self.create_invite_join_magic_folder(u"Alice\u0101", self.local_dir) d.addCallback(self._create_magicfolder)