Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Dec 10, 2024
1 parent 6c67fd0 commit 59ac61d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Optional, Self
from typing import Optional

from typing_extensions import Self

from faststream.specification.asyncapi.v2_6_0.schema.bindings.amqp import (
ChannelBinding as V2Binding,
Expand Down
4 changes: 0 additions & 4 deletions tests/prometheus/confluent/basic.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from typing import Any

from faststream import AckPolicy
from faststream.confluent import KafkaBroker
from faststream.confluent.prometheus import KafkaPrometheusMiddleware
from tests.brokers.confluent.basic import ConfluentTestcaseConfig


class KafkaPrometheusSettings(ConfluentTestcaseConfig):
messaging_system = "kafka"

def get_broker(self, apply_types=False, **kwargs: Any) -> KafkaBroker:
return KafkaBroker(apply_types=apply_types, **kwargs)

def get_middleware(self, **kwargs: Any) -> KafkaPrometheusMiddleware:
return KafkaPrometheusMiddleware(**kwargs)

Expand Down
4 changes: 0 additions & 4 deletions tests/prometheus/kafka/basic.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from typing import Any

from faststream import AckPolicy
from faststream.kafka import KafkaBroker
from faststream.kafka.prometheus import KafkaPrometheusMiddleware
from tests.brokers.kafka.basic import KafkaTestcaseConfig


class KafkaPrometheusSettings(KafkaTestcaseConfig):
messaging_system = "kafka"

def get_broker(self, apply_types=False, **kwargs: Any) -> KafkaBroker:
return KafkaBroker(apply_types=apply_types, **kwargs)

def get_middleware(self, **kwargs: Any) -> KafkaPrometheusMiddleware:
return KafkaPrometheusMiddleware(**kwargs)

Expand Down
3 changes: 2 additions & 1 deletion tests/prometheus/nats/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from faststream.nats import NatsBroker
from faststream.nats.prometheus import NatsPrometheusMiddleware
from tests.brokers.nats.basic import NatsTestcaseConfig


class NatsPrometheusSettings:
class NatsPrometheusSettings(NatsTestcaseConfig):
messaging_system = "nats"

def get_broker(self, apply_types=False, **kwargs: Any) -> NatsBroker:
Expand Down
4 changes: 3 additions & 1 deletion tests/prometheus/nats/test_nats.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def stream(queue):

@pytest.mark.nats()
class TestPrometheus(
NatsPrometheusSettings, LocalPrometheusTestcase, LocalRPCPrometheusTestcase
NatsPrometheusSettings,
LocalPrometheusTestcase,
LocalRPCPrometheusTestcase,
):
async def test_metrics_batch(
self,
Expand Down
3 changes: 2 additions & 1 deletion tests/prometheus/nats/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@


class LocalBaseNatsMetricsSettingsProviderTestcase(
NatsPrometheusSettings, LocalMetricsSettingsProviderTestcase
NatsPrometheusSettings,
LocalMetricsSettingsProviderTestcase,
):
def test_get_publish_destination_name_from_cmd(self, queue: str) -> None:
expected_destination_name = queue
Expand Down
4 changes: 0 additions & 4 deletions tests/prometheus/rabbit/basic.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from typing import Any

from faststream.rabbit import RabbitBroker
from faststream.rabbit.prometheus import RabbitPrometheusMiddleware
from tests.brokers.rabbit.basic import RabbitTestcaseConfig


class RabbitPrometheusSettings(RabbitTestcaseConfig):
messaging_system = "rabbitmq"

def get_broker(self, apply_types=False, **kwargs: Any) -> RabbitBroker:
return RabbitBroker(apply_types=apply_types, **kwargs)

def get_middleware(self, **kwargs: Any) -> RabbitPrometheusMiddleware:
return RabbitPrometheusMiddleware(**kwargs)
6 changes: 1 addition & 5 deletions tests/prometheus/rabbit/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@

from faststream.prometheus import MetricsSettingsProvider
from faststream.rabbit.prometheus.provider import RabbitMetricsSettingsProvider
from tests.prometheus.basic import (
LocalMetricsSettingsProviderTestcase,
LocalRPCPrometheusTestcase,
)
from tests.prometheus.basic import LocalMetricsSettingsProviderTestcase

from .basic import RabbitPrometheusSettings


class TestRabbitMetricsSettingsProvider(
RabbitPrometheusSettings,
LocalMetricsSettingsProviderTestcase,
LocalRPCPrometheusTestcase,
):
@staticmethod
def get_provider() -> MetricsSettingsProvider:
Expand Down
4 changes: 0 additions & 4 deletions tests/prometheus/redis/basic.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from typing import Any

from faststream.redis import RedisBroker
from faststream.redis.prometheus import RedisPrometheusMiddleware
from tests.brokers.redis.basic import RedisTestcaseConfig


class RedisPrometheusSettings(RedisTestcaseConfig):
messaging_system = "redis"

def get_broker(self, apply_types=False, **kwargs: Any) -> RedisBroker:
return RedisBroker(apply_types=apply_types, **kwargs)

def get_middleware(self, **kwargs: Any) -> RedisPrometheusMiddleware:
return RedisPrometheusMiddleware(**kwargs)

0 comments on commit 59ac61d

Please sign in to comment.