]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add file conflict unit test
authorDavid Stainton <dstainton415@gmail.com>
Tue, 27 Oct 2015 09:59:29 +0000 (10:59 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 28 Dec 2015 15:30:06 +0000 (15:30 +0000)
src/allmydata/test/test_magic_folder.py

index 733202bad98bdcee944f955613e5886f8b4a5d6c..3f1f37ac68bf070c5a6d1ece129b9be176ac96d6 100644 (file)
@@ -813,8 +813,6 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(_check_downloader_count, 'objects_conflicted', 0)
         d.addCallback(_check_downloader_count, 'objects_conflicted', 0, alice=False)
 
-
-        # XXX
         def Bob_to_rewrite_file():
             print "Bob rewrites file\n"
             self.file_path = abspath_expanduser_unicode(u"file1", base=self.bob_magicfolder.uploader._local_path_u)
@@ -839,6 +837,27 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(_check_downloader_count, 'objects_downloaded', 1, alice=False)
         d.addCallback(_check_downloader_count, 'objects_conflicted', 0, alice=False)
 
+        def Alice_conflicts_with_Bob():
+            print "Alice conflicts with Bob\n"
+            downloaded_d = self.bob_magicfolder.downloader.set_hook('processed')
+            uploadable = Data("do not follow the white rabbit", self.alice_magicfolder._client.convergence)
+            alice_dmd = self.alice_magicfolder.uploader._upload_dirnode
+            d2 = alice_dmd.add_file(u"file1", uploadable,
+                                    metadata={"version": 5,
+                                              "last_downloaded_uri" : "URI:LIT:" },
+                                    overwrite=True)
+            print "Waiting for Alice to upload\n"
+            d2.addCallback(lambda ign: bob_clock.advance(6))
+            d2.addCallback(lambda ign: downloaded_d)
+            d2.addCallback(lambda ign: self.failUnless(alice_dmd.has_child(encoded_path_u)))
+            return d2
+
+        d.addCallback(lambda ign: Alice_conflicts_with_Bob())
+        # XXX fix the code so that it doesn't increment objects_excluded each turn
+        #d.addCallback(_check_downloader_count, 'objects_excluded', 1)
+        d.addCallback(_check_downloader_count, 'objects_downloaded', 4)
+        d.addCallback(_check_downloader_count, 'objects_conflicted', 1)
+
         def _cleanup(ign, magicfolder, clock):
             if magicfolder is not None:
                 d2 = magicfolder.finish()