How to use the spade.trace.TraceStore function in spade

To help you get started, we’ve selected a few spade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javipalanca / spade / tests / test_trace.py View on Github external
def test_filter_to_limit():
    cycle = itertools.cycle(range(3))
    trace = TraceStore(10)
    for i in range(5):
        msg = Message(
            body=str(i), to="{}@server".format(next(cycle)), sender="sender@server"
        )
        trace.append(msg)

    result = [x[1].body for x in trace.filter(to="0@server", limit=1)]
    assert result == ["3"]
github javipalanca / spade / tests / test_trace.py View on Github external
def test_all_limit():
    trace = TraceStore(10)
    for i in range(5):
        trace.append(i)
    all = trace.all(limit=2)
    events = [e[1] for e in all]

    assert events == [3, 4]
github javipalanca / spade / tests / test_trace.py View on Github external
def test_init():
    trace = TraceStore(10)

    assert trace.size == 10
    assert trace.store == []
github javipalanca / spade / tests / test_trace.py View on Github external
def test_append_with_category():
    trace = TraceStore(10)
    trace.append("EVENT", "CATEGORY")
    assert len(trace.store) == 1
    assert trace.store[0][1] == "EVENT"
    assert type(trace.store[0][0]) == datetime.datetime
    assert trace.store[0][2] == "CATEGORY"
github javipalanca / spade / tests / test_trace.py View on Github external
def test_filter_to_and_category():
    cycle = itertools.cycle(range(3))
    trace = TraceStore(10)
    for i in range(5):
        c = str(next(cycle))
        msg = Message(body=str(c), to="{}@server".format(c), sender="sender@server")
        trace.append(msg, c)

    result = [(x[1].body, x[2]) for x in trace.filter(to="1@server", category="1")]
    assert result == [("1", "1"), ("1", "1")]
github javipalanca / spade / tests / test_trace.py View on Github external
def test_reset():
    trace = TraceStore(10)
    for i in range(5):
        trace.append(i)
    assert len(trace.store) == 5

    trace.reset()
    assert len(trace.store) == 0
github javipalanca / spade / tests / test_trace.py View on Github external
def test_len():
    trace = TraceStore(10)
    for i in range(5):
        trace.append(i)
    assert trace.len() == 5
github javipalanca / spade / tests / test_trace.py View on Github external
def test_filter():
    trace = TraceStore(10)
    for i in range(5):
        trace.append(i)

    result = [x[1] for x in trace.filter()]
    assert result == [0, 1, 2, 3, 4]
github javipalanca / spade / tests / test_trace.py View on Github external
def test_all():
    trace = TraceStore(10)
    for i in range(5):
        trace.append(i)
    all = trace.all()
    events = [e[1] for e in all]

    assert events == [0, 1, 2, 3, 4]
github javipalanca / spade / tests / test_trace.py View on Github external
def test_filter_to():
    cycle = itertools.cycle(range(3))
    trace = TraceStore(10)
    for i in range(5):
        msg = Message(
            body=str(i), to="{}@server".format(next(cycle)), sender="sender@server"
        )
        trace.append(msg)

    result = [x[1].body for x in trace.filter(to="0@server")]
    assert result == ["0", "3"]