Beispiel #1
0
 def create_event(event_type, payload):
     nonlocal counter
     counter += 1
     event_id = common.EventId(1, counter)
     event = common.Event(event_id=event_id,
                          event_type=event_type,
                          timestamp=common.now(),
                          source_timestamp=None,
                          payload=payload)
     return event
Beispiel #2
0
 def create_event(event_type, with_source_timestamp):
     nonlocal counter
     counter += 1
     event_id = common.EventId(1, counter)
     t = common.now()
     event = common.Event(
         event_id=event_id,
         event_type=event_type,
         timestamp=t,
         source_timestamp=(t if with_source_timestamp else None),
         payload=None)
     return event
Beispiel #3
0
def create_event(event_type, payload):
    return common.Event(event_id=common.EventId(1, 2),
                        event_type=event_type,
                        timestamp=common.now(),
                        source_timestamp=None,
                        payload=payload)
Beispiel #4
0
import pytest

from hat.event.server.backends.lmdb import common
import hat.event.server.backends.lmdb.encoder


@pytest.mark.parametrize('event', [
    common.Event(event_id=common.EventId(1, 2),
                 event_type=('a', 'b', 'c'),
                 timestamp=common.now(),
                 source_timestamp=None,
                 payload=None)
])
def test_event(event):
    encoded = hat.event.server.backends.lmdb.encoder.encode_event(event)
    decoded = hat.event.server.backends.lmdb.encoder.decode_event(encoded)
    assert event == decoded


@pytest.mark.parametrize('timestamp_id', [
    (common.now(), 123)
])
def test_timestamp_id(timestamp_id):
    encoded = hat.event.server.backends.lmdb.encoder.encode_timestamp_id(
        timestamp_id)
    decoded = hat.event.server.backends.lmdb.encoder.decode_timestamp_id(
        encoded)
    assert timestamp_id == decoded


@pytest.mark.parametrize('value', [