ワンクリックで
test-guide
Testing patterns for claude-code-discord-bridge — pytest, async testing, mocking Discord objects, TDD workflow
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Testing patterns for claude-code-discord-bridge — pytest, async testing, mocking Discord objects, TDD workflow
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
ccdb のマイナー/メジャーリリース手順。「v1.4.0としてリリースして」等と言われたときに使う。
Python coding patterns, idioms, and quality standards for claude-code-discord-bridge development
Security checklist specific to claude-code-discord-bridge — subprocess injection, env leaks, input validation
Enforce test-driven development — write tests FIRST, then implement. Mandatory for new features and bug fixes.
Step-by-step guide to add a new discord.py Cog to the framework
Run full verification pipeline (lint, format, test, security) before committing
SOC 職業分類に基づく
| name | test-guide |
| description | Testing patterns for claude-code-discord-bridge — pytest, async testing, mocking Discord objects, TDD workflow |
Follow the Red-Green-Refactor cycle:
# pyproject.toml
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
These have no external dependencies. Test exhaustively:
def test_parse_system_message():
line = '{"type":"system","session_id":"abc-123"}'
event = parse_line(line)
assert event.message_type == MessageType.SYSTEM
assert event.session_id == "abc-123"
def test_parse_invalid_json():
event = parse_line("not json")
assert event is None
@pytest.fixture
async def repo(tmp_path):
db_path = str(tmp_path / "test.db")
await init_db(db_path)
return SessionRepository(db_path)
async def test_save_and_get(repo):
await repo.save(thread_id=123, session_id="abc-def")
result = await repo.get_session_id(thread_id=123)
assert result == "abc-def"
def test_build_args_basic():
runner = ClaudeRunner(command="claude", model="sonnet")
args = runner._build_args("hello", session_id=None)
assert args[0] == "claude"
assert "-p" in args
assert "--" in args
assert args[-1] == "hello"
def test_build_args_rejects_invalid_session():
runner = ClaudeRunner()
with pytest.raises(ValueError):
runner._build_args("hello", session_id="'; DROP TABLE --")
def test_env_strips_secrets():
runner = ClaudeRunner()
import os
os.environ["DISCORD_BOT_TOKEN"] = "test-token"
env = runner._build_env()
assert "DISCORD_BOT_TOKEN" not in env
from unittest.mock import AsyncMock, MagicMock
def make_mock_interaction(user_id: int = 12345) -> MagicMock:
interaction = MagicMock()
interaction.user = MagicMock()
interaction.user.id = user_id
interaction.response = AsyncMock()
interaction.followup = AsyncMock()
return interaction
def test_chunk_empty_string():
assert chunk_message("") == []
def test_chunk_preserves_code_blocks():
text = "```python\nprint('hello')\n```"
chunks = chunk_message(text)
assert len(chunks) == 1
def test_chunk_splits_at_boundary():
long_text = "a" * 3000
chunks = chunk_message(long_text)
assert all(len(c) <= 2000 for c in chunks)
# Full suite with coverage
uv run pytest tests/ -v --cov=claude_discord --cov-report=term-missing
# Single file
uv run pytest tests/test_parser.py -v
# Single test
uv run pytest tests/test_parser.py::test_parse_system_message -v
# Stop on first failure
uv run pytest tests/ -x