]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Remove workaround for collective_dircap and repair some tests.
authorDaira Hopwood <daira@jacaranda.org>
Mon, 13 Jul 2015 17:08:45 +0000 (18:08 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:45 +0000 (01:19 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_cli_magic_folder.py
src/allmydata/test/test_magic_folder.py

index 6eba9cc4a340a7f485166744255a1ca820506be1..ff9e255496383c8bd5f4163a1b49362eb3ec25bb 100644 (file)
@@ -77,13 +77,12 @@ class MagicFolder(service.MultiService):
 
         # TODO: allow a path rather than a cap URI.
         self._upload_dirnode = self._client.create_node_from_uri(upload_dircap)
-        if collective_dircap != "":
-            # XXX this condition used for some unit tests
-            self._collective_dirnode = self._client.create_node_from_uri(collective_dircap)
-            if not IDirectoryNode.providedBy(self._collective_dirnode):
-                raise AssertionError("The URI in 'private/collective_dircap' does not refer to a directory.")
-            if self._collective_dirnode.is_unknown() or not self._collective_dirnode.is_readonly():
-                raise AssertionError("The URI in 'private/collective_dircap' is not a readonly cap to a directory.")
+
+        self._collective_dirnode = self._client.create_node_from_uri(collective_dircap)
+        if not IDirectoryNode.providedBy(self._collective_dirnode):
+            raise AssertionError("The URI in 'private/collective_dircap' does not refer to a directory.")
+        if self._collective_dirnode.is_unknown() or not self._collective_dirnode.is_readonly():
+            raise AssertionError("The URI in 'private/collective_dircap' is not a readonly cap to a directory.")
 
         if not IDirectoryNode.providedBy(self._upload_dirnode):
             raise AssertionError("The URI in 'private/magic_folder_dircap' does not refer to a directory.")
index f6e9a16d4a020fcbbb010d536cd1c4e0d69ad97b..9894ed93c5e42d04ae22d045fc80f2d8ad7eab36 100644 (file)
@@ -95,6 +95,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin):
         d.addCallback(_done)
         def get_alice_caps(x):
             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)
         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 ac5e0d9a0003da88e4db4f8a630bb264e970198c..303e5b5cab23a3bf8e6a0e1d4122200b8eb4b8f2 100644 (file)
@@ -30,7 +30,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         temp = self.mktemp()
         self.basedir = abspath_expanduser_unicode(temp.decode(get_filesystem_encoding()))
         self.magicfolder = None
-        self.dir_node = None
 
     def _get_count(self, name):
         return self.stats_provider.get_stats()["counters"].get(name, 0)
@@ -42,16 +41,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         self.failUnlessEqual(bdb.VERSION, 3)
         return bdb
 
-    def _made_upload_dir(self, n):
-        if self.dir_node == None:
-            self.dir_node = n
-        else:
-            n = self.dir_node
-        self.failUnless(IDirectoryNode.providedBy(n))
-        self.upload_dirnode = n
-        self.upload_dircap = n.get_uri()
-        self.collective_dircap = ""
-
     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,
@@ -104,9 +93,9 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         self.client = self.g.clients[0]
         self.stats_provider = self.client.stats_provider
 
-        d = self.client.create_dirnode()
-        d.addCallback(self._made_upload_dir)
+        d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
         d.addCallback(self._create_magicfolder)
+
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.dirs_monitored'), 1))
         d.addBoth(self.cleanup)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.dirs_monitored'), 0))
@@ -209,6 +198,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
         d.addCallback(self._create_magicfolder)
+
         def create_test_file(result):
             d2 = defer.Deferred()
             self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
@@ -254,10 +244,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         self.client = self.g.clients[0]
         self.stats_provider = self.client.stats_provider
 
-        d = self.client.create_dirnode()
-
-        d.addCallback(self._made_upload_dir)
-        self.collective_dircap = ""
+        d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
         d.addCallback(self._create_magicfolder)
 
         # Write something short enough for a LIT file.