예제 #1
0
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))
예제 #2
0
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))
예제 #3
0
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)
예제 #4
0
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])
예제 #5
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)
예제 #6
0
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)
예제 #7
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))
예제 #8
0
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])
예제 #9
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)
예제 #10
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)
예제 #11
0
    def on_next(cls, ticks, value):
        if type(value) == types.FunctionType:
            return Recorded(ticks, OnNextPredicate(value))

        return Recorded(ticks, OnNext(value))
예제 #12
0
 def on_next(value):
     observer.on_next(OnNext(value))
예제 #13
0
 def on_next(self, value):
     self.messages.append(Recorded(self.scheduler.clock, OnNext(value)))
예제 #14
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))
예제 #15
0
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"))
예제 #16
0
def test_on_next_accept_observer():
    con = CheckOnNextObserver()
    n1 = OnNext(42)
    n1.accept(con)
    assert(42 == con.value)
예제 #17
0
 def create():
     return OnNext(42).to_observable(scheduler)
예제 #18
0
def test_on_next_tostring():
    n1 = OnNext(42)
    assert ("OnNext" in str(n1))
    assert ("42" in str(n1))
예제 #19
0
    def on_next(cls, ticks, value):
        if isinstance(value, types.FunctionType):
            return Recorded(ticks, OnNextPredicate(value))

        return Recorded(ticks, OnNext(value))
예제 #20
0
def test_on_next_accept_observer():
    con = CheckOnNextObserver()
    n1 = OnNext(42)
    n1.accept(con)
    assert (42 == con.value)