drop-upload test for non-existent local dir separately from test for non-directory...
authorZooko O'Whielacronx <zooko@zooko.com>
Tue, 9 Aug 2011 22:01:15 +0000 (15:01 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Tue, 9 Aug 2011 22:01:15 +0000 (15:01 -0700)
A candidate patch for #1429 has a bug when it is using FilePath.is_dir() to detect whether the configured local dir exists and is a directory. FilePath.is_dir() raises exception, instead of returning False, if the thing doesn't exist. This test is to make sure that DropUploader.__init__ raise different exceptions for those two cases.
refs #1429

src/allmydata/test/test_drop_upload.py

index ab403a768621a087bb81aeb0b2b842f5cfde0cde..81fa51d8b1500ac60825606baeff1e3335b78e2f 100644 (file)
@@ -167,10 +167,15 @@ class MockTest(DropUploadTestMixin, unittest.TestCase):
 
             self.shouldFail(AssertionError, 'invalid local dir', 'could not be represented',
                             DropUploader, client, upload_dircap, '\xFF', inotify=fake_inotify)
-            self.shouldFail(AssertionError, 'non-existant local dir', 'not an existing directory',
+            self.shouldFail(AssertionError, 'non-existant local dir', 'there is no directory',
                             DropUploader, client, upload_dircap, os.path.join(self.basedir, "Laputa"), inotify=fake_inotify)
 
-            self.shouldFail(AssertionError, 'bad URI', 'not a directory URI',
+            fp = filepath.FilePath(self.basedir).child('IM_NOT_A_DIR')
+            fp.touch()
+            self.shouldFail(AssertionError, 'non-existant local dir', 'is not a directory',
+                            DropUploader, client, upload_dircap, fp.path, inotify=fake_inotify)
+
+            self.shouldFail(AssertionError, 'bad cap', 'does not refer to a directory',
                             DropUploader, client, 'bad', errors_dir, inotify=fake_inotify)
             self.shouldFail(AssertionError, 'non-directory cap', 'does not refer to a directory',
                             DropUploader, client, 'URI:LIT:foo', errors_dir, inotify=fake_inotify)