def consumer(service): with MessageReader(service) as reader: for message in reader: show_message(message)
def test_reader_bad_consistency(consistency): with pytest.raises(InvalidArgumentError): with MessageReader(SERVICE, consistency=consistency) as _: pass
def test_reader_client_id_empty(): with MessageReader(SERVICE, client_id="") as f: assert f.client_id is not None and f.client_id != ""
def test_reader_topic(topics): with MessageReader(SERVICE, topics) as _: pass
def test_reader_consistency(consistency): with MessageReader(SERVICE, consistency=consistency) as f: assert consistency == f.consistency
def test_reader_topics_list_in_config_file(): with MessageReader(SERVICE) as f: assert f.topics == [TOPIC, TOPIC2]
def test_receive_timeout_ms(): timeout = 100 with MessageReader(SERVICE, receive_timeout_ms=timeout) as f: assert f.receive_timeout_ms == timeout
def test_reader_consistency_error(): with pytest.raises(InvalidArgumentError): with MessageReader(SERVICE, TOPIC, consistency=999) as _: pass
def test_reader_kafka_opt(): with MessageReader(SERVICE, TOPIC, heartbeat_interval_ms=1000) as _: pass
def test_reader_topic(topics): with MessageReader(SERVICE, topics) as f: assert f.topics == topics
def test_reader_consistency(consistency): with MessageReader(SERVICE, TOPIC, consistency=consistency) as _: pass
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()
def test_reader_timeout(): with MessageReader(SERVICE, TOPIC, receive_timeout_ms=3000) as f: for msg in f: pass
def test_reader_topic_in_config_file_and_arg(): with MessageReader(SERVICE, TOPIC2) as f: assert f.topics == TOPIC2
def test_reader_seek_to_beginning(): with MessageReader(SERVICE, TOPIC) as f: f.seek_to_beginning()
def test_reader_topics_in_config_file_and_kwargs(): with MessageReader(service=SERVICE, topic=TOPIC2) as f: assert f.topics == TOPIC2
def test_reader_seek_to_end(): with MessageReader(SERVICE, TOPIC) as f: f.seek_to_end()
def test_service(): with MessageReader(SERVICE) as f: assert f.service == SERVICE
def test_reader_deser(): with MessageReader(SERVICE, value_deserializer=(lambda x: x)) as _: pass
def test_default_receive_timeout_ms(): with MessageReader(SERVICE) as f: assert f.receive_timeout_ms == inf
def test_reader_timeout(): with MessageReader(SERVICE, receive_timeout_ms=3000) as _: pass
def test_reader_bad_topics(): with pytest.raises(InvalidArgumentError): with MessageReader(SERVICE) as _: pass
def test_open_close(): f = MessageReader(SERVICE).open() assert hasattr(f, '__iter__') f.close()
def test_reader_consistency_in_config_file(config_params): with MessageReader(SERVICE) as f: consistency = config_params['consistency'] assert eval(consistency) == f.consistency
def test_close_twice(): f = MessageReader(SERVICE).open() f.close() f.close()
def test_reader_client_id_default(): with MessageReader(SERVICE) as f: assert f.client_id is not None and f.client_id != ""
def test_reader_topic_in_config_file(config_topic): with MessageReader(SERVICE) as f: assert f.topics == config_topic
def test_reader_client_id_set(): cid = "oreore" with MessageReader(SERVICE, client_id=cid) as f: assert f.client_id == cid
def consumer(service): with MessageReader(service, value_type='image') as reader: for message in reader: if show_image(message): break