コード例 #1
0
ファイル: test_notification.py プロジェクト: ESSL-CQQ/RxPY
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_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)
コード例 #3
0
ファイル: test_notification.py プロジェクト: zmyer/RxPY
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))
コード例 #4
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
コード例 #5
0
ファイル: test_notification.py プロジェクト: ESSL-CQQ/RxPY
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)
コード例 #6
0
ファイル: test_notification.py プロジェクト: ESSL-CQQ/RxPY
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])
コード例 #7
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]
コード例 #8
0
ファイル: test_notification.py プロジェクト: wolf937/RxPY
def test_on_next_accept_action_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(on_next, on_error, on_completed)
    assert ('OK' == res)
コード例 #9
0
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'])
コード例 #10
0
ファイル: test_notification.py プロジェクト: ESSL-CQQ/RxPY
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))
コード例 #11
0
 def on_next(self, value):
     if self.requested_count <= 0:
         self.enable_queue and self.queue.append(OnNext(value))
     else:
         self.requested_count -= 1
         if self.requested_count == 0:
             self.dispose_current_request()
         self.subject.on_next(value)
コード例 #12
0
    def handle_on_next(value):
        try:
            value = int(value)
        except Exception:
            pass

        if value in ('T', 'F'):
            value = value == 'T'
        messages.append((OnNext(value), timedelta[0]))
コード例 #13
0
ファイル: test_observer.py プロジェクト: zmyer/RxPY
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)
コード例 #14
0
    def on_next(self, value):

        with self.lock:
            # concurrent situation with acknowledgment in inner subscription or new subscriptions

            # empty inactive subscriptions; they are added to the list once they reach the top of the buffer again
            inactive_subsriptions = self.inactive_subsriptions
            self.inactive_subsriptions = []

            # add item to buffer
            self.buffer.append(OnNext(value))

            # current ack is used by subscriptions that weren't inactive, but reached the top of the buffer
            current_ack = Ack()
            self.current_ack = current_ack

            is_done = self.is_done

        if is_done:
            return stop_ack

        def gen_inner_ack():
            # send notification to inactive subscriptions
            for inner_subscription in inactive_subsriptions:
                inner_ack = inner_subscription.notify_on_next(value)
                yield inner_ack

        inner_ack_list = list(gen_inner_ack())

        continue_ack = [
            ack for ack in inner_ack_list if isinstance(ack, Continue)
        ]

        if 0 < len(continue_ack):
            # return any Continue ack
            return continue_ack[0]
        else:
            # return merged acknowledgments from inner subscriptions

            ack_list = [current_ack] + inner_ack_list

            upper_ack = Ack()
            rx.Observable.merge(*ack_list).first().subscribe(upper_ack)
            return upper_ack
コード例 #15
0
    def on_next(ticks: int, value: Any) -> Recorded:
        if isinstance(value, types.FunctionType):
            return Recorded(ticks, OnNextPredicate(value))

        return Recorded(ticks, OnNext(value))
コード例 #16
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)
コード例 #17
0
 def on_next(value) -> None:
     self.messages.append(Recorded(scheduler.clock, OnNext(value)))
コード例 #18
0
 def on_next(self, value):
     self.messages.append(Recorded(self.scheduler.clock, OnNext(value)))
コード例 #19
0
import rx
import rx.operators as ops
from rx.core.notification import OnNext, OnCompleted

numbers = rx.from_([OnNext(1), OnNext(2), OnNext(3), OnNext(4), OnCompleted()])

numbers.pipe(ops.dematerialize()).subscribe(
    on_next=lambda i: print("on_next {}".format(i)),
    on_error=lambda e: print("on_error: {}".format(e)),
    on_completed=lambda: print("on_completed"))
コード例 #20
0
    def on_next(cls, ticks, value):
        if isinstance(value, types.FunctionType):
            return Recorded(ticks, OnNextPredicate(value))

        return Recorded(ticks, OnNext(value))
コード例 #21
0
ファイル: test_notification.py プロジェクト: ESSL-CQQ/RxPY
def test_on_next_accept_observer():
    con = CheckOnNextObserver()
    n1 = OnNext(42)
    n1.accept(con)
    assert(42 == con.value)
コード例 #22
0
from rx import Observable
from rx.core.notification import OnNext, OnCompleted

numbers = Observable.from_(
    [OnNext(1), OnNext(2),
     OnNext(3), OnNext(4),
     OnCompleted()])

numbers.dematerialize().subscribe(
    on_next=lambda i: print("on_next {}".format(i)),
    on_error=lambda e: print("on_error: {}".format(e)),
    on_completed=lambda: print("on_completed"))
コード例 #23
0
 def on_next(value):
     observer.on_next(OnNext(value))
コード例 #24
0
def test_on_next_accept_observer():
    con = CheckOnNextObserver()
    n1 = OnNext(42)
    n1.accept(con)
    assert con.value == 42
コード例 #25
0
def test_on_next_tostring():
    n1 = OnNext(42)
    assert "OnNext" in str(n1)
    assert "42" in str(n1)
コード例 #26
0
 def create():
     return OnNext(42).to_observable(scheduler)
コード例 #27
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")