BewareMyPower commented on code in PR #289:
URL: 
https://github.com/apache/pulsar-client-python/pull/289#discussion_r2752320302


##########
tests/asyncio_test.py:
##########
@@ -133,6 +155,48 @@ async def test_flush(self):
         self.assertEqual(msg_id0.batch_index(), 0)
         self.assertEqual(msg_id1.batch_index(), 1)
 
+    async def test_get_topics_partitions(self):
+        topic_partitioned = 
"persistent://public/default/test_get_topics_partitions_async"
+        topic_non_partitioned = 
"persistent://public/default/test_get_topics_async_not-partitioned"
+
+        url1 = ADMIN_URL + 
"/admin/v2/persistent/public/default/test_get_topics_partitions_async/partitions"
+        doHttpPut(url1, "3")
+
+        self.assertEqual(
+            await self._client.get_topic_partitions(topic_partitioned),
+            [
+                
"persistent://public/default/test_get_topics_partitions_async-partition-0",
+                
"persistent://public/default/test_get_topics_partitions_async-partition-1",
+                
"persistent://public/default/test_get_topics_partitions_async-partition-2",
+            ],
+        )
+        self.assertEqual(await 
self._client.get_topic_partitions(topic_non_partitioned), 
[topic_non_partitioned])
+
+    async def test_get_partitioned_topic_name(self):
+        url1 = ADMIN_URL + 
"/admin/v2/persistent/public/default/partitioned_topic_name_test/partitions"
+        doHttpPut(url1, "3")
+
+        partitions = [
+            
"persistent://public/default/partitioned_topic_name_test-partition-0",
+            
"persistent://public/default/partitioned_topic_name_test-partition-1",
+            
"persistent://public/default/partitioned_topic_name_test-partition-2",
+        ]
+        self.assertEqual(
+            await 
self._client.get_topic_partitions("persistent://public/default/partitioned_topic_name_test"),
 partitions
+        )
+
+        consumer = await self._client.subscribe(
+            "persistent://public/default/partitioned_topic_name_test",
+            "partitioned_topic_name_test_sub",
+            consumer_type=pulsar.ConsumerType.Shared,
+        )
+        producer = await 
self._client.create_producer("persistent://public/default/partitioned_topic_name_test")
+        await producer.send(b"hello")
+
+        async with asyncio.timeout(TIMEOUT_MS / 1000):

Review Comment:
   The `timeout` function is first added in Python 3.11. Since Python 3.10 
won't reach the EOL until Nov. 2026, you can use `asyncio.wait_for` instead



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to