From: Daira Hopwood Date: Tue, 28 Apr 2015 18:37:08 +0000 (+0100) Subject: Add very basic unit tests for dir scan and db X-Git-Url: https://git.rkrishnan.org/pf?a=commitdiff_plain;h=2d7e577de1a6aeeb423b89511f6e764e999bb93d;p=tahoe-lafs%2Ftahoe-lafs.git Add very basic unit tests for dir scan and db Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index 8dfc7449..e5174d04 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -117,8 +117,6 @@ class DropUploader(service.MultiService): if self._db is None: return Failure(Exception('ERROR: Unable to load magic folder db.')) - self._scan(self._local_path) - service.MultiService.startService(self) d = self._notifier.startReading() diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index 163263cd..00dabcab 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -220,6 +220,39 @@ class MockTest(DropUploadTestMixin, unittest.TestCase): class RealTest(DropUploadTestMixin, unittest.TestCase): """This is skipped unless both Twisted and the platform support inotify.""" + def test_db_basic(self): + self.basedir = basedir = os.path.join("dropupload", "basic") + fileutil.make_dirs(basedir) + dbfile = os.path.join(basedir, "dbfile") + bdb = self.create(dbfile) + + def test_uploader_startService(self): + self.uploader = None + self.inotify = None # use the appropriate inotify for the platform + self.basedir = "drop_upload.RealTest.test_uploader_startService" + self.set_up_grid() + self.client = self.g.clients[0] + + d = self.client.create_dirnode() + def _made_upload_dir(n): + self.failUnless(IDirectoryNode.providedBy(n)) + self.upload_dirnode = n + self.upload_dircap = n.get_uri() + self.uploader = DropUploader(self.client, self.upload_dircap, self.basedir.encode('utf-8'), + "magicfolderdb.sqlite", inotify=self.inotify) + self.uploader.startService() + self.failUnlessEqual(self.uploader._db.VERSION, 2) + d.addCallback(_made_upload_dir) + + # Prevent unclean reactor errors. + def _cleanup(res): + d = defer.succeed(None) + if self.uploader is not None: + d.addCallback(lambda ign: self.uploader.finish(for_tests=True)) + d.addCallback(lambda ign: res) + return d + d.addBoth(_cleanup) + return d def test_drop_upload(self): # We should always have runtime.platform.supportsINotify, because we're using