-
Writing API test code based on Coze’s API
Prompt: This is a python project. Please generate API test code based on the interface information described in the online documentation. https://www.coze.cn/docs/developer_guides/retrieve_chat
Request Example: curl --location --request GET 'https://api.coze.cn/v3/chat/retrieve?chat_id=738137187639794****&conversation_id=738136585609548****' \ --header 'Authorization: Bearer pat_OYDacMzM3WyOWV3Dtj2bHRMymzxP****' \ --header 'Content-Type: application/json' \ Response Example: { "code": 0, "data": { "bot_id": "737946218936519****", "completed_at": 1718609575, "conversation_id": "738136585609548****", "created_at": 1718609571, "id": "738137187639794****", "status": "completed", "usage": { "input_count": 242, "output_count": 56, "token_count": 298 } }, "msg": ""}
Prompt: Please modify the code based on the request and response examples in @example.txt to improve the testing scenarios.
-
Generating a mind map based on the code
Once the code runs correctly, I asked Windsurf to generate a mind map based on the code.
Prompt: Please generate a mind map of test cases based on the test code.
# Coze API Test Cases ## 1. Basic Configuration - API Base URL: https://api.coze.cn - API Version: v3 - Endpoint: /chat/retrieve - Authentication Method: Bearer Token ## 2. Normal Scenario Tests (test_retrieve_chat_success) ### Request Parameter Validation - chat_id is correct - conversation_id is correct ### Response Validation - HTTP status code is 200 - response code is 0 - msg field exists ### Data Structure Validation - Validate that the data object exists - Validate basic chat information * id * conversation_id * bot_id * completed_at * created_at * status - Validate usage information * input_count * output_count * token_count ## 3. Abnormal Scenario Tests ### Invalid chat_id (test_retrieve_chat_invalid_chat_id) - Use an invalid chat_id - Validate error response - Check error message ### Invalid conversation_id (test_retrieve_chat_invalid_conversation_id) - Use an invalid conversation_id - Validate error response - Check error message ### Missing Parameter Tests (test_retrieve_chat_missing_params) - Missing chat_id - Missing conversation_id - Validate error response ### Authentication Exception Tests (test_retrieve_chat_invalid_auth) - Use an invalid authentication token - Validate error response - Check error message ## 4. Test Data ### Example Values - chat_id: **** - conversation_id: **** - bot_id: ****
