]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix db persistence unit test for uploader
authorDavid Stainton <dstainton415@gmail.com>
Tue, 21 Apr 2015 07:17:24 +0000 (08:17 +0100)
committerDavid Stainton <dstainton415@gmail.com>
Tue, 21 Apr 2015 07:17:24 +0000 (08:17 +0100)
src/allmydata/test/test_drop_upload.py

index 74e0e16a3b1ba1e4ba596a5e33dabd3c42f5bf76..f16888821c63b01ed2bf5afc1632a89433e55027 100644 (file)
@@ -142,35 +142,27 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         self.stats_provider = self.client.stats_provider
         d = self.client.create_dirnode()
         d.addCallback(self._made_upload_dir)
-        d.addCallback(self._cleanup)
-        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 0))
-        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
-        d.addCallback(lambda ign: self.client.removeService(self.uploader))
-
-        def msg(val):
-            print "old uploader removed"
-            return None
-        d.addCallback(msg)
         
         def create_file(val):
+            d2 = defer.Deferred()
+            self.uploader.set_uploaded_callback(d2.callback)
             myFile = os.path.join(self.local_dir, "what")
             f = open(myFile, "wb")
             f.write("meow")
             f.close()
-            print "test file created"
-            return None
+            self.notify_close_write(FilePath(myFile))
+            return d2
         d.addCallback(create_file)
-        
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
+        d.addCallback(self._cleanup)
+        d.addCallback(lambda ign: self.client.removeService(self.uploader))
+
         d.addCallback(self._made_upload_dir)
-        def resume_uploader(val):
-            print "created new uploader"
-            d = defer.Deferred()
-            self.uploader.set_uploaded_callback(d.callback)
-            return d
-        d.addCallback(resume_uploader)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1))
         d.addBoth(self._cleanup)
+
         return d
 
     def _test(self):