def test_multiple_elem_sync_ack(self):
        obs = FromIteratorObservable(iterator=iter([[1], [2, 3], [4]]),
                                     scheduler=self.scheduler,
                                     subscribe_scheduler=self.scheduler)
        sink = TObserver()
        obs.observe(init_observer_info(sink))
        self.scheduler.advance_by(1)

        self.assertEqual([1, 2, 3, 4], sink.received)
        self.assertTrue(sink.is_completed)
    def test_multiple_elem_async_ack(self):
        obs = FromIteratorObservable(iterator=iter([[1], [2]]),
                                     scheduler=self.scheduler,
                                     subscribe_scheduler=self.scheduler)
        sink = TObserver(immediate_continue=0)
        obs.observe(init_observer_info(sink))
        self.scheduler.advance_by(1)

        self.assertEqual([1], sink.received)
        self.assertFalse(sink.is_completed)
    def test_batch(self):
        obs = FromIteratorObservable(iterator=iter([[1, 2, 3]]),
                                     scheduler=self.scheduler,
                                     subscribe_scheduler=self.scheduler)
        sink = TObserver(immediate_continue=0)
        obs.observe(init_observer_info(sink))
        self.scheduler.advance_by(1)

        self.assertEqual([1, 2, 3], sink.received)
        self.assertTrue(sink.is_completed)
    def test_empty_iterable(self):
        obs = FromIteratorObservable(iterator=iter([]),
                                     scheduler=self.scheduler,
                                     subscribe_scheduler=self.scheduler)
        sink = TObserver()

        obs.observe(init_observer_info(sink))
        self.scheduler.advance_by(1)

        self.assertEqual([], sink.received)
        self.assertTrue(sink.is_completed)
Example #5
0
    def unsafe_subscribe(self, subscriber: Subscriber) -> Subscription:
        iterator = iter(self.iterable)

        return init_subscription(observable=FromIteratorObservable(
            iterator=iterator,
            subscribe_scheduler=subscriber.subscribe_scheduler,
            scheduler=subscriber.scheduler,
        ), )
    def unsafe_subscribe(self, subscriber: Subscriber) -> Subscription:
        iterator = iter(self.iterable)

        return init_indexed_subscription(
            index=FlowableBaseAndSelectors(
                base=self.base,
            ),
            observable=FromIteratorObservable(
                iterator=iterator,
                subscribe_scheduler=subscriber.subscribe_scheduler,
                scheduler=subscriber.scheduler,
            ),
        )
 def test_initialize(self):
     FromIteratorObservable(iterator=iter([]),
                            scheduler=self.scheduler,
                            subscribe_scheduler=self.scheduler)