]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Try to fix some tests - WIP.
authorDaira Hopwood <daira@jacaranda.org>
Mon, 27 Jul 2015 16:51:40 +0000 (17:51 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 16:56:04 +0000 (17:56 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index f4ec692e1fd411d5da7641fc7695d17edd930e9e..4627e471ad553ccee50307280f0dc2c82f9f4bf4 100644 (file)
@@ -52,8 +52,11 @@ class MagicFolder(service.MultiService):
         if db is None:
             return Failure(Exception('ERROR: Unable to load magic folder db.'))
 
-        self.is_ready = False
+        # for tests
+        self._client = client
+        self._db = db
 
+        self.is_ready = False
 
         self.uploader = Uploader(client, local_path_u, db, upload_dircap, inotify, pending_delay)
         self.downloader = Downloader(client, local_path_u, db, collective_dircap)
index 95075c8b00b42e22cd8d315e3af7a57a90716502..b6bd532330b29b4513fd859dd4c1454165117c3d 100644 (file)
@@ -128,7 +128,7 @@ class MagicFolderTestMixin(MagicFolderTestMixin, ShouldFailMixin, ReallyEqualMix
         def _check_move_empty_tree(res):
             self.mkdir_nonascii(empty_tree_dir)
             d2 = defer.Deferred()
-            self.magicfolder.set_callback(d2.callback)
+            self.magicfolder.uploader.set_callback(d2.callback)
             os.rename(empty_tree_dir, new_empty_tree_dir)
             self.notify(to_filepath(new_empty_tree_dir), self.inotify.IN_MOVED_TO)
             return d2
@@ -204,7 +204,7 @@ class MagicFolderTestMixin(MagicFolderTestMixin, ShouldFailMixin, ReallyEqualMix
 
         def create_test_file(result):
             d2 = defer.Deferred()
-            self.magicfolder.set_callback(d2.callback)
+            self.magicfolder.uploader.set_callback(d2.callback)
             test_file = abspath_expanduser_unicode(u"what", base=self.local_dir)
             fileutil.write(test_file, "meow")
             self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
@@ -279,7 +279,7 @@ class MagicFolderTestMixin(MagicFolderTestMixin, ShouldFailMixin, ReallyEqualMix
         # Note: this relies on the fact that we only get one IN_CLOSE_WRITE notification per file
         # (otherwise we would get a defer.AlreadyCalledError). Should we be relying on that?
         d = defer.Deferred()
-        self.magicfolder.set_callback(d.callback)
+        self.magicfolder.uploader.set_callback(d.callback)
 
         path_u = abspath_expanduser_unicode(name_u, base=self.local_dir)
         path = to_filepath(path_u)
@@ -334,7 +334,8 @@ class MagicFolderTestMixin(MagicFolderTestMixin, ShouldFailMixin, ReallyEqualMix
 
         def Alice_write_a_file(result):
             print "Alice writes a file\n"
-            self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder.uploader.local_path)
+            # XXX simplify by just using FilePath and setContent
+            self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder.uploader._local_path_u)
             fileutil.write(self.file_path, "meow, meow meow. meow? meow meow! meow.")
             self.magicfolder = self.alice_magicfolder
             self.notify(to_filepath(self.file_path), self.inotify.IN_CLOSE_WRITE)
@@ -358,7 +359,7 @@ class MagicFolderTestMixin(MagicFolderTestMixin, ShouldFailMixin, ReallyEqualMix
         def Bob_wait_for_download(result):
             print "Bob waits for a download\n"
             d2 = defer.Deferred()
-            self.bob_magicfolder.set_download_callback(d2.callback)
+            self.bob_magicfolder.downloader.set_callback(d2.callback)
             return d2
         d.addCallback(Bob_wait_for_download)
         #d.addCallback(lambda ign: self._check_version_in_local_db(self.bob_magicfolder, u"file1", 0))