alice bob test alice rewrite file

This commit is contained in:
David Stainton 2015-07-14 14:54:09 -07:00 committed by Daira Hopwood
parent bdffc3c484
commit b82f66de07
2 changed files with 19 additions and 3 deletions

View File

@ -407,7 +407,7 @@ class MagicFolder(service.MultiService):
d2.addCallback(get_metadata) d2.addCallback(get_metadata)
def set_deleted(metadata): def set_deleted(metadata):
current_version = self._db.get_local_file_version(path) + 1 current_version = self._db.get_local_file_version(path) + 1
metadata['version'] = current_version metadata['version'] = current_version + 1
metadata['deleted'] = True metadata['deleted'] = True
emptyUploadable = Data("", self._convergence) emptyUploadable = Data("", self._convergence)
return self._upload_dirnode.add_file(name, emptyUploadable, overwrite=True, metadata=metadata) return self._upload_dirnode.add_file(name, emptyUploadable, overwrite=True, metadata=metadata)
@ -424,6 +424,7 @@ class MagicFolder(service.MultiService):
version = 1 version = 1
else: else:
version += 1 version += 1
print "NEW VERSION ", version
d2 = _add_file(name, version) d2 = _add_file(name, version)
def add_db_entry(filenode): def add_db_entry(filenode):
filecap = filenode.get_uri() filecap = filenode.get_uri()

View File

@ -360,10 +360,25 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
d.addCallback(Alice_delete_file) d.addCallback(Alice_delete_file)
d.addCallback(Alice_wait_for_upload) d.addCallback(Alice_wait_for_upload)
d.addCallback(Alice_prepare_for_alice_stats) 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_wait_for_download)
d.addCallback(Bob_prepare_for_stats) 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): def cleanup_Alice_and_Bob(result):
d = defer.succeed(None) d = defer.succeed(None)