Abyss-lord commented on code in PR #9483:
URL: https://github.com/apache/gravitino/pull/9483#discussion_r2654531639


##########
clients/client-python/tests/unittests/dto/responses/test_responses.py:
##########
@@ -483,13 +492,75 @@ def test_partition_list_response(self):
         """
         partitions = [
             PartitionDTOSerdes.deserialize(
-                json.loads(TestResponses.PARTITION_JSON_STRING)
+                _json.loads(TestResponses.PARTITION_JSON_STRING)
             )
         ]
         resp: PartitionListResponse = 
PartitionListResponse.from_json(json_string)
         resp.validate()
         self.assertListEqual(resp.get_partitions(), partitions)
 
+    def test_tag_response(self) -> None:
+        tag_dto = TagDTO.builder().name("tag1").comment("comment1").build()
+        tag_resp = TagResponse(0, tag_dto)
+
+        tag_resp.validate()
+
+        # test serialization
+        ser_json = _json.dumps(tag_resp.to_dict())
+        deser_dict = _json.loads(ser_json)
+
+        self.assertEqual(tag_dto, tag_resp.tag())
+        self.assertEqual(0, deser_dict["code"])
+        self.assertIsNotNone(deser_dict.get("tag"))
+        self.assertEqual("tag1", deser_dict["tag"]["name"])
+        self.assertEqual("comment1", deser_dict["tag"]["comment"])
+
+        tag_dto_invalid = TagDTO.builder().build()
+        with self.assertRaises(ValueError):
+            tag_resp = TagResponse(tag_dto_invalid)
+            tag_resp.validate()
+
+    def test_tag_name_list_response(self) -> None:
+        tag_names = ["tag1", "tag2", "tag3"]
+        tag_name_list_resp = TagNamesListResponse(0, tag_names)
+
+        tag_name_list_resp.validate()
+
+        # test serialization
+        ser_json = _json.dumps(tag_name_list_resp.to_dict())
+        deser_dict = _json.loads(ser_json)
+
+        self.assertEqual(0, deser_dict["code"])
+        self.assertIsNotNone(deser_dict.get("names"))
+        self.assertEqual(3, len(deser_dict["names"]))
+        self.assertListEqual(tag_names, deser_dict["names"])
+
+    def test_tag_list_response(self) -> None:
+        tag_dto1 = TagDTO.builder().name("tag1").comment("comment1").build()
+        tag_dto2 = TagDTO.builder().name("tag2").comment("comment2").build()
+        tag_dto3 = TagDTO.builder().name("tag3").comment("comment3").build()
+
+        tag_list_resp = TagListResponse(0, [tag_dto1, tag_dto2, tag_dto3])
+
+        tag_list_resp.validate()
+
+        # test serialization
+        ser_json = _json.dumps(tag_list_resp.to_dict())
+        deser_dict = _json.loads(ser_json)
+
+        self.assertEqual(0, deser_dict["code"])
+        self.assertIsNotNone(deser_dict.get("tags"))
+        self.assertEqual(3, len(deser_dict["tags"]))
+
+        self.assertEqual("tag1", deser_dict["tags"][0]["name"])
+        self.assertEqual("comment1", deser_dict["tags"][0]["comment"])
+
+        self.assertEqual("tag2", deser_dict["tags"][1]["name"])
+        self.assertEqual("comment2", deser_dict["tags"][1]["comment"])
+
+        self.assertEqual("tag3", deser_dict["tags"][2]["name"])
+        self.assertEqual("comment3", deser_dict["tags"][2]["comment"])
+

Review Comment:
   fix



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