]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Teach test_alice_bob to fail if local version is wrong
authorDavid Stainton <dstainton415@gmail.com>
Thu, 24 Sep 2015 08:25:23 +0000 (10:25 +0200)
committerDaira Hopwood <daira@jacaranda.org>
Wed, 30 Sep 2015 15:45:27 +0000 (16:45 +0100)
src/allmydata/test/test_magic_folder.py

index ee2e44e31e3a60d11592560558fe1e4a1e419feb..feedfe3cee1517af51f8babcf2c32749d6de8891 100644 (file)
@@ -320,7 +320,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(get_results)
 
         def Alice_write_a_file(result):
-            #print "Alice writes a file\n"
+            print "Alice writes a file\n"
             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
@@ -329,7 +329,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(Alice_write_a_file)
 
         def Alice_wait_for_upload(result):
-            #print "Alice waits for an upload\n"
+            print "Alice waits for an upload\n"
             d2 = self.alice_magicfolder.uploader.set_hook('processed')
             return d2
         d.addCallback(Alice_wait_for_upload)
@@ -343,7 +343,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.directories_created', client=self.alice_magicfolder._client), 0))
 
         def Bob_wait_for_download(result):
-            #print "Bob waits for a download\n"
+            print "Bob waits for a download\n"
             d2 = self.bob_magicfolder.downloader.set_hook('processed')
             return d2
         d.addCallback(Bob_wait_for_download)
@@ -355,7 +355,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         # test deletion of file behavior
         def Alice_delete_file(result):
-            #print "Alice deletes the file!\n"
+            print "Alice deletes the file!\n"
             os.unlink(self.file_path)
             self.notify(to_filepath(self.file_path), self.inotify.IN_DELETE)
 
@@ -373,16 +373,20 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(lambda ign: self._check_version_in_local_db(self.bob_magicfolder, u"file1", 1))
         d.addCallback(lambda ign: self._check_version_in_dmd(self.bob_magicfolder, u"file1", 1))
 
-
         def Alice_rewrite_file(result):
-            #print "Alice rewrites file\n"
+            print "Alice rewrites file\n"
             self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder.uploader._local_path_u)
             fileutil.write(self.file_path, "Alice suddenly sees the white rabbit running into the forest.")
             self.magicfolder = self.alice_magicfolder
             self.notify(to_filepath(self.file_path), self.inotify.IN_CLOSE_WRITE)
-        d.addCallback(Alice_rewrite_file)
 
+        d.addCallback(Alice_rewrite_file)
+        d.addCallback(lambda ign: self._check_version_in_local_db(self.bob_magicfolder, u"file1", 1))
         d.addCallback(Alice_wait_for_upload)
+
+        d.addCallback(lambda ign: self._check_version_in_dmd(self.alice_magicfolder, u"file1", 2))
+        d.addCallback(lambda ign: self._check_version_in_local_db(self.alice_magicfolder, u"file1", 2))
+
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_failed'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded', client=self.alice_magicfolder._client), 3))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.files_uploaded', client=self.alice_magicfolder._client), 3))
@@ -390,10 +394,13 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.directories_created', client=self.alice_magicfolder._client), 0))
 
         d.addCallback(Bob_wait_for_download)
+        d.addCallback(lambda ign: self._check_version_in_dmd(self.bob_magicfolder, u"file1", 2))
+        d.addCallback(lambda ign: self._check_version_in_local_db(self.bob_magicfolder, u"file1", 2))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('downloader.objects_failed'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('downloader.objects_downloaded', client=self.bob_magicfolder._client), 3))
 
         def cleanup_Alice_and_Bob(result):
+            print "cleanup alice bob test\n"
             d = defer.succeed(None)
             d.addCallback(lambda ign: self.alice_magicfolder.finish())
             d.addCallback(lambda ign: self.bob_magicfolder.finish())