def test_on_error_accept_action_with_result(): ex = 'ex' n1 = OnError(ex) def on_next(x): assert(False) return None def on_error(ex): return "OK" def on_completed(): assert(False) return None res = n1.accept(on_next, on_error, on_completed) assert('OK' == res)
def test_throw_accept_action_with_result(): ex = 'ex' n1 = OnError(ex) def on_next(x): assert False return None def on_error(ex): return "OK" def on_completed(): assert False return None res = n1.accept(on_next, on_error, on_completed) assert 'OK' == res
def test_throw_accept_observer_with_result(): ex = 'ex' n1 = OnError(ex) def on_next(x): assert(False) return None def on_error(ex): return "OK" def on_completed(): assert(False) return None res = n1.accept(AcceptObserver(on_next, on_error, on_completed)) assert('OK' == res)
def notification(obj): if obj['what'] == 'on_next': return OnNext(obj['item']) elif obj['what'] == 'on_completed': return OnCompleted() elif obj['what'] == 'on_error': return OnError(obj['error'])
def test_throw_accept_observer_with_result(): ex = 'ex' n1 = OnError(ex) def on_next(x): assert (False) return None def on_error(ex): return "OK" def on_completed(): assert (False) return None res = n1.accept(AcceptObserver(on_next, on_error, on_completed)) assert ('OK' == res)
def test_throw_accept_action(): ex = 'ex' obs = [False] n1 = OnError(ex) def on_next(x): assert False return None def on_error(ex): obs[0] = True return obs[0] def on_completed(): assert False return None n1.accept(on_next, on_error, on_completed) assert obs[0]
def test_on_error_accept_action(): ex = 'ex' obs = [False] n1 = OnError(ex) def on_next(x): assert(False) return None def on_error(ex): obs[0] = True return obs[0] def on_completed(): assert(False) return None n1.accept(on_next, on_error, on_completed) assert(obs[0])
def on_error(self, error): self.has_failed = True self.error = error if not self.enable_queue or len(self.queue) == 0: self.subject.on_error(error) self.dispose_current_request() else: self.queue.append(OnError(error))
def test_on_error_equality(): ex1 = 'ex1' ex2 = 'ex2' n1 = OnError(ex1) n2 = OnError(ex1) n3 = OnError(ex2) 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_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_error(self, exception): with self.lock: # concurrent situation with acknowledgment in inner subscription or new subscriptions # inner subscriptions that return Continue or Stop need to be added to inactive subscriptions again inactive_subsriptions = self.inactive_subsriptions self.inactive_subsriptions = [] # add item to buffer self.buffer.append(OnError(exception)) # send notification to inactive subscriptions for inner_subscription in inactive_subsriptions: inner_subscription.notify_on_error(exception)
def on_error(self, error: Exception) -> None: self.messages.append(Recorded(self.scheduler.clock, OnError(error)))
def test_on_error_equality(): ex1 = 'ex1' ex2 = 'ex2' n1 = OnError(ex1) n2 = OnError(ex1) n3 = OnError(ex2) 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 on_error(ticks: int, exception: Exception) -> Recorded: if isinstance(exception, types.FunctionType): return Recorded(ticks, OnErrorPredicate(exception)) return Recorded(ticks, OnError(exception))
def on_error(cls, ticks, exception): if isinstance(exception, types.FunctionType): return Recorded(ticks, OnErrorPredicate(exception)) return Recorded(ticks, OnError(exception))
def on_error(error) -> None: self.messages.append(Recorded(scheduler.clock, OnError(error))) self.completed.set()
def create(): return OnError(ex).to_observable(scheduler)
def test_on_error_tostring(): ex = 'ex' n1 = OnError(ex) assert ("OnError" in str(n1)) assert ("ex" in str(n1))
def on_error(self, exception): self.messages.append(Recorded(self.scheduler.clock, OnError(exception)))
def handle_on_error(value): messages.append((OnError(value), timedelta[0])) completed[0] = True
def test_throw_tostring(): ex = 'ex' n1 = OnError(ex) assert "OnError" in str(n1) assert "ex" in str(n1)
def test_throw_accept_observer(): ex = 'ex' obs = CheckOnErrorObserver() n1 = OnError(ex) n1.accept(obs) assert ex == obs.error
def test_throw_equality(): ex1 = 'ex1' ex2 = 'ex2' n1 = OnError(ex1) n2 = OnError(ex1) n3 = OnError(ex2) 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_throw_ctor_and_props(): e = 'e' n = OnError(e) assert 'E'== n.kind assert not n.has_value assert e == n.exception
def test_throw_ctor_and_props(): e = 'e' n = OnError(e) assert ('E' == n.kind) assert (not n.has_value) assert (e == n.exception)
def on_error(exception): observer.on_next(OnError(exception)) observer.on_completed()
def test_on_error_accept_observer(): ex = 'ex' obs = CheckOnErrorObserver() n1 = OnError(ex) n1.accept(obs) assert(ex == obs.error)