def test_complete_first_source2(self):
        sink = TObserver()
        observer = FlatConcatNoBackpressureObserver(
            next_observer=sink,
            selector=lambda v: v,
            scheduler=self.scheduler,
            subscribe_scheduler=self.scheduler,
            composite_disposable=self.composite_disposable,
        )
        self.source.observe(init_observer_info(observer=observer))
        self.source.on_next_single(self.source1)
        self.scheduler.advance_by(1)
        self.source1.on_next_single(1)
        self.source.on_next_single(self.source2)
        self.scheduler.advance_by(1)
        self.source.on_completed()
        self.source2.on_next_single('a')
        self.source1.on_next_single(2)
        self.source1.on_completed()
        self.source2.on_next_single('b')

        self.source2.on_completed()

        self.assertEqual([1, 2, 'a', 'b'], sink.received)
        self.assertTrue(sink.is_completed)
 def test_initialize(self):
     sink = TObserver()
     observer = FlatConcatNoBackpressureObserver(
         next_observer=sink,
         selector=lambda v: v,
         scheduler=self.scheduler,
         subscribe_scheduler=self.scheduler,
         composite_disposable=self.composite_disposable,
     )
     self.source.observe(init_observer_info(observer=observer))
    def test_inner_on_next(self):
        sink = TObserver()
        observer = FlatConcatNoBackpressureObserver(
            next_observer=sink,
            selector=lambda v: v,
            scheduler=self.scheduler,
            subscribe_scheduler=self.scheduler,
            composite_disposable=self.composite_disposable,
        )
        self.source.observe(init_observer_info(observer=observer))
        self.source.on_next_single(self.source1)
        self.scheduler.advance_by(1)

        self.source1.on_next_single(1)

        self.assertEqual([1], sink.received)
    def test_on_next_does_not_backpressure(self):
        sink = TObserver()
        observer = FlatConcatNoBackpressureObserver(
            next_observer=sink,
            selector=lambda v: v,
            scheduler=self.scheduler,
            subscribe_scheduler=self.scheduler,
            composite_disposable=self.composite_disposable,
        )
        self.source.observe(init_observer_info(observer=observer))

        ack1 = self.source.on_next_single(self.source1)
        ack2 = self.source.on_next_single(self.source2)

        self.assertIsInstance(ack1, ContinueAck)
        self.assertIsInstance(ack2, ContinueAck)
Example #5
0
    def observe(self, observer_info: ObserverInfo):
        composite_disposable = CompositeDisposable()

        concat_observer = FlatConcatNoBackpressureObserver(
            next_observer=observer_info.observer,
            selector=self.selector,
            scheduler=self.scheduler,
            subscribe_scheduler=self.subscribe_scheduler,
            composite_disposable=composite_disposable,
        )

        disposable = self.source.observe(
            observer_info.copy(observer=concat_observer))
        composite_disposable.add(disposable)

        return composite_disposable