Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
def test_close_accept_action_with_result():
    n1 = OnCompleted()

    def on_next(x):
        assert False
        return None

    def on_error(ex):
        assert False
        return None

    def on_completed():
        return "OK"

    res = n1.accept(on_next, on_error, on_completed)
    assert "OK" == res
Esempio n. 4
0
def test_close_accept_observer_with_result():
    n1 = OnCompleted()

    def on_next(x):
        assert False
        return None

    def on_error(err):
        assert False
        return None

    def on_completed():
        return "OK"

    res = n1.accept(AcceptObserver(on_next, on_error, on_completed))
    assert "OK" == res
Esempio n. 5
0
def test_close_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)
Esempio n. 6
0
def test_close_accept_action():
    obs = [False]
    n1 = OnCompleted()

    def on_next(x):
        assert False
        return None

    def on_error(ex):
        assert False
        return None

    def on_completed():
        obs[0] = True
        return obs[0]

    n1.accept(on_next, on_error, on_completed)
    assert obs[0]
Esempio n. 7
0
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
Esempio n. 8
0
 def on_completed(ticks: int) -> Recorded[Any]:
     return Recorded(ticks, OnCompleted())
Esempio n. 9
0
 def on_completed(self) -> None:
     self.messages.append(Recorded(self.scheduler.clock, OnCompleted()))
Esempio n. 10
0
 def create():
     return OnCompleted().to_observable(scheduler)
Esempio n. 11
0
def test_close_accept_observer():
    obs = CheckOnCompletedObserver()
    n1 = OnCompleted()
    n1.accept(obs)
    assert obs.completed
Esempio n. 12
0
def test_close_tostring():
    n1 = OnCompleted()
    assert "OnCompleted" in str(n1)
Esempio n. 13
0
def test_close_ctor_and_props():
    n = OnCompleted()
    assert "C" == n.kind
    assert not n.has_value
    assert not hasattr(n, "exception")
Esempio n. 14
0
 def on_completed() -> None:
     observer.on_next(OnCompleted())
     observer.on_completed()