Beispiel #1
0
def test_merge_construction():
    s = stream("1")
    evt = event(V.foo == 1) >> event(V.bar == 2)

    span1 = span(s(evt), within=delta(days=1))
    span2 = span(s(evt), within=delta(days=2))
    assume(merge(span1, span2))
Beispiel #2
0
    def test_switch_construction(query1, query2):
        spike = event(V.foo == query1) >> event(V.bar < query2) >> event(
            V.baz != query1)
        assume(isinstance(spike, Switch))

        s = stream("1")
        assume(isinstance(s(spike), Switch))
Beispiel #3
0
    def test_par_construction(query1, query2):
        s1 = stream("1")
        s2 = stream("2")
        evt1 = event(V.foo == query1)
        evt2 = event(V.foo == query2)

        assume( isinstance(any_of(s1(evt1), s2(evt2)), Par) )
        assume( isinstance(all_of(s1(evt1), s2(evt2)), Par) )
Beispiel #4
0
    def test_serial_construction(query1, query2):
        s1 = stream("1")
        s2 = stream("2")
        evt1 = event(V.foo == query1)
        evt2 = event(V.foo == query2)

        srl = span(s1(evt1)) \
             .then(s2(evt2), within=delta(days=5))

        assume(type(srl) is Serial)
Beispiel #5
0
def test_select_with_bounds():
    s = stream("1")
    # FIXME: using this as a span returns a TypeError
    evt = event(V.foo == 1)

    sel = select(start=datetime.now(), end=datetime.now()) \
            .span(s.evt == 1) \
            .then(s.evt == 2)
            #.span(s(evt) >> s(evt)) \
            #.then(s(evt))

    assume(isinstance(sel, Select))
    assume(type(sel()) == dict)

    sel = select(end=datetime.now()) \
            .span(s.evt == 1) \
            .then(s.evt == 2)
            #.span(s(evt) >> s(evt)) \
            #.then(s(evt))

    assume(isinstance(sel, Select))
    assume(type(sel()) == dict)

    sel = select(start=datetime.now()) \
            .span(s.evt == 1) \
            .then(s.evt == 2)
            #.span(s(evt) >> s(evt)) \
            #.then(s(evt))

    assume(isinstance(sel, Select))
    assume(type(sel()) == dict)
Beispiel #6
0
def test_span_unwrapping():
    sp1 = span(event(V.foo == 0, V.bar == 1))
    sp2 = span(sp1)
    sp3 = span(sp2)

    # FIXME: this throws a FlareSyntaxError, which means there is a bug
    # assert str(sp2) == str(sp1)
    assert len(sp2.query) == len(sp1.query)
    assert len(sp3.query) == len(sp1.query)
Beispiel #7
0
    def test_select_construction(query1, query2):
        s1 = stream("1")
        s2 = stream("2")
        evt1 = event(V.foo == query1)
        evt2 = event(V.foo == query2)

        sel0 = select() \
            .span(s1(evt1))
        assume(isinstance(sel0, Select))

        sel1 = select() \
            .span(s1(evt1) >> s2(evt2))
        assume(isinstance(sel1, Select))

        sel3 = select() \
            .span(all_of(s1(evt1), s2(evt2)))
        assume(isinstance(sel3, Select))

        sel4 = select() \
            .span((s1(evt1), s2(evt2))) \
            .then(s2(evt1))

        assume(isinstance(sel4, Select))