From 81771b55520a2a11de6a717992586532a694f487 Mon Sep 17 00:00:00 2001 From: Nikita Pastukhov Date: Wed, 7 Aug 2024 21:08:21 +0300 Subject: [PATCH] tests: increase confluent tests timeouts --- .../subscription/confluent/real_testing.py | 4 ++-- faststream/nats/subscriber/usecase.py | 1 + .../getting_started/publishing/test_broker_context.py | 2 +- tests/opentelemetry/kafka/test_kafka.py | 9 ++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/docs_src/getting_started/subscription/confluent/real_testing.py b/docs/docs_src/getting_started/subscription/confluent/real_testing.py index 9bf9feee62..43973935b9 100644 --- a/docs/docs_src/getting_started/subscription/confluent/real_testing.py +++ b/docs/docs_src/getting_started/subscription/confluent/real_testing.py @@ -10,7 +10,7 @@ async def test_handle(): async with TestKafkaBroker(broker, with_real=True) as br: await br.publish({"name": "John", "user_id": 1}, topic="test-topic-confluent") - await handle.wait_call(timeout=20) + await handle.wait_call(timeout=30) handle.mock.assert_called_once_with({"name": "John", "user_id": 1}) assert handle.mock is None @@ -20,6 +20,6 @@ async def test_validation_error(): async with TestKafkaBroker(broker, with_real=True) as br: with pytest.raises(ValidationError): await br.publish("wrong message", topic="test-confluent-wrong-fields") - await wrong_handle.wait_call(timeout=20) + await wrong_handle.wait_call(timeout=30) wrong_handle.mock.assert_called_once_with("wrong message") diff --git a/faststream/nats/subscriber/usecase.py b/faststream/nats/subscriber/usecase.py index 85c133770c..ba77aac70c 100644 --- a/faststream/nats/subscriber/usecase.py +++ b/faststream/nats/subscriber/usecase.py @@ -1,6 +1,7 @@ import asyncio from abc import abstractmethod from contextlib import suppress +from functools import cached_property from typing import ( TYPE_CHECKING, Any, diff --git a/tests/docs/getting_started/publishing/test_broker_context.py b/tests/docs/getting_started/publishing/test_broker_context.py index 19207f0dc9..b44b9a2144 100644 --- a/tests/docs/getting_started/publishing/test_broker_context.py +++ b/tests/docs/getting_started/publishing/test_broker_context.py @@ -38,7 +38,7 @@ async def test_broker_context_confluent(): from faststream.confluent import TestKafkaBroker as TestConfluentKafkaBroker async with TestConfluentKafkaBroker(broker, with_real=True), TestApp(app): - await handle.wait_call(20) + await handle.wait_call(30) handle.mock.assert_called_once_with("Hi!") diff --git a/tests/opentelemetry/kafka/test_kafka.py b/tests/opentelemetry/kafka/test_kafka.py index c8f67b40b1..4c8995f7ed 100644 --- a/tests/opentelemetry/kafka/test_kafka.py +++ b/tests/opentelemetry/kafka/test_kafka.py @@ -79,7 +79,8 @@ async def test_batch( expected_link_count = 1 expected_link_attrs = {"messaging.batch.message_count": 3} - @broker.subscriber(queue, batch=True, **self.subscriber_kwargs) + args, kwargs = self.get_subscriber_params(queue, batch=True) + @broker.subscriber(*args, **kwargs) async def handler(m): mock(m) event.set() @@ -131,7 +132,8 @@ async def test_batch_publish_with_single_consume( expected_span_count = 8 expected_pub_batch_count = 1 - @broker.subscriber(queue, **self.subscriber_kwargs) + args, kwargs = self.get_subscriber_params(queue) + @broker.subscriber(*args, **kwargs) async def handler(msg): await msgs_queue.put(msg) @@ -189,7 +191,8 @@ async def test_single_publish_with_batch_consume( expected_span_count = 6 expected_process_batch_count = 1 - @broker.subscriber(queue, batch=True, **self.subscriber_kwargs) + args, kwargs = self.get_subscriber_params(queue, batch=True) + @broker.subscriber(*args, **kwargs) async def handler(m): m.sort() mock(m)