def test_single_batch(self): sink = TObserver() observer = FilterObserver( observer=sink, predicate=lambda v: v > 0, ) self.source.observe(init_observer_info(observer)) self.source.on_next_list([0, 1, 0, 2]) self.assertEqual([1, 2], sink.received)
def test_single_elem_fulfill_predicate(self): sink = TObserver() observer = FilterObserver( observer=sink, predicate=lambda v: v > 0, ) self.source.observe(init_observer_info(observer)) self.source.on_next_single(1) self.assertEqual([1], sink.received)
def test_on_error(self): sink = TObserver() observer = FilterObserver( observer=sink, predicate=lambda v: v > 0, ) self.source.observe(init_observer_info(observer)) self.source.on_error(self.exc) self.assertEqual(self.exc, sink.exception)
def test_on_complete(self): sink = TObserver() observer = FilterObserver( observer=sink, predicate=lambda v: v > 0, ) self.source.observe(init_observer_info(observer)) self.source.on_completed() self.assertTrue(sink.is_completed)
def observe(self, observer_info: ObserverInfo): subscription = observer_info.copy(observer=FilterObserver( observer=observer_info.observer, predicate=self.predicate, ), ) return self.source.observe(subscription)
def test_initialize(self): sink = TObserver() FilterObserver( observer=sink, predicate=lambda _: True, )