testing-requirements
Use when writing tests - test structure, mocking patterns, pre-commit checks
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when writing tests - test structure, mocking patterns, pre-commit checks
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Master code organization - encapsulation with wrapper methods, file modularity (split >150 lines), one function one responsibility, descriptive naming, minimal comments
Use when starting work - guidelines for asking questions and commit policies
Use when adding error handling - exception patterns, HTTP codes, domain exceptions
Use when adding logging to features - structured logging with LoggerService categories
Use when exiting plan mode - where to save implementation plans
Apply Martin Fowler's refactoring patterns - extract variables to eliminate repetition, split temporary variables, replace temp with query for cleaner, more maintainable code
| name | testing-requirements |
| description | Use when writing tests - test structure, mocking patterns, pre-commit checks |
Use this skill when writing tests for features or fixing bugs.
app/ structure in tests/ directoryapp/features/generators/service.py → tests/app/features/generators/test_service.py)test_ prefix for all test files and test functionspytest.mark.asyncio decorator for async testsCover all three paths:
import pytest
from unittest.mock import Mock, patch
from app.features.generators.service import GeneratorService
@pytest.mark.asyncio
async def test_generate_image_success():
"""Test successful image generation (happy path)."""
mock_db = Mock()
config = GenerateConfig(prompt="test", model_id=1)
with patch('app.cores.model_manager.load_model'):
result = await GeneratorService.generate(config, mock_db)
assert result.success is True
@pytest.mark.asyncio
async def test_generate_image_invalid_model():
"""Test error handling for invalid model (error case)."""
mock_db = Mock()
config = GenerateConfig(prompt="test", model_id=999)
with pytest.raises(ValueError, match="Model not found"):
await GeneratorService.generate(config, mock_db)
@pytest.mark.asyncio
async def test_generate_image_empty_prompt():
"""Test handling of empty prompt (edge case)."""
mock_db = Mock()
config = GenerateConfig(prompt="", model_id=1)
with pytest.raises(ValueError, match="Prompt cannot be empty"):
await GeneratorService.generate(config, mock_db)
Before marking work complete, run all checks:
uv run ty check app/path/to/modified.py tests/path/to/test.pyuv run ruff check --fix app/ tests/uv run ruff format app/ tests/uv run pytest -q