Remove self.client and stats_provider attributes which could get out-of-sync with self.get_client().

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-09-03 20:20:13 +01:00
parent 8771a41000
commit ff1ad20392
2 changed files with 9 additions and 25 deletions

View File

@ -83,9 +83,10 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin):
return (rc,stdout,stderr) return (rc,stdout,stderr)
d.addCallback(_done) d.addCallback(_done)
def get_alice_caps(x): def get_alice_caps(x):
client = self.get_client()
self.collective_dircap, self.upload_dircap = self.get_caps_from_files(0) 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.collective_dirnode = client.create_node_from_uri(self.collective_dircap)
self.upload_dirnode = self.client.create_node_from_uri(self.upload_dircap) self.upload_dirnode = client.create_node_from_uri(self.upload_dircap)
d.addCallback(get_alice_caps) d.addCallback(get_alice_caps)
d.addCallback(lambda x: self.check_joined_config(0, self.upload_dircap)) d.addCallback(lambda x: self.check_joined_config(0, self.upload_dircap))
d.addCallback(lambda x: self.check_config(0, local_dir)) d.addCallback(lambda x: self.check_config(0, local_dir))

View File

@ -33,7 +33,8 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
self.magicfolder = None self.magicfolder = None
def _get_count(self, name, client=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): def _createdb(self):
dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir) dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir)
@ -47,19 +48,15 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
d = self.restart_client() d = self.restart_client()
def _restarted(ign): def _restarted(ign):
print "_restarted" print "_restarted"
self.client = self.get_client() self.magicfolder = self.get_client().getServiceNamed('magic-folder')
print self.client
print self.client.services
self.magicfolder = self.client.getServiceNamed('magic-folder')
#self.magicfolder.ready()
d.addCallback(_restarted) d.addCallback(_restarted)
return d return d
def _create_magicfolder(self, ign): def _create_magicfolder(self, ign):
dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir) 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) dbfile, inotify=self.inotify, pending_delay=0.2)
self.magicfolder.setServiceParent(self.client) self.magicfolder.setServiceParent(self.get_client())
self.magicfolder.ready() self.magicfolder.ready()
# Prevent unclean reactor errors. # Prevent unclean reactor errors.
@ -104,9 +101,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
base=self.basedir) base=self.basedir)
self.mkdir_nonascii(self.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", self.local_dir) d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
d.addCallback(self._restart_client) d.addCallback(self._restart_client)
@ -122,9 +116,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
base=self.basedir) base=self.basedir)
self.mkdir_nonascii(self.local_dir) 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_name = self.unicode_or_fallback(u"empty_tr\u00EAe", u"empty_tree")
empty_tree_dir = abspath_expanduser_unicode(empty_tree_name, base=self.basedir) 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) 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.local_dir = abspath_expanduser_unicode(u"test_persistence", base=self.basedir)
self.mkdir_nonascii(self.local_dir) self.mkdir_nonascii(self.local_dir)
self.client = self.g.clients[0]
self.stats_provider = self.client.stats_provider
self.collective_dircap = "" self.collective_dircap = ""
d = self.create_invite_join_magic_folder(u"Alice", self.local_dir) 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) fileutil.write(os.path.join(client_node_dir, "tahoe.cfg"), tahoe_config)
def setup_stats(result): def setup_stats(result):
#print "setup_stats" #print "setup_stats"
self.client = None
self.set_up_grid(client_config_hooks={0: write_config}) self.set_up_grid(client_config_hooks={0: write_config})
self.client = self.g.clients[0] self.magicfolder = self.get_client().getServiceNamed("magic-folder")
self.stats_provider = self.client.stats_provider
self.magicfolder = self.client.getServiceNamed("magic-folder")
d3.addBoth(self.cleanup) d3.addBoth(self.cleanup)
d3.addCallback(setup_stats) 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.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.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 = self.create_invite_join_magic_folder(u"Alice\u0101", self.local_dir)
d.addCallback(self._create_magicfolder) d.addCallback(self._create_magicfolder)