def test_on_completed_equality(): n1 = OnCompleted() n2 = OnCompleted() n3 = OnNext(2) assert(n1.equals(n1)) assert(n1.equals(n2)) assert(n2.equals(n1)) assert(not n1.equals(None)) assert(not n1.equals(n3)) assert(not n3.equals(n1))
def test_on_completed_equality(): n1 = OnCompleted() n2 = OnCompleted() n3 = OnNext(2) assert (n1.equals(n1)) assert (n1.equals(n2)) assert (n2.equals(n1)) assert (not n1.equals(None)) assert (not n1.equals(n3)) assert (not n3.equals(n1))
def test_on_next_accept_observer_with_result(): n1 = OnNext(42) def on_next(x): return "OK" def on_error(err): assert(False) def on_completed(): assert(False) res = n1.accept(AcceptObserver(on_next, on_error, on_completed)) assert('OK' == res)
def test_on_next_accept_action(): obs = [False] n1 = OnNext(42) def on_next(x): obs[0] = True return obs[0] def on_error(err): assert(False) def on_completed(): assert(False) n1.accept(on_next, on_error, on_completed) assert(obs[0])
def test_on_next_accept_action(): obs = False n1 = OnNext(42) def on_next(x): nonlocal obs obs = True return obs def on_error(err): assert(False) def on_completed(): assert(False) n1.accept(on_next, on_error, on_completed) assert(obs)
def test_on_next_accept_observer_with_result(): n1 = OnNext(42) def on_next(x): return "OK" def on_error(err): assert (False) def on_completed(): assert (False) res = n1.accept(AcceptObserver(on_next, on_error, on_completed)) assert ('OK' == res)
def test_on_next_equality(): n1 = OnNext(42) n2 = OnNext(42) n3 = OnNext(24) n4 = OnCompleted() assert(n1.equals(n1)) assert(n1.equals(n2)) assert(n2.equals(n1)) assert(not n1.equals(None)) assert(not n1.equals(n3)) assert(not n3.equals(n1)) assert(not n1.equals(n4)) assert(not n4.equals(n1))
def test_on_next_accept_action(): obs = [False] n1 = OnNext(42) def on_next(x): obs[0] = True return obs[0] def on_error(err): assert (False) def on_completed(): assert (False) n1.accept(on_next, on_error, on_completed) assert (obs[0])
def test_on_next_accept_action(): obs = False n1 = OnNext(42) def on_next(x): nonlocal obs obs = True return obs def on_error(err): assert (False) def on_completed(): assert (False) n1.accept(on_next, on_error, on_completed) assert (obs)
def test_to_notifier_forwards(): obsn = MyObserver() obsn.to_notifier()(OnNext(42)) assert (obsn.has_on_next == 42) ex = 'ex' obse = MyObserver() obse.to_notifier()(OnError(ex)) assert (ex == obse.has_on_error) obsc = MyObserver() obsc.to_notifier()(OnCompleted()) assert (obsc.has_on_completed)
def on_next(cls, ticks, value): if type(value) == types.FunctionType: return Recorded(ticks, OnNextPredicate(value)) return Recorded(ticks, OnNext(value))
def on_next(value): observer.on_next(OnNext(value))
def on_next(self, value): self.messages.append(Recorded(self.scheduler.clock, OnNext(value)))
def test_on_next_equality(): n1 = OnNext(42) n2 = OnNext(42) n3 = OnNext(24) n4 = OnCompleted() assert (n1.equals(n1)) assert (n1.equals(n2)) assert (n2.equals(n1)) assert (not n1.equals(None)) assert (not n1.equals(n3)) assert (not n3.equals(n1)) assert (not n1.equals(n4)) assert (not n4.equals(n1))
def test_on_next_ctor_and_props(): n = OnNext(42) assert ('N' == n.kind) assert (n.has_value) assert (42 == n.value) assert (not hasattr(n, "exception"))
def test_on_next_accept_observer(): con = CheckOnNextObserver() n1 = OnNext(42) n1.accept(con) assert(42 == con.value)
def create(): return OnNext(42).to_observable(scheduler)
def test_on_next_tostring(): n1 = OnNext(42) assert ("OnNext" in str(n1)) assert ("42" in str(n1))
def on_next(cls, ticks, value): if isinstance(value, types.FunctionType): return Recorded(ticks, OnNextPredicate(value)) return Recorded(ticks, OnNext(value))
def test_on_next_accept_observer(): con = CheckOnNextObserver() n1 = OnNext(42) n1.accept(con) assert (42 == con.value)