pytest-kafka-broker 0.1.1__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import asyncio
2
2
  import subprocess
3
+ from collections.abc import AsyncGenerator
3
4
  from dataclasses import dataclass
4
5
  from pathlib import Path
5
6
  from tarfile import TarFile
@@ -8,9 +9,10 @@ from uuid import uuid4
8
9
 
9
10
  import pytest
10
11
  import pytest_asyncio
11
- from astropy.config import get_cache_dir_path
12
- from astropy.utils.data import get_readable_fileobj
12
+ from astropy.config import get_cache_dir_path # type: ignore[import-untyped]
13
+ from astropy.utils.data import get_readable_fileobj # type: ignore[import-untyped]
13
14
  from confluent_kafka import Consumer, Producer
15
+ from confluent_kafka.admin import AdminClient
14
16
  from confluent_kafka.aio import AIOConsumer, AIOProducer
15
17
  from rich.status import Status
16
18
 
@@ -24,7 +26,7 @@ SCALA_VERSION = "2.13"
24
26
  KAFKA_VERSION = "4.1.1"
25
27
 
26
28
 
27
- async def wait_port(port: int, timeout: float = 0.25):
29
+ async def wait_port(port: int, timeout: float = 0.25) -> None:
28
30
  """Wait until a connection is detected listening on the given port."""
29
31
  while True:
30
32
  try:
@@ -83,9 +85,12 @@ class KafkaBrokerContext:
83
85
  bootstrap_server: str
84
86
  """Kafka bootstrap server in the form :samp:`{host}:{port}`."""
85
87
 
86
- def config(self, config: dict | None = None):
88
+ def config(self, config: dict | None = None) -> dict:
87
89
  return {**(config or {}), "bootstrap.servers": self.bootstrap_server}
88
90
 
91
+ def admin(self, config: dict | None = None) -> AdminClient:
92
+ return AdminClient(self.config(config))
93
+
89
94
  def producer(self, config: dict | None = None) -> Producer:
90
95
  return Producer(self.config(config))
91
96
 
@@ -99,6 +104,7 @@ class KafkaBrokerContext:
99
104
  return AIOConsumer(self.config(config))
100
105
 
101
106
  config.__doc__ = _doc.format("Get the configuration for a Kafka client.")
107
+ admin.__doc__ = _doc.format("Create a Kafka admin client connected to the cluster.")
102
108
  producer.__doc__ = _doc.format("Create a Kafka producer connected to the cluster.")
103
109
  consumer.__doc__ = _doc.format("Create a Kafka consumer connected to the cluster.")
104
110
  aio_producer.__doc__ = _doc.format(
@@ -113,13 +119,10 @@ del _doc
113
119
 
114
120
 
115
121
  @pytest_asyncio.fixture
116
- async def kafka_broker(kafka_home, tmp_path, unused_tcp_port_factory):
117
- """Pytest fixture to run a local, temporary Kafka broker.
118
-
119
- Returns
120
- -------
121
- : KafkaBrokerContext
122
- """
122
+ async def kafka_broker(
123
+ kafka_home, tmp_path, unused_tcp_port_factory
124
+ ) -> AsyncGenerator[KafkaBrokerContext]:
125
+ """Pytest fixture to run a local, temporary Kafka broker."""
123
126
  kafka_storage = kafka_home / "bin" / "kafka-storage.sh"
124
127
  kafka_server_start = kafka_home / "bin" / "kafka-server-start.sh"
125
128
  config_path = tmp_path / "server.properties"
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-kafka-broker
3
- Version: 0.1.1
3
+ Version: 0.3.0
4
4
  Summary: Pytest plugin to run a single-broker Kafka cluster
5
5
  Author-email: Leo Singer <leo.singer@ligo.org>
6
6
  License-Expression: Apache-2.0
@@ -0,0 +1,7 @@
1
+ pytest_kafka_broker/__init__.py,sha256=3mODu1laOwp9moAXLnrMPZo6Zb7CWe-L7g7pVUVvQPU,6396
2
+ pytest_kafka_broker/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pytest_kafka_broker-0.3.0.dist-info/METADATA,sha256=KI9mVBcRN688rjCpdLfNx99-LhOpq4pj_D4u7WTlwYI,683
4
+ pytest_kafka_broker-0.3.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
5
+ pytest_kafka_broker-0.3.0.dist-info/entry_points.txt,sha256=mjFsRbu6FOiZkUOlSaXpo4QdLHwniNB-p_NEIgRbDnw,46
6
+ pytest_kafka_broker-0.3.0.dist-info/top_level.txt,sha256=nTrYx9xVeK5hsqbhBRL2bgBV_ea-J66_f4Dk8eD-Ci0,20
7
+ pytest_kafka_broker-0.3.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- pytest_kafka_broker.py,sha256=h0D80ZYRw_cxB7wdwKvhctSiGyB_GNX4G75w8M_BQF0,6036
2
- pytest_kafka_broker-0.1.1.dist-info/METADATA,sha256=sihNIutx9OFvjaVwEhO4oP-wiDe6qJCumcYgNovf-3g,683
3
- pytest_kafka_broker-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
- pytest_kafka_broker-0.1.1.dist-info/entry_points.txt,sha256=mjFsRbu6FOiZkUOlSaXpo4QdLHwniNB-p_NEIgRbDnw,46
5
- pytest_kafka_broker-0.1.1.dist-info/top_level.txt,sha256=nTrYx9xVeK5hsqbhBRL2bgBV_ea-J66_f4Dk8eD-Ci0,20
6
- pytest_kafka_broker-0.1.1.dist-info/RECORD,,