Exemplo n.º 1
0
def test_consumer_returns_last_commit(db):
    conn, _ = db
    consumer = Consumer(conn, "foo", "offsets")

    new_offset = consumer.new_offset()
    consumer.commit(new_offset)

    offset = consumer.get_offset()
    assert offset == new_offset
Exemplo n.º 2
0
def test_consumer_passes_offsets_to_work_fn(db):
    conn, _ = db
    consumer = Consumer(conn, "foo", "offsets")

    new_offset = consumer.new_offset()
    consumer.commit(new_offset)

    def work(old, new):
        assert old == new_offset

    consumer.do_work(work)
Exemplo n.º 3
0
def test_consumer_throws_consumer_work_error_on_exception(db):
    conn, _ = db
    consumer = Consumer(conn, "foo", "offsets")

    new_offset = consumer.new_offset()
    consumer.commit(new_offset)

    def work(old, new):
        assert old != new_offset

    with pytest.raises(ConsumerWorkError):
        consumer.do_work(work)