Files
cleveragents-core/robot/server_endpoints.robot
T

135 lines
6.4 KiB
Plaintext

*** Settings ***
*** Variables ***
${PYTHON} python
Documentation Test suite for server endpoint discovery functionality
Library OperatingSystem
Library Collections
Library Process
*** Test Cases ***
Server Endpoint Extraction Should Work
[Documentation] Test that server endpoint extraction runs successfully
[Tags] discovery
${result}= Run Process ${PYTHON} -m cleveragents.discovery.server_endpoints cwd=/app
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} Server Endpoint Extraction Complete
Should Contain ${result.stdout} Total endpoints:
Should Contain ${result.stdout} Streaming endpoints:
Server Endpoint Files Should Be Created
[Documentation] Verify that all expected output files are created
[Tags] discovery
File Should Exist /app/docs/reference/server_endpoints.yaml
File Should Exist /app/docs/reference/server_endpoints.json
File Should Exist /app/docs/reference/server_api.yaml
Server Endpoint JSON Should Be Valid
[Documentation] Test that generated JSON is valid and contains expected structure
[Tags] discovery
${json_content}= Load JSON From File /app/docs/reference/server_endpoints.json
Dictionary Should Contain Key ${json_content} metadata
Dictionary Should Contain Key ${json_content} statistics
Dictionary Should Contain Key ${json_content} endpoints_by_category
Dictionary Should Contain Key ${json_content} all_endpoints
${stats}= Get From Dictionary ${json_content} statistics
Dictionary Should Contain Key ${stats} total_endpoints
Dictionary Should Contain Key ${stats} streaming_endpoints
Dictionary Should Contain Key ${stats} categories
Dictionary Should Contain Key ${stats} methods
Server OpenAPI Spec Should Be Valid
[Documentation] Test that OpenAPI spec is valid YAML with correct structure
[Tags] discovery
${yaml_content}= Get File /app/docs/reference/server_api.yaml
Should Contain ${yaml_content} openapi:
Should Contain ${yaml_content} info:
Should Contain ${yaml_content} paths:
Should Contain ${yaml_content} components:
Server Endpoint Count Should Be Reasonable
[Documentation] Verify that a reasonable number of endpoints were extracted
[Tags] discovery
${json_content}= Load JSON From File /app/docs/reference/server_endpoints.json
${stats}= Get From Dictionary ${json_content} statistics
${total}= Get From Dictionary ${stats} total_endpoints
Should Be True ${total} >= 80 Expected at least 80 endpoints, got ${total}
Streaming Endpoints Should Be Identified
[Documentation] Verify that streaming endpoints are properly identified
[Tags] discovery
${json_content}= Load JSON From File /app/docs/reference/server_endpoints.json
${stats}= Get From Dictionary ${json_content} statistics
${streaming}= Get From Dictionary ${stats} streaming_endpoints
Should Be True ${streaming} >= 3 Expected at least 3 streaming endpoints, got ${streaming}
Endpoint Categories Should Be Comprehensive
[Documentation] Verify that endpoints are properly categorized
[Tags] discovery
${json_content}= Load JSON From File /app/docs/reference/server_endpoints.json
${categories}= Get From Dictionary ${json_content} endpoints_by_category
Dictionary Should Contain Key ${categories} Authentication
Dictionary Should Contain Key ${categories} Plans
Dictionary Should Contain Key ${categories} Projects
Dictionary Should Contain Key ${categories} Models
Dictionary Should Contain Key ${categories} Organizations
Dictionary Should Contain Key ${categories} System
${auth_endpoints}= Get From Dictionary ${categories} Authentication
${length}= Get Length ${auth_endpoints}
Should Be True ${length} > 0 Authentication category should have endpoints
HTTP Methods Should Be Diverse
[Documentation] Verify that various HTTP methods are extracted
[Tags] discovery
${json_content}= Load JSON From File /app/docs/reference/server_endpoints.json
${stats}= Get From Dictionary ${json_content} statistics
${methods}= Get From Dictionary ${stats} methods
Dictionary Should Contain Key ${methods} GET
Dictionary Should Contain Key ${methods} POST
Dictionary Should Contain Key ${methods} PUT
Dictionary Should Contain Key ${methods} DELETE
Dictionary Should Contain Key ${methods} PATCH
Path Parameters Should Be Extracted
[Documentation] Verify that path parameters are properly extracted
[Tags] discovery
${json_content}= Load JSON From File /app/docs/reference/server_endpoints.json
${endpoints}= Get From Dictionary ${json_content} all_endpoints
${params_found}= Set Variable ${False}
${planId_found}= Set Variable ${False}
${projectId_found}= Set Variable ${False}
FOR ${endpoint} IN @{endpoints}
${has_params}= Run Keyword And Return Status
... Dictionary Should Contain Key ${endpoint} path_params
IF ${has_params}
${params}= Get From Dictionary ${endpoint} path_params
${length}= Get Length ${params}
IF ${length} > 0
${params_found}= Set Variable ${True}
${param_str}= Convert To String ${params}
IF 'planId' in $param_str
${planId_found}= Set Variable ${True}
END
IF 'projectId' in $param_str
${projectId_found}= Set Variable ${True}
END
END
END
END
Should Be True ${params_found} No endpoints with path parameters found
Should Be True ${planId_found} planId parameter not found in any endpoint
Should Be True ${projectId_found} projectId parameter not found in any endpoint
*** Keywords ***
Load JSON From File
[Arguments] ${file_path}
${content}= Get File ${file_path}
${json}= Evaluate json.loads('''${content}''') json
RETURN ${json}