From c1e95b3634eed205ccf3a0371319c6b29235a93c Mon Sep 17 00:00:00 2001 From: David Stainton Date: Wed, 15 Jul 2015 16:54:26 -0700 Subject: [PATCH] fix bug in test_errors and add test - test that we report the correct error when a write cap is passed as a collective dircap --- src/allmydata/frontends/magic_folder.py | 10 +++++----- src/allmydata/test/test_magic_folder.py | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index ce260343..f37e77c3 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -77,18 +77,18 @@ class MagicFolder(service.MultiService): # TODO: allow a path rather than a cap URI. self._upload_dirnode = self._client.create_node_from_uri(upload_dircap) - 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.") if self._upload_dirnode.is_unknown() or self._upload_dirnode.is_readonly(): raise AssertionError("The URI in 'private/magic_folder_dircap' is not a writecap to a directory.") + 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._processed_callback = lambda ign: None self._download_callback = lambda ign: None self._upload_ignore_count = 0 diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index a49c3d90..fc57752c 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -417,9 +417,11 @@ class MockTest(MagicFolderTestMixin, unittest.TestCase): MagicFolder, client, 'bad', '', errors_dir, magicfolderdb, inotify=fake_inotify) self.shouldFail(AssertionError, 'non-directory upload.dircap', 'does not refer to a directory', MagicFolder, client, 'URI:LIT:foo', '', errors_dir, magicfolderdb, inotify=fake_inotify) - self.shouldFail(AssertionError, 'readonly upload.dircap', - '\"The URI in \'private/collective_dircap\' does not refer to a directory.\"', + self.shouldFail(AssertionError, 'readonly upload.dircap', 'is not a writecap to a directory', MagicFolder, client, readonly_dircap, '', errors_dir, magicfolderdb, inotify=fake_inotify) + self.shouldFail(AssertionError, 'collective dircap', + "The URI in 'private/collective_dircap' is not a readonly cap to a directory.", + MagicFolder, client, upload_dircap, upload_dircap, errors_dir, magicfolderdb, inotify=fake_inotify) def _not_implemented(): raise NotImplementedError("blah") -- 2.45.2