Example #1
0
def test_monitor_during_wrapper():
    def plan():
        # can't use 2 * [Msg('open_run'), Msg('null'), Msg('close_run')]
        # because plan_mutator sees the same ids twice and skips them
        yield from [
            Msg('open_run'),
            Msg('null'),
            Msg('close_run'),
            Msg('open_run'),
            Msg('null'),
            Msg('close_run')
        ]

    processed_plan = list(monitor_during_wrapper(plan(), [det]))
    expected = 2 * [
        Msg('open_run'),
        # inserted
        Msg('monitor', det, name=(det.name + '_monitor')),
        Msg('null'),
        Msg('unmonitor', det),  # inserted
        Msg('close_run')
    ]

    strip_group(processed_plan)
    assert processed_plan == expected

    processed_plan = list(monitor_during_decorator([det])(plan)())
    strip_group(processed_plan)
    assert processed_plan == expected
Example #2
0
def test_monitor_during_wrapper():
    def plan():
        # can't use 2 * [Msg('open_run'), Msg('null'), Msg('close_run')]
        # because plan_mutator sees the same ids twice and skips them
        yield from [Msg('open_run'), Msg('null'), Msg('close_run'),
                    Msg('open_run'), Msg('null'), Msg('close_run')]

    processed_plan = list(monitor_during_wrapper(plan(), [det]))
    expected = 2 * [Msg('open_run'),
                    # inserted
                    Msg('monitor', det, name=(det.name + '-monitor')),
                    Msg('null'),
                    Msg('unmonitor', det),  # inserted
                    Msg('close_run')]

    strip_group(processed_plan)
    assert processed_plan == expected

    processed_plan = list(monitor_during_decorator([det])(plan)())
    strip_group(processed_plan)
    assert processed_plan == expected
Example #3
0
def test_filtering_stream_name(db, RE):

    # one event stream
    RE.subscribe('all', db.mds.insert)
    uid, = RE(count([det], num=7))
    h = db[uid]
    assert len(list(db.get_events(h, stream_name='primary'))) == 7
    assert len(db.get_table(h, stream_name='primary')) == 7
    assert len(list(db.get_events(h, stream_name='primary', fields=['det']))) == 7
    assert len(db.get_table(h, stream_name='primary', fields=['det'])) == 7

    # two event streams: 'primary' and 'd-monitor'
    d = Reader('d', read_fields={'d': lambda: 1}, monitor_intervals=[0.5],
               loop=RE.loop)
    uid, = RE(monitor_during_wrapper(count([det], num=7, delay=0.1), [d]))
    h = db[uid]
    assert len(h.descriptors) == 2
    assert len(list(db.get_events(h, stream_name='primary'))) == 7
    assert len(list(db.get_events(h, stream_name='d-monitor'))) == 1
    assert len(list(db.get_events(h))) == 8  # ALL streams by default

    assert len(db.get_table(h, stream_name='primary')) == 7
    assert len(db.get_table(h, stream_name='d-monitor')) == 1
    assert len(db.get_table(h)) == 7  # 'primary' by default
Example #4
0
def test_monitor(fresh_RE):
    RE = fresh_RE
    RE(monitor_during_wrapper(count([det], 5), [det1]))
def test_monitor(fresh_RE):
    RE = fresh_RE
    RE(monitor_during_wrapper(count([det], 5), [det1]))