]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fix bug in test_errors and add test
authorDavid Stainton <dstainton415@gmail.com>
Wed, 15 Jul 2015 23:54:26 +0000 (16:54 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 16:56:03 +0000 (17:56 +0100)
- test that we report the correct error when
a write cap is passed as a collective dircap

src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index ce2603439f408250a17fd9a9fbb3fed2f7fd70bc..f37e77c31ede473216694380f9102ec136d142d9 100644 (file)
@@ -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
index a49c3d90d716799446bdc5e9fea41e9cdb3854cf..fc57752c9e3680c8cdc01a0db75d816266cd6d23 100644 (file)
@@ -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")