Exemplo n.º 1
0
def test_broadcast():
    lst1 = []
    lst2 = []
    pipe1 = L.list_sink(lst1)
    pipe2 = L.list_sink(lst2)
    pipe = L.broadcast(pipe1, pipe2)
    info = {'und alle so': 'yeah'}
    pipe.send(info)
    assert lst1[0] == info, 'list 1 did not receive info'
    assert lst2[0] == info, 'list 2 did not receive info'
Exemplo n.º 2
0
def test_timing():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.timify(pipe)
    pipe.send({})
    assert len(lst) == 1, 'nothing added to sink'
    assert 'datetime' in lst[0]
Exemplo n.º 3
0
def test_jsonify():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.jsonify(pipe)
    info = {'2': [3], '4': 5.}
    pipe.send(info)
    received_info = json.loads(lst[0])
    assert received_info == info, 'jsonify did mutate info: %s' % received_info
Exemplo n.º 4
0
def test_dontkeep():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.dontkeep(pipe, ['blabla'])

    pipe.send({'message': 'take care', 'blabla': 'blubb'})

    assert len(lst) == 1, 'wrong number of messages got through'
    assert lst[0] == {'message': 'take care'}, 'wrong keys got through'
Exemplo n.º 5
0
def test_addkeyvalue():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.add_keyvalue(pipe, 'yo', 'no')

    pipe.send({'message': 'take care', 'blabla': 'blubb'})

    assert len(lst) == 1, 'wrong number of messages got through'
    assert 'yo' in lst[0], 'did not get field'
    assert lst[0]['yo'] == 'no', 'field has not the right value'
Exemplo n.º 6
0
def test_uniquify():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.uniquify(pipe)

    pipe.send({'message': 'take care', 'blabla': 'blubb'})

    assert len(lst) == 1, 'wrong number of messages got through'
    assert 'uuid' in lst[0], 'did not get a uuid'
    assert len(lst[0]['uuid']) == 36, 'not a uuid'
Exemplo n.º 7
0
def test_exclude_tags():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.exclude_tags(pipe, 'fun')
    pipe1 = L.taggify(pipe, 'warn')
    pipe2 = L.taggify(pipe, 'fun')

    pipe1.send({'message': 'take care'})
    pipe2.send({'message': 'haahaa'})

    assert len(lst) == 1, 'wrong number of messages got through'
    assert lst[0]['message'] == 'take care', 'wrong message got through'
Exemplo n.º 8
0
def test_tagging():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.taggify(pipe, tags=['bla', 'blubb'])
    pipe.send({})
    assert len(lst) == 1, 'nothing added to sink'
    tags = lst[0]['tags']
    assert tags == ['bla', 'blubb'], 'tags did not get through: %s' % tags

    pipe = L.taggify(pipe, tags='hopp')
    pipe.send({})
    tags = lst[-1]['tags']
    assert tags == ['hopp', 'bla', 'blubb'], 'tags did not get through: %s' % tags