diff --git a/bluesky_kafka/produce.py b/bluesky_kafka/produce.py index 9df7306..1b284b0 100644 --- a/bluesky_kafka/produce.py +++ b/bluesky_kafka/produce.py @@ -115,7 +115,6 @@ def __init__( raise ValueError( "do not specify 'bootstrap.servers' in producer_config dictionary, " "use only the 'bootstrap_servers' parameter" - f"\n{self}" ) else: self._producer_config["bootstrap.servers"] = ",".join(bootstrap_servers) diff --git a/bluesky_kafka/tests/test_basic_consumer.py b/bluesky_kafka/tests/test_basic_consumer.py index 3f389ef..1669659 100644 --- a/bluesky_kafka/tests/test_basic_consumer.py +++ b/bluesky_kafka/tests/test_basic_consumer.py @@ -7,8 +7,8 @@ "bootstrap_servers, consumer_config_bootstrap_servers", [ ([], ""), - (["1.2.3.4:9092"], "1.2.3.4:9092"), - (["1.2.3.4:9092", "localhost:9092"], "1.2.3.4:9092,localhost:9092"), + (["localhost:9092"], "localhost:9092"), + (["localhost:9091", "localhost:9092"], "localhost:9091,localhost:9092"), ], ) def test_bootstrap_servers(bootstrap_servers, consumer_config_bootstrap_servers): @@ -42,49 +42,46 @@ def test_bootstrap_servers_in_consumer_config(): consumer_config={"bootstrap.servers": ""}, ) - assert ( - "do not specify 'bootstrap.servers' in consumer_config dictionary, " - "use only the 'bootstrap_servers' parameter" in excinfo.value - ) + assert ( + "do not specify 'bootstrap.servers' in consumer_config dictionary, " + "use only the 'bootstrap_servers' parameter" in str(excinfo.value) + ) def test_bootstrap_servers_not_list(): with pytest.raises(TypeError) as excinfo: BasicConsumer( topics=["abc"], - bootstrap_servers="1.2.3.4:9092", + bootstrap_servers="localhost:9092", group_id="abc", consumer_config={}, ) - assert ( - "parameter `bootstrap_servers` must be a sequence of str, not str" - in excinfo.value - ) + assert "parameter `bootstrap_servers` must be a sequence of str, not str" in str( + excinfo.value + ) def test_bad_consumer_config(): with pytest.raises(ValueError) as excinfo: BasicConsumer( topics=["abc"], - bootstrap_servers=["1.2.3.4:9092"], + bootstrap_servers=["localhost:9092"], group_id="abc", consumer_config={ - "bootstrap.servers": "5.6.7.8:9092", - "auto.offset.reset": "latest", "group.id": "raise an exception!", }, ) - assert ( - "do not specify 'group.id' in consumer_config, use only the 'group_id' argument" - in excinfo.value - ) + assert ( + "do not specify 'group.id' in consumer_config, use only the 'group_id' parameter" + in str(excinfo.value) + ) def test_redact_password_from_str(): basic_consumer = BasicConsumer( topics=["abc"], bootstrap_servers=["localhost:9091", "localhost:9092"], - group_id="abc", + group_id="def", consumer_config={ "sasl.password": "PASSWORD", }, @@ -94,8 +91,8 @@ def test_redact_password_from_str(): "(" "topics=['abc'], " "consumer_config={" - "'sasl.password': '****', " - "'group.id': 'abc', " - "'bootstrap.servers': 'localhost:9091,localhost:9092'}" + "'sasl.password': '****', " + "'group.id': 'def', " + "'bootstrap.servers': 'localhost:9091,localhost:9092'}" ")" - ) \ No newline at end of file + ) diff --git a/bluesky_kafka/tests/test_basic_producer.py b/bluesky_kafka/tests/test_basic_producer.py index c4f141b..176c5c9 100644 --- a/bluesky_kafka/tests/test_basic_producer.py +++ b/bluesky_kafka/tests/test_basic_producer.py @@ -7,8 +7,8 @@ "bootstrap_servers, producer_config, combined_bootstrap_servers", [ ([], {}, ""), - (["1.2.3.4:9092"], {}, "1.2.3.4:9092"), - (["1.2.3.4:9092", "localhost:9092"], {}, "1.2.3.4:9092,localhost:9092"), + (["localhost:9092"], {}, "localhost:9092"), + (["localhost:9091", "localhost:9092"], {}, "localhost:9091,localhost:9092"), ], ) def test_bootstrap_servers( @@ -45,10 +45,10 @@ def test_bootstrap_servers_in_producer_config(): producer_config={"bootstrap.servers": ""}, ) - assert ( - "do not specify 'bootstrap.servers' in producer_config dictionary, " - "use only the 'bootstrap_servers' parameter" in excinfo.value - ) + assert ( + "do not specify 'bootstrap.servers' in producer_config dictionary, " + "use only the 'bootstrap_servers' parameter" in str(excinfo.value) + ) def test_bad_bootstrap_servers(): @@ -62,10 +62,9 @@ def test_bad_bootstrap_servers(): "bootstrap.servers": "localhost:9092", }, ) - assert ( - "parameter `bootstrap_servers` must be a sequence of str, not str" - in excinfo.value - ) + assert "parameter `bootstrap_servers` must be a sequence of str, not str" in str( + excinfo.value + ) def test_redact_password_from_str_output(): @@ -88,4 +87,4 @@ def test_redact_password_from_str_output(): "bootstrap_servers=['localhost:9091', 'localhost:9092'], " "producer_config={'sasl.password': '****', 'bootstrap.servers': 'localhost:9091,localhost:9092'}" ")" - ) \ No newline at end of file + ) diff --git a/bluesky_kafka/tests/test_bluesky_consumer.py b/bluesky_kafka/tests/test_bluesky_consumer.py index 272a897..4a5fd2b 100644 --- a/bluesky_kafka/tests/test_bluesky_consumer.py +++ b/bluesky_kafka/tests/test_bluesky_consumer.py @@ -11,24 +11,24 @@ def test_consumer_config(): test_topic = "test.consumer.config" bluesky_consumer = BlueskyConsumer( topics=[test_topic], - bootstrap_servers="1.2.3.4:9092", + bootstrap_servers="localhost:9091", group_id="abc", consumer_config={ - "bootstrap.servers": "5.6.7.8:9092", + "bootstrap.servers": "localhost:9092", "auto.offset.reset": "latest", }, ) assert ( bluesky_consumer._consumer_config["bootstrap.servers"] - == "1.2.3.4:9092,5.6.7.8:9092" + == "localhost:9091,localhost:9092" ) def test_redact_password_from_str_output(): bluesky_consumer = BlueskyConsumer( topics=["test.redact.password"], - bootstrap_servers="1.2.3.4:9092", + bootstrap_servers="localhost:9092", group_id="test-redact-password-group", consumer_config={ "sasl.password": "PASSWORD", @@ -46,15 +46,13 @@ def test_bad_consumer_config(): with pytest.raises(ValueError) as excinfo: BlueskyConsumer( topics=[test_topic], - bootstrap_servers="1.2.3.4:9092", + bootstrap_servers="localhost:9092", group_id="test-bad-consumer_config", consumer_config={ - "bootstrap.servers": "5.6.7.8:9092", - "auto.offset.reset": "latest", "group.id": "raise an exception!", }, ) - assert ( - "do not specify 'group.id' in consumer_config, use only the 'group_id' argument" - in excinfo.value - ) + assert ( + "do not specify 'group.id' in consumer_config, use only the 'group_id' parameter" + in str(excinfo.value) + ) diff --git a/bluesky_kafka/tests/test_queue_thread.py b/bluesky_kafka/tests/test_queue_thread.py index 5c72293..32dbba7 100644 --- a/bluesky_kafka/tests/test_queue_thread.py +++ b/bluesky_kafka/tests/test_queue_thread.py @@ -226,7 +226,7 @@ def test_publisher_with_no_broker(RE, hw): build_kafka_publisher_queue_and_thread( topic=beamline_name, # specify a bootstrap server that does not exist - bootstrap_servers="100.100.100.100:9092", + bootstrap_servers="localhost:9999", producer_config={}, publisher_queue_timeout=1, )