def test_use_case(self):
        sink = TObserver(immediate_continue=0)
        subscription = rxbp.from_range(1, 4).unsafe_subscribe(self.subscriber)
        subscription.observable.observe(init_observer_info(observer=sink))

        self.scheduler.advance_by(1)

        self.assertEqual([1, 2, 3], sink.received)
        self.assertTrue(sink.is_completed)
示例#2
0
    def test_happy_case(self):
        sink = TObserver(immediate_continue=0)
        subscription = rxbp.from_range(1, 4).unsafe_subscribe(Subscriber(
            scheduler=self.scheduler,
            subscribe_scheduler=self.scheduler,
        ))
        disposable = subscription.observable.observe(ObserverInfo(
            observer=sink
        ))

        self.scheduler.advance_by(1)

        self.assertEqual([1, 2, 3], sink.received)
        self.assertTrue(sink.is_completed)
    def test_from_list_batch_size_of_two(self):
        sink = TObserver(immediate_continue=0)
        subscription = rxbp.from_range(1, 4, batch_size=2).unsafe_subscribe(
            self.subscriber)
        subscription.observable.observe(init_observer_info(observer=sink))

        self.scheduler.advance_by(1)

        self.assertEqual([1, 2], sink.received)

        sink.ack.on_next(continue_ack)
        self.scheduler.advance_by(1)

        self.assertEqual([1, 2, 3], sink.received)
        self.assertTrue(sink.is_completed)
示例#4
0
    def test_from_list_batch_size_of_one(self):
        sink = TObserver(immediate_continue=0)
        subscription = rxbp.from_range(1, 4, batch_size=1).unsafe_subscribe(
            Subscriber(scheduler=self.scheduler,
                       subscribe_scheduler=self.scheduler))
        subscription.observable.observe(ObserverInfo(observer=sink))

        self.scheduler.advance_by(1)

        self.assertEqual([1], sink.received)
        self.assertFalse(sink.is_completed)

        sink.ack.on_next(continue_ack)
        self.scheduler.advance_by(1)

        self.assertEqual([1, 2], sink.received)
示例#5
0
    def test_base(self):
        subscription = rxbp.from_range(1, 4).unsafe_subscribe(
            Subscriber(scheduler=self.scheduler,
                       subscribe_scheduler=self.scheduler))

        self.assertEqual(NumericalBase(3), subscription.info.base)
示例#6
0
import rxbp

source = rxbp.from_range(2).pipe(rxbp.op.map(lambda v: v + 2), )

result = rxbp.multicast.from_flowable(source).pipe(
    rxbp.multicast.op.map(lambda v: rxbp.from_range(v))).to_flowable().run()

print(result)