From e78ce9f58b799b4dad5d71528835acd29f398990 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2024 22:58:55 +0100 Subject: [PATCH] linting --- faststream/confluent/testing.py | 4 ++- faststream/kafka/testing.py | 11 ++++-- faststream/testing/broker.py | 4 ++- tests/brokers/confluent/test_test_client.py | 38 ++++++++++----------- tests/brokers/kafka/test_test_client.py | 1 - 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/faststream/confluent/testing.py b/faststream/confluent/testing.py index a73dac146d..90c24297cd 100644 --- a/faststream/confluent/testing.py +++ b/faststream/confluent/testing.py @@ -112,7 +112,9 @@ async def publish( # type: ignore[override] if topic in handler.topics: handle_value = await call_handler( handler=handler, - message=[incoming] if isinstance(handler, AsyncAPIBatchSubscriber) else incoming, + message=[incoming] + if isinstance(handler, AsyncAPIBatchSubscriber) + else incoming, rpc=rpc, rpc_timeout=rpc_timeout, raise_timeout=raise_timeout, diff --git a/faststream/kafka/testing.py b/faststream/kafka/testing.py index e9a572a2dd..5abe59cf97 100755 --- a/faststream/kafka/testing.py +++ b/faststream/kafka/testing.py @@ -108,13 +108,18 @@ async def publish( # type: ignore[override] return_value = None for handler in self.broker._subscribers.values(): # pragma: no branch - if any( + if ( + any( p.topic == topic and (partition is None or p.partition == partition) for p in handler.partitions - ) or topic in handler.topics: + ) + or topic in handler.topics + ): handle_value = await call_handler( handler=handler, - message=[incoming] if isinstance(handler, AsyncAPIBatchSubscriber) else incoming, + message=[incoming] + if isinstance(handler, AsyncAPIBatchSubscriber) + else incoming, rpc=rpc, rpc_timeout=rpc_timeout, raise_timeout=raise_timeout, diff --git a/faststream/testing/broker.py b/faststream/testing/broker.py index c7d186d34c..f8925210a4 100644 --- a/faststream/testing/broker.py +++ b/faststream/testing/broker.py @@ -214,7 +214,9 @@ async def call_handler( if rpc: message_body, content_type = encode_message(result) - msg_to_publish = StreamMessage(raw_message=None, body=message_body, content_type=content_type) + msg_to_publish = StreamMessage( + raw_message=None, body=message_body, content_type=content_type + ) consumed_data = decode_message(msg_to_publish) return consumed_data diff --git a/tests/brokers/confluent/test_test_client.py b/tests/brokers/confluent/test_test_client.py index 82daa8adac..aec2ae9fb9 100644 --- a/tests/brokers/confluent/test_test_client.py +++ b/tests/brokers/confluent/test_test_client.py @@ -13,10 +13,10 @@ class TestTestclient(BrokerTestclientTestcase): @pytest.mark.confluent() async def test_with_real_testclient( - self, - broker: KafkaBroker, - queue: str, - event: asyncio.Event, + self, + broker: KafkaBroker, + queue: str, + event: asyncio.Event, ): @broker.subscriber(queue, auto_offset_reset="earliest") def subscriber(m): @@ -34,9 +34,9 @@ def subscriber(m): assert event.is_set() async def test_batch_pub_by_default_pub( - self, - test_broker: KafkaBroker, - queue: str, + self, + test_broker: KafkaBroker, + queue: str, ): @test_broker.subscriber(queue, batch=True, auto_offset_reset="earliest") async def m(): @@ -47,9 +47,9 @@ async def m(): m.mock.assert_called_once_with(["hello"]) async def test_batch_pub_by_pub_batch( - self, - test_broker: KafkaBroker, - queue: str, + self, + test_broker: KafkaBroker, + queue: str, ): @test_broker.subscriber(queue, batch=True, auto_offset_reset="earliest") async def m(): @@ -60,9 +60,9 @@ async def m(): m.mock.assert_called_once_with(["hello"]) async def test_batch_publisher_mock( - self, - test_broker: KafkaBroker, - queue: str, + self, + test_broker: KafkaBroker, + queue: str, ): publisher = test_broker.publisher(queue + "1", batch=True) @@ -125,9 +125,9 @@ async def h2(): ... @pytest.mark.confluent() async def test_multiple_subscribers_different_groups( - self, - queue: str, - test_broker: KafkaBroker, + self, + queue: str, + test_broker: KafkaBroker, ): @test_broker.subscriber(queue, group_id="group1") async def subscriber1(): ... @@ -143,9 +143,9 @@ async def subscriber2(): ... @pytest.mark.confluent() async def test_multiple_subscribers_same_group( - self, - queue: str, - test_broker: KafkaBroker, + self, + queue: str, + test_broker: KafkaBroker, ): @test_broker.subscriber(queue, group_id="group1") async def subscriber1(): ... diff --git a/tests/brokers/kafka/test_test_client.py b/tests/brokers/kafka/test_test_client.py index bf830ff7eb..5924d97265 100644 --- a/tests/brokers/kafka/test_test_client.py +++ b/tests/brokers/kafka/test_test_client.py @@ -200,4 +200,3 @@ async def subscriber2(): ... assert subscriber1.mock.call_count == 1 assert subscriber2.mock.call_count == 0 -