yummyPancake2607 commented on code in PR #4020:
URL: https://github.com/apache/iggy/pull/4020#discussion_r3939290764


##########
foreign/python/tests/test_client_info.py:
##########
@@ -0,0 +1,111 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import pytest
+
+from apache_iggy import ClientInfo, ClientInfoDetails, IggyClient
+
+
+class TestGetMe:
+    """Test get_me returns the currently connected client."""
+
+    @pytest.mark.asyncio
+    async def test_get_me_returns_client_info_details(self, iggy_client: 
IggyClient):
+        """get_me() should return a ClientInfoDetails with valid fields."""
+        me = await iggy_client.get_me()
+        assert isinstance(me, ClientInfoDetails)
+        assert isinstance(me.client_id, int)
+        assert me.client_id > 0
+        assert isinstance(me.address, str)
+        assert len(me.address) > 0
+        assert isinstance(me.transport, str)
+        assert isinstance(me.consumer_groups_count, int)
+        assert isinstance(me.consumer_groups, list)
+
+    @pytest.mark.asyncio
+    async def test_get_me_user_id_matches_logged_in_user(self, iggy_client: 
IggyClient):
+        """get_me().user_id should be set after login."""
+        me = await iggy_client.get_me()
+        assert me.user_id is not None
+        assert isinstance(me.user_id, int)
+
+
+class TestGetClients:
+    """Test get_clients returns all connected clients."""
+
+    @pytest.mark.asyncio
+    async def test_get_clients_returns_list(self, iggy_client: IggyClient):
+        """get_clients() should return a non-empty list of ClientInfo."""
+        clients = await iggy_client.get_clients()
+        assert isinstance(clients, list)
+        assert len(clients) >= 1
+
+    @pytest.mark.asyncio
+    async def test_get_clients_contains_current_client(self, iggy_client: 
IggyClient):
+        """The current client (from get_me) should appear in get_clients()."""
+        me = await iggy_client.get_me()
+        clients = await iggy_client.get_clients()
+        client_ids = [c.client_id for c in clients]
+        assert me.client_id in client_ids

Review Comment:
    I've fixed the test to use `next(..., None)` and added the completeness 
comment about shards missing the 3s gather budget dropping clients from 
results. The test now safely handles the case where no matching client is found



-- 
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