예제 #1
0
 def setUp(self):
     mock_conf_settings(self)
     self.blob_manager = mock.Mock()
     self.payment_rate_manager = NegotiatedPaymentRateManager(
         BasePaymentRateManager(0.001), DummyBlobAvailabilityTracker())
     self.handler = BlobRequestHandler.BlobRequestHandler(
         self.blob_manager, None, self.payment_rate_manager, None)
예제 #2
0
 def test_file_is_sent_to_consumer(self):
     # TODO: also check that the expected payment values are set
     consumer = proto_helpers.StringTransport()
     test_file = StringIO.StringIO('test')
     handler = BlobRequestHandler.BlobRequestHandler(None, None, None, None)
     handler.peer = mock.create_autospec(Peer.Peer)
     handler.currently_uploading = mock.Mock()
     handler.read_handle = test_file
     handler.send_blob_if_requested(consumer)
     while consumer.producer:
         consumer.producer.resumeProducing()
     self.assertEqual(consumer.value(), 'test')
예제 #3
0
 def test_nothing_happens_if_not_currently_uploading(self):
     handler = BlobRequestHandler.BlobRequestHandler(None, None, None, None)
     handler.currently_uploading = None
     deferred = handler.send_blob_if_requested(None)
     self.assertEqual(True, self.successResultOf(deferred))
예제 #4
0
 def setUp(self):
     self.blob_manager = mock.Mock()
     self.payment_rate_manager = mock.Mock()
     self.handler = BlobRequestHandler.BlobRequestHandler(
         self.blob_manager, None, self.payment_rate_manager)