Ejemplo n.º 1
0
def test_event_to_json():
    ''' test for converting event as json
    '''
    event = events.Event(name='Event#1',
                         metadata={'k1': 'v1'},
                         payload=['p1', 'p2', 'p3'])
    assert json.loads(event.to_json()) == json.loads("""
        {"name": "Event#1", "metadata": { "k1": "v1" }, "payload": [ "p1", "p2", "p3"] }
    """)
Ejemplo n.º 2
0
def test_event_with_attrs():
    ''' test for events with attributes
    '''
    event = events.Event(name='Event#1',
                         metadata={'k1': 'v1'},
                         payload=['p1', 'p2', 'p3'])

    assert event.name == 'Event#1'
    assert event.metadata == {'k1': 'v1'}
    assert event.payload == ['p1', 'p2', 'p3']
Ejemplo n.º 3
0
def test_event_to_dict():
    ''' test for converting event as dict
    '''
    event = events.Event(name='Event#1',
                         metadata={'k1': 'v1'},
                         payload=['p1', 'p2', 'p3'])
    assert event.to_dict() == {
        'name': 'Event#1',
        'metadata': {
            'k1': 'v1'
        },
        'payload': ['p1', 'p2', 'p3']
    }
Ejemplo n.º 4
0
def test_change_events_attrs():
    ''' test for changing events attributes
    '''
    event = events.Event(name='Event#1',
                         metadata={'k1': 'v1'},
                         payload=['p1', 'p2', 'p3'])

    event.metadata.update({'k2': 'v2'})
    event.payload.append('p4')

    assert event.name == 'Event#1'
    assert event.metadata == {
        'k1': 'v1',
        'k2': 'v2',
    }
    assert event.payload == [
        'p1',
        'p2',
        'p3',
        'p4',
    ]
Ejemplo n.º 5
0
def test_base_event():
    ''' test for base event
    '''
    event = events.Event(name='Event#1', metadata=dict(), payload=list())
    assert event.name == 'Event#1'