Remove workaround for collective_dircap and repair some tests.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-07-13 18:08:45 +01:00
parent e61130395d
commit 38a6d60f1a
3 changed files with 12 additions and 24 deletions

View 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.")

View 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))

View 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.