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