Teach Alice to upload file for Alice+Bob test
authorDavid Stainton <dstainton415@gmail.com>
Tue, 30 Jun 2015 21:58:20 +0000 (14:58 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:44 +0000 (01:19 +0100)
note: this is not yet working for the mock test; the real
test passes.

src/allmydata/test/test_cli_magic_folder.py
src/allmydata/test/test_magic_folder.py

index b97ee0d0d14bc8741d5d87168475bb45b6c02758..ee235bcda450cde211605a9adaa80318c7ae6601 100644 (file)
@@ -163,6 +163,7 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin):
         d.addCallback(prepare_result)
         return d
 
+
 class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
 
     def test_create_and_then_invite_join(self):
index 6729fdd220f8ffaf521e56bbd52e598f3e7ae905..190b19180639129bc814c7367480204cab07e614 100644 (file)
@@ -19,7 +19,7 @@ from allmydata.frontends import magic_folder
 from allmydata.frontends.magic_folder import MagicFolder
 from allmydata import backupdb
 from allmydata.util.fileutil import abspath_expanduser_unicode
-
+from allmydata.util import fileutil
 
 class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqualMixin, NonASCIIPathMixin):
     """
@@ -322,6 +322,25 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
             self.alice_collective_dir, self.alice_upload_dircap, self.alice_magicfolder, self.bob_collective_dircap, self.bob_upload_dircap, self.bob_magicfolder = result
         d.addCallback(get_results)
 
+        def write_a_file(result):
+            file_path = os.path.join(self.alice_magicfolder._local_dir, "file1")
+            fileutil.write(file_path, "meow, meow meow. meow? meow meow! meow.")
+            # XXX fix me --> self.notify(file_path, self.inotify.IN_CLOSE_WRITE)
+        d.addCallback(write_a_file)
+
+        def wait_for_upload(result):
+            d2 = defer.Deferred()
+            self.alice_magicfolder.set_processed_callback(d2.callback, ignore_count=0)
+            return d2
+        d.addCallback(wait_for_upload)
+        def prepare_for_stats(result):
+            self.stats_provider = self.alice_magicfolder._client.stats_provider
+        d.addCallback(prepare_for_stats)
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 1))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.files_uploaded'), 1))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 0))
+
         def cleanup_Alice_and_Bob(result):
             d = defer.succeed(None)
             d.addCallback(lambda ign: self.alice_magicfolder.finish(for_tests=True))