From b82f66de07bde7bf3d264f76503136db2983f103 Mon Sep 17 00:00:00 2001 From: David Stainton Date: Tue, 14 Jul 2015 14:54:09 -0700 Subject: [PATCH] alice bob test alice rewrite file --- src/allmydata/frontends/magic_folder.py | 3 ++- src/allmydata/test/test_magic_folder.py | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 6169161b..fc9a2ad1 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -407,7 +407,7 @@ class MagicFolder(service.MultiService): d2.addCallback(get_metadata) def set_deleted(metadata): current_version = self._db.get_local_file_version(path) + 1 - metadata['version'] = current_version + metadata['version'] = current_version + 1 metadata['deleted'] = True emptyUploadable = Data("", self._convergence) return self._upload_dirnode.add_file(name, emptyUploadable, overwrite=True, metadata=metadata) @@ -424,6 +424,7 @@ class MagicFolder(service.MultiService): version = 1 else: version += 1 + print "NEW VERSION ", version d2 = _add_file(name, version) def add_db_entry(filenode): filecap = filenode.get_uri() diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 0a8ac9fc..279cffc3 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -360,10 +360,25 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual d.addCallback(Alice_delete_file) d.addCallback(Alice_wait_for_upload) d.addCallback(Alice_prepare_for_alice_stats) - d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 2)) # XXX ? + d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 2)) d.addCallback(Bob_wait_for_download) d.addCallback(Bob_prepare_for_stats) - d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_downloaded'), 2)) # XXX ? + d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_downloaded'), 2)) + + def Alice_rewrite_file(result): + print "Alice rewrites file\n" + self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder._local_dir) + 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_wait_for_upload) + d.addCallback(Alice_prepare_for_alice_stats) + d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 3)) + d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.files_uploaded'), 2)) + 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) -- 2.45.2