From: David Stainton Date: Wed, 15 Jul 2015 23:54:26 +0000 (-0700) Subject: fix bug in test_errors and add test X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/-?a=commitdiff_plain;h=57fc30be44d118e4710f3d925c302ab7a1d40a23;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- 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")