forked from HAL9000/cleveragents-core
88 lines
3.7 KiB
Plaintext
88 lines
3.7 KiB
Plaintext
*** Settings ***
|
|
Documentation Test data contract extraction from Plandex shared Go code
|
|
Library OperatingSystem
|
|
Library Collections
|
|
Library String
|
|
Library Process
|
|
Suite Setup Run Discovery Once
|
|
|
|
*** Variables ***
|
|
${PYTHON} python
|
|
${PLANDEX_DIR} ${CURDIR}/../plandex
|
|
${OUTPUT_DIR} ${CURDIR}/../docs/reference/contracts
|
|
${PYTHON_SCRIPT} ${CURDIR}/../src/cleveragents/discovery/run_all.py
|
|
|
|
*** Keywords ***
|
|
Run Discovery Once
|
|
[Documentation] Run the discovery script once for all tests
|
|
[Tags] discovery
|
|
${result}= Run Process ${PYTHON} ${PYTHON_SCRIPT} cwd=${CURDIR}/..
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Set Suite Variable ${DISCOVERY_OUTPUT} ${result.stdout}
|
|
|
|
*** Test Cases ***
|
|
Run Data Contract Extraction
|
|
[Documentation] Test running the full discovery script with data contracts
|
|
[Tags] discovery
|
|
Should Contain ${DISCOVERY_OUTPUT} Extracting Shared Data Contracts
|
|
Should Contain ${DISCOVERY_OUTPUT} ✓ Extracted contracts from
|
|
Should Contain ${DISCOVERY_OUTPUT} Structs:
|
|
Should Contain ${DISCOVERY_OUTPUT} Enums:
|
|
Should Contain ${DISCOVERY_OUTPUT} Type aliases:
|
|
|
|
Verify JSON Contract Output
|
|
[Documentation] Test that JSON contract file is created
|
|
[Tags] discovery
|
|
File Should Exist ${OUTPUT_DIR}/data_contracts.json
|
|
${size}= Get File Size ${OUTPUT_DIR}/data_contracts.json
|
|
Should Be True ${size} > 1000 JSON file too small: ${size} bytes
|
|
|
|
# Basic structure check without full parsing
|
|
${content}= Get File ${OUTPUT_DIR}/data_contracts.json
|
|
${json_content}= Evaluate json.loads('''${content}''') json
|
|
|
|
@{module_keys}= Get Dictionary Keys ${json_content}
|
|
Should Be True len(@{module_keys}) > 0 No modules found in contracts JSON
|
|
${first_key}= Get From List ${module_keys} 0
|
|
${first_module}= Get From Dictionary ${json_content} ${first_key}
|
|
|
|
Dictionary Should Contain Key ${first_module} structs
|
|
Dictionary Should Contain Key ${first_module} enums
|
|
Dictionary Should Contain Key ${first_module} type_aliases
|
|
Dictionary Should Contain Key ${first_module} package_name
|
|
|
|
Verify Python Stubs Generation
|
|
[Documentation] Test that Python stub files are generated
|
|
[Tags] discovery
|
|
|
|
Directory Should Exist ${OUTPUT_DIR}/stubs
|
|
@{files}= List Files In Directory ${OUTPUT_DIR}/stubs *.py
|
|
${count}= Get Length ${files}
|
|
Should Be True ${count} > 0 No Python stubs generated
|
|
|
|
# Check content of first stub file
|
|
${first_file}= Get From List ${files} 0
|
|
${content}= Get File ${OUTPUT_DIR}/stubs/${first_file}
|
|
Should Contain ${content} from dataclasses import dataclass
|
|
Should Contain ${content} from typing import
|
|
|
|
Verify Example Fixtures Generation
|
|
[Documentation] Test that example JSON fixtures are generated
|
|
[Tags] discovery
|
|
|
|
Directory Should Exist ${OUTPUT_DIR}/fixtures
|
|
@{files}= List Files In Directory ${OUTPUT_DIR}/fixtures *.json
|
|
${count}= Get Length ${files}
|
|
Should Be True ${count} > 0 No fixture files generated
|
|
|
|
# Verify first fixture is valid JSON (basic check)
|
|
${first_file}= Get From List ${files} 0
|
|
${content}= Get File ${OUTPUT_DIR}/fixtures/${first_file}
|
|
Should Contain ${content} {
|
|
Should Contain ${content} }
|
|
|
|
Data Contract Performance Test
|
|
[Documentation] Test that contract extraction completes in reasonable time
|
|
[Tags] discovery
|
|
# This test is now covered by the suite setup timing
|
|
Should Contain ${DISCOVERY_OUTPUT} Discovery Summary |