]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Remove self.client and stats_provider attributes which could get out-of-sync with...
authorDaira Hopwood <daira@jacaranda.org>
Thu, 3 Sep 2015 19:20:13 +0000 (20:20 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:48 +0000 (01:19 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/test_cli_magic_folder.py
src/allmydata/test/test_magic_folder.py

index 5b75c6d0255dbc04a3574d6ee399e9dcf672aec0..9d3880e665f4a8f03efc7a4543813dedfdacf1e2 100644 (file)
@@ -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))
index fb75114e5a2096bb6f057294054eb5c497394158..3d76799f42c0d5cacdba702e3c8e5950a06772c8 100644 (file)
@@ -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)