class TestProvideSizeSubscriber(unittest.TestCase):
    def setUp(self):
        self.transfer_future = mock.Mock(spec=TransferFuture)
        self.transfer_meta = TransferMeta()
        self.transfer_future.meta = self.transfer_meta

    def test_size_set(self):
        self.transfer_meta.provide_transfer_size(5)
        subscriber = ProvideSizeSubscriber(10)
        subscriber.on_queued(self.transfer_future)
        self.assertEqual(self.transfer_meta.size, 10)
Example #2
0
class TestProvideSizeSubscriber(unittest.TestCase):
    def setUp(self):
        self.transfer_future = mock.Mock(spec=TransferFuture)
        self.transfer_meta = TransferMeta()
        self.transfer_future.meta = self.transfer_meta

    def test_size_set(self):
        self.transfer_meta.provide_transfer_size(5)
        subscriber = ProvideSizeSubscriber(10)
        subscriber.on_queued(self.transfer_future)
        self.assertEqual(self.transfer_meta.size, 10)
Example #3
0
 def setUp(self):
     self.subscriber = RecordingSubscriber()
     self.second_subscriber = RecordingSubscriber()
     self.call_args = CallArgs(
         subscribers=[self.subscriber, self.second_subscriber])
     self.transfer_meta = TransferMeta(self.call_args)
     self.transfer_future = TransferFuture(self.transfer_meta)
Example #4
0
class TestTransferMeta(unittest.TestCase):
    def setUp(self):
        self.transfer_meta = TransferMeta()

    def test_size(self):
        self.assertEqual(self.transfer_meta.size, None)
        self.transfer_meta.provide_transfer_size(5)
        self.assertEqual(self.transfer_meta.size, 5)

    def test_call_args(self):
        call_args = object()
        transfer_meta = TransferMeta(call_args)
        # Assert the that call args provided is the same as is returned
        self.assertIs(transfer_meta.call_args, call_args)

    def test_transfer_id(self):
        transfer_meta = TransferMeta(transfer_id=1)
        self.assertEqual(transfer_meta.transfer_id, 1)

    def test_user_context(self):
        self.transfer_meta.user_context['foo'] = 'bar'
        self.assertEqual(self.transfer_meta.user_context, {'foo': 'bar'})
Example #5
0
class TestTransferMeta(unittest.TestCase):
    def setUp(self):
        self.transfer_meta = TransferMeta()

    def test_size(self):
        self.assertEqual(self.transfer_meta.size, None)
        self.transfer_meta.provide_transfer_size(5)
        self.assertEqual(self.transfer_meta.size, 5)

    def test_call_args(self):
        call_args = object()
        transfer_meta = TransferMeta(call_args)
        # Assert the that call args provided is the same as is returned
        self.assertIs(transfer_meta.call_args, call_args)

    def test_transfer_id(self):
        transfer_meta = TransferMeta(transfer_id=1)
        self.assertEqual(transfer_meta.transfer_id, 1)

    def test_user_context(self):
        self.transfer_meta.user_context['foo'] = 'bar'
        self.assertEqual(self.transfer_meta.user_context, {'foo': 'bar'})
Example #6
0
 def _get_future_with_components(self, call_args):
     transfer_id = self._id_counter
     # Creates a new transfer future along with its components
     transfer_coordinator = TransferCoordinator(transfer_id=transfer_id)
     # Track the transfer coordinator for transfers to manage.
     self._coordinator_controller.add_transfer_coordinator(
         transfer_coordinator)
     # Also make sure that the transfer coordinator is removed once
     # the transfer completes so it does not stick around in memory.
     transfer_coordinator.add_done_callback(
         self._coordinator_controller.remove_transfer_coordinator,
         transfer_coordinator)
     components = {
         'meta': TransferMeta(call_args, transfer_id=transfer_id),
         'coordinator': transfer_coordinator
     }
     transfer_future = TransferFuture(**components)
     return transfer_future, components
Example #7
0
 def setUp(self):
     self.transfer_meta = TransferMeta()
Example #8
0
 def setUp(self):
     self.meta = TransferMeta()
     self.coordinator = TransferCoordinator()
     self.future = self._get_transfer_future()
Example #9
0
 def test_transfer_id(self):
     transfer_meta = TransferMeta(transfer_id=1)
     self.assertEqual(transfer_meta.transfer_id, 1)
Example #10
0
 def test_call_args(self):
     call_args = object()
     transfer_meta = TransferMeta(call_args)
     # Assert the that call args provided is the same as is returned
     self.assertIs(transfer_meta.call_args, call_args)
Example #11
0
 def setUp(self):
     self.transfer_future = mock.Mock(spec=TransferFuture)
     self.transfer_meta = TransferMeta()
     self.transfer_future.meta = self.transfer_meta
 def setUp(self):
     self.transfer_future = mock.Mock(spec=TransferFuture)
     self.transfer_meta = TransferMeta()
     self.transfer_future.meta = self.transfer_meta
Example #13
0
 def setUp(self):
     self.transfer_meta = TransferMeta()
Example #14
0
 def get_transfer_future(self, call_args=None):
     return TransferFuture(meta=TransferMeta(call_args),
                           coordinator=self.transfer_coordinator)