예제 #1
0
def test_module_unpack():

    actor_config = ActorConfig('unpack', 100, 1, {}, "")
    unpack = Unpack(actor_config)

    unpack.pool.queue.inbox.disableFallThrough()
    unpack.pool.queue.outbox.disableFallThrough()
    unpack.start()

    bulk = Event(bulk=True)

    for _ in range(0, 10):
        bulk.appendBulk(Event())

    unpack.pool.queue.inbox.put(bulk)

    for _ in range(0, 10):
        assert getter(unpack.pool.queue.outbox)

    try:
        getter(unpack.pool.queue.outbox)
    except Exception:
        assert True
    else:
        assert False
예제 #2
0
def test_event_appendBulk():

    e = Event(bulk=True)
    ee = Event({"one": 1})

    e.appendBulk(ee)
    assert e.dump()["data"][0]["uuid"] == ee.data["uuid"]
예제 #3
0
def test_extractBulkItemValues():

    from wishbone.event import extractBulkItemValues

    e = Event(bulk=True)
    e.appendBulk(Event({"one": 1}))
    e.appendBulk(Event({"two": 2}))
    e.appendBulk(Event({"three": 3}))

    for item in extractBulkItemValues(e, "data"):
        assert item in [{"one": 1}, {"two": 2}, {"three": 3}]
예제 #4
0
def test_extractBulkItems():

    from wishbone.event import extractBulkItems

    e = Event(bulk=True)
    e.appendBulk(Event({"one": 1}))
    e.appendBulk(Event({"two": 2}))
    e.appendBulk(Event({"three": 3}))

    for item in extractBulkItems(e):
        assert isinstance(item, Event)
예제 #5
0
def test_event_appendBulkFull():

    e = Event(bulk=True, bulk_size=1)
    ee = Event({"one": 1})

    e.appendBulk(ee)
    try:
        e.appendBulk(ee)
    except BulkFull:
        assert True
    else:
        assert False
예제 #6
0
def test_event_appendBulkBad():

    normal_event = Event()

    try:
        normal_event.appendBulk(Event())
    except Exception:
        assert True
    else:
        assert False

    bulk_event = Event(bulk=True)
    try:
        bulk_event.appendBulk("hello")
    except Exception:
        assert True
    else:
        assert False