Exemplo n.º 1
0
def consumer(service):
    with MessageReader(service) as reader:
        for message in reader:
            show_message(message)
Exemplo n.º 2
0
def test_reader_bad_consistency(consistency):
    with pytest.raises(InvalidArgumentError):
        with MessageReader(SERVICE, consistency=consistency) as _:
            pass
Exemplo n.º 3
0
def test_reader_client_id_empty():
    with MessageReader(SERVICE, client_id="") as f:
        assert f.client_id is not None and f.client_id != ""
Exemplo n.º 4
0
def test_reader_topic(topics):
    with MessageReader(SERVICE, topics) as _:
        pass
Exemplo n.º 5
0
def test_reader_consistency(consistency):
    with MessageReader(SERVICE, consistency=consistency) as f:
        assert consistency == f.consistency
Exemplo n.º 6
0
def test_reader_topics_list_in_config_file():
    with MessageReader(SERVICE) as f:
        assert f.topics == [TOPIC, TOPIC2]
Exemplo n.º 7
0
def test_receive_timeout_ms():
    timeout = 100
    with MessageReader(SERVICE, receive_timeout_ms=timeout) as f:
        assert f.receive_timeout_ms == timeout
Exemplo n.º 8
0
def test_reader_consistency_error():
    with pytest.raises(InvalidArgumentError):
        with MessageReader(SERVICE, TOPIC, consistency=999) as _:
            pass
Exemplo n.º 9
0
def test_reader_kafka_opt():
    with MessageReader(SERVICE, TOPIC, heartbeat_interval_ms=1000) as _:
        pass
Exemplo n.º 10
0
def test_reader_topic(topics):
    with MessageReader(SERVICE, topics) as f:
        assert f.topics == topics
Exemplo n.º 11
0
def test_reader_consistency(consistency):
    with MessageReader(SERVICE, TOPIC, consistency=consistency) as _:
        pass
Exemplo n.º 12
0
def test_open_twice():
    with MessageReader(SERVICE, TOPIC) as f:
        with pytest.raises(AlreadyConnectedError):
            f.open()
def consumer(service, width, height):
    with MessageReader(service, value_type='image') as reader:
        for message in reader:
            if show_image(message, width, height):
                sys.exit()
Exemplo n.º 14
0
def test_reader_timeout():
    with MessageReader(SERVICE, TOPIC, receive_timeout_ms=3000) as f:
        for msg in f:
            pass
Exemplo n.º 15
0
def test_reader_topic_in_config_file_and_arg():
    with MessageReader(SERVICE, TOPIC2) as f:
        assert f.topics == TOPIC2
Exemplo n.º 16
0
def test_reader_seek_to_beginning():
    with MessageReader(SERVICE, TOPIC) as f:
        f.seek_to_beginning()
Exemplo n.º 17
0
def test_reader_topics_in_config_file_and_kwargs():
    with MessageReader(service=SERVICE, topic=TOPIC2) as f:
        assert f.topics == TOPIC2
Exemplo n.º 18
0
def test_reader_seek_to_end():
    with MessageReader(SERVICE, TOPIC) as f:
        f.seek_to_end()
Exemplo n.º 19
0
def test_service():
    with MessageReader(SERVICE) as f:
        assert f.service == SERVICE
Exemplo n.º 20
0
def test_reader_deser():
    with MessageReader(SERVICE, value_deserializer=(lambda x: x)) as _:
        pass
Exemplo n.º 21
0
def test_default_receive_timeout_ms():
    with MessageReader(SERVICE) as f:
        assert f.receive_timeout_ms == inf
Exemplo n.º 22
0
def test_reader_timeout():
    with MessageReader(SERVICE, receive_timeout_ms=3000) as _:
        pass
Exemplo n.º 23
0
def test_reader_bad_topics():
    with pytest.raises(InvalidArgumentError):
        with MessageReader(SERVICE) as _:
            pass
Exemplo n.º 24
0
def test_open_close():
    f = MessageReader(SERVICE).open()
    assert hasattr(f, '__iter__')
    f.close()
Exemplo n.º 25
0
def test_reader_consistency_in_config_file(config_params):
    with MessageReader(SERVICE) as f:
        consistency = config_params['consistency']
        assert eval(consistency) == f.consistency
Exemplo n.º 26
0
def test_close_twice():
    f = MessageReader(SERVICE).open()
    f.close()
    f.close()
Exemplo n.º 27
0
def test_reader_client_id_default():
    with MessageReader(SERVICE) as f:
        assert f.client_id is not None and f.client_id != ""
Exemplo n.º 28
0
def test_reader_topic_in_config_file(config_topic):
    with MessageReader(SERVICE) as f:
        assert f.topics == config_topic
Exemplo n.º 29
0
def test_reader_client_id_set():
    cid = "oreore"
    with MessageReader(SERVICE, client_id=cid) as f:
        assert f.client_id == cid
Exemplo n.º 30
0
def consumer(service):
    with MessageReader(service, value_type='image') as reader:
        for message in reader:
            if show_image(message):
                break