Teach test_persistence to upload a 2nd file

test fails...
This commit is contained in:
David Stainton 2015-09-11 13:37:01 +02:00
parent 871408f76a
commit b11bebc129
2 changed files with 18 additions and 4 deletions

View File

@ -203,7 +203,10 @@ class Uploader(QueueMixin):
return d return d
def start_scanning(self): def start_scanning(self):
print "start_scanning self._db = %r" % (self._db,)
self.is_ready = True self.is_ready = True
all_files = self._db.get_all_files()
print "ALL files recorded in magic-folder db: %s" % (all_files,)
d = self._scan(self._local_path_u) # XXX do not want dropped deferreds! d = self._scan(self._local_path_u) # XXX do not want dropped deferreds!
self._turn_deque() self._turn_deque()
return d return d
@ -337,6 +340,7 @@ class Uploader(QueueMixin):
return upload_d return upload_d
elif pathinfo.isfile: elif pathinfo.isfile:
version = self._db.get_local_file_version(relpath_u) version = self._db.get_local_file_version(relpath_u)
print "LOCAL version %s" % (version,)
if version is None: if version is None:
version = 0 version = 0
else: else:

View File

@ -203,18 +203,28 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
d = self.create_invite_join_magic_folder(u"Alice", self.local_dir) d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
d.addCallback(self._create_magicfolder) d.addCallback(self._create_magicfolder)
def create_test_file(result): def create_test_file(result, filename):
d2 = self.magicfolder.uploader.set_hook('processed') d2 = self.magicfolder.uploader.set_hook('processed')
test_file = abspath_expanduser_unicode(u"what", base=self.local_dir) test_file = abspath_expanduser_unicode(filename, base=self.local_dir)
fileutil.write(test_file, "meow") fileutil.write(test_file, "meow")
self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE) self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
return d2 return d2
d.addCallback(create_test_file) d.addCallback(lambda ign: create_test_file(ign, u"what1"))
def fu(ign):
print "upload complete"
d.addBoth(fu)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1)) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1))
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0)) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
d.addCallback(self.cleanup) d.addCallback(self.cleanup)
d.addCallback(self._restart_client) d.addCallback(self._restart_client)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 0))
d.addCallback(lambda ign: create_test_file(ign, u"what2"))
def fu2(ign):
print "2nd upload complete"
d.addBoth(fu2)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1))
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0)) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
d.addBoth(self.cleanup) d.addBoth(self.cleanup)
return d return d