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


##########
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
+
+    @pytest.mark.asyncio
+    async def test_get_clients_items_are_client_info(self, iggy_client: 
IggyClient):
+        """Each item in get_clients() should be a ClientInfo with valid 
fields."""
+        clients = await iggy_client.get_clients()
+        for client in clients:
+            assert isinstance(client, ClientInfo)
+            assert isinstance(client.client_id, int)
+            assert client.client_id > 0
+            assert isinstance(client.address, str)
+            assert isinstance(client.transport, str)
+            assert isinstance(client.consumer_groups_count, int)
+
+
+class TestGetClient:
+    """Test get_client returns details for a specific client."""
+
+    @pytest.mark.asyncio
+    async def test_get_client_returns_client_info_details(
+        self, iggy_client: IggyClient
+    ):
+        """get_client() with a valid id should return ClientInfoDetails."""
+        me = await iggy_client.get_me()
+        client = await iggy_client.get_client(me.client_id)
+        assert client is not None
+        assert isinstance(client, ClientInfoDetails)
+        assert client.client_id == me.client_id
+
+    @pytest.mark.asyncio
+    async def test_get_client_unknown_id_returns_none(self, iggy_client: 
IggyClient):
+        """get_client() with an unknown id should return None."""
+        client = await iggy_client.get_client(999999)

Review Comment:
   I've given `999999` a descriptive name in the test (e.g., `INVALID_CLIENT_ID 
= 999999`) so readers know it's meant to be an ID that can't exist. The test 
now clearly communicates its intent.



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