From: Daira Hopwood Date: Mon, 13 Jul 2015 17:08:45 +0000 (+0100) Subject: Remove workaround for collective_dircap and repair some tests. X-Git-Url: https://git.rkrishnan.org/specifications/%5B/%5D%20//%22%22?a=commitdiff_plain;h=676e817fb47a9f2f76d704ed7bf7fc4ab9cc5a5d;p=tahoe-lafs%2Ftahoe-lafs.git Remove workaround for collective_dircap and repair some tests. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 6eba9cc4..ff9e2554 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -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.") diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index f6e9a16d..9894ed93 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -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)) diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index ac5e0d9a..303e5b5c 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -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.