Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sifex committed May 18, 2024
1 parent fff8a92 commit e78ce9f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
4 changes: 3 additions & 1 deletion faststream/confluent/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions faststream/kafka/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion faststream/testing/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
38 changes: 19 additions & 19 deletions tests/brokers/confluent/test_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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():
Expand All @@ -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():
Expand All @@ -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)

Expand Down Expand Up @@ -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(): ...
Expand All @@ -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(): ...
Expand Down
1 change: 0 additions & 1 deletion tests/brokers/kafka/test_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,3 @@ async def subscriber2(): ...

assert subscriber1.mock.call_count == 1
assert subscriber2.mock.call_count == 0

0 comments on commit e78ce9f

Please sign in to comment.