AGENT SKILL
gen-test
Generate unit tests for nd-mock API endpoints
使用场景测试与质量
- License 许可
- Apache-2.0
- 最近更新
- 2026-03-08
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- gen-test
- arguments
- [ { "name": "endpoint", "required": true, "description": "Path to the endpoint module to test (e.g., app/v1/endpoints/manage/fabrics/fabric_get.py)" } ]
- description
- Generate unit tests for nd-mock API endpoints
- disable-model-invocation
- true
02 资源文件 2
- 参考文档SOURCE.md336 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
Generate Unit Tests
Generate pytest unit tests for the specified endpoint module, following the project's established testing patterns.
Test Conventions
- Tests use
fastapi.testclient.TestClientwith an in-memory SQLite database - Import fixtures from
tests/unit/common.py:client_fixture,session_fixture - Test data is loaded from JSON files via a
data_loader.pyandload_test_data()helper - Test function names follow pattern:
test_{version}_{resource}_{method}_{number}(e.g.,test_v1_fabric_post_100) - Each test uses
inspect.currentframe().f_code.co_nameto load its corresponding test data - Include standard pylint disables at the top of test files
Steps
- Read the endpoint module specified in the
endpointargument - Read the corresponding model(s) used by the endpoint
- Look at existing tests in
tests/unit/to match the style exactly - Generate test file with:
- Standard pylint/mypy disable comments
- Proper relative imports for models and common fixtures
- A
load_test_data()helper function - Tests for success cases (status 200) and error cases (400, 404, 422)
- Assertions on
response.status_codeandresponse.json()structure
- Generate corresponding test data JSON file in a
data/subdirectory - Run
pyteston the new test file to verify it passes
04 同仓库更多 Skills
sync-docs
Regenerate docs/supported_endpoints.md by running utils/docs_generate.py and verify it matches current endpoint registrations in app/main.py
★ 1
add-endpoint
Scaffold a new API endpoint with models, router, main.py registration, and test stubs based on schema/manage.json or schema/infra.json definitions
★ 1