SuperClaude/tests/conftest.py

118 lines
3.2 KiB
Python
Raw Normal View History

feat: add comprehensive test suite, CI/CD workflows, and install command Major improvements to SuperClaude Framework infrastructure and testing: ## New Features - Add 'superclaude install' command to install slash commands (/research, /index-repo, /agent, /recommend) - Create comprehensive test suite with 71 tests (70 passing, 1 skipped) - Add GitHub Actions CI/CD workflows for automated testing - Add essential documentation files (PLANNING.md, TASK.md, KNOWLEDGE.md) ## Testing - tests/unit/: 59 tests covering PM Agent components - test_confidence.py: 13 tests for ConfidenceChecker - test_self_check.py: 14 tests for SelfCheckProtocol - test_reflexion.py: 9 tests for ReflexionPattern - test_token_budget.py: 12 tests for TokenBudgetManager - test_cli_install.py: 12 tests for install command (NEW) - tests/integration/: 11 tests for pytest plugin integration - tests/conftest.py: Shared fixtures for all tests ## CI/CD Workflows - .github/workflows/test.yml: Comprehensive test matrix - Tests on Python 3.10, 3.11, 3.12 - Lint and format checks with ruff - Pytest plugin verification - SuperClaude doctor health checks - Coverage reporting with Codecov - .github/workflows/quick-check.yml: Fast PR validation (~2-3 min) - .github/workflows/README.md: Workflow documentation ## Documentation - PLANNING.md: Architecture, design principles, absolute rules - TASK.md: Current tasks, priorities, backlog - KNOWLEDGE.md: Accumulated insights, best practices, troubleshooting ## Bug Fixes - Fix .gitignore contradictions (remove conflicting Claude Code patterns) - Fix TokenBudgetManager to properly validate and default invalid complexity - Update package.json version to 4.1.6 (sync with VERSION file) ## CLI Improvements - src/superclaude/cli/install_commands.py: Command installation logic - src/superclaude/cli/main.py: Add 'install' command with --list and --force options - README.md: Update installation instructions with correct commands ## Breaking Changes None - all changes are backwards compatible ## Migration Guide Users should run 'superclaude install' after upgrading to install slash commands Fixes #466 (indirectly by clarifying installation process) Refs #419 (plugin system - documentation updated) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 18:21:22 +01:00
"""
Pytest configuration and shared fixtures for SuperClaude tests
This file is automatically loaded by pytest and provides
shared fixtures available to all test modules.
"""
import pytest
from pathlib import Path
@pytest.fixture
def sample_context():
"""
Provide a sample context for confidence checking tests
Returns:
Dict with test context including various checks
"""
return {
"test_name": "test_sample_feature",
"test_file": __file__,
"duplicate_check_complete": True,
"architecture_check_complete": True,
"official_docs_verified": True,
"oss_reference_complete": True,
"root_cause_identified": True,
"markers": ["unit", "confidence_check"],
}
@pytest.fixture
def low_confidence_context():
"""
Provide a context that should result in low confidence
Returns:
Dict with incomplete checks
"""
return {
"test_name": "test_unclear_feature",
"test_file": __file__,
"duplicate_check_complete": False,
"architecture_check_complete": False,
"official_docs_verified": False,
"oss_reference_complete": False,
"root_cause_identified": False,
"markers": ["unit"],
}
@pytest.fixture
def sample_implementation():
"""
Provide a sample implementation for self-check validation
Returns:
Dict with implementation details
"""
return {
"tests_passed": True,
"test_output": "✅ 5 tests passed in 0.42s",
"requirements": ["Feature A", "Feature B", "Feature C"],
"requirements_met": ["Feature A", "Feature B", "Feature C"],
"assumptions": ["API returns JSON", "Database is PostgreSQL"],
"assumptions_verified": ["API returns JSON", "Database is PostgreSQL"],
"evidence": {
"test_results": "✅ All tests passing",
"code_changes": ["file1.py", "file2.py"],
"validation": "Linting passed, type checking passed",
},
"status": "complete",
}
@pytest.fixture
def failing_implementation():
"""
Provide a failing implementation for self-check validation
Returns:
Dict with failing implementation details
"""
return {
"tests_passed": False,
"test_output": "",
"requirements": ["Feature A", "Feature B", "Feature C"],
"requirements_met": ["Feature A"],
"assumptions": ["API returns JSON", "Database is PostgreSQL"],
"assumptions_verified": ["API returns JSON"],
"evidence": {},
"status": "complete",
"errors": ["TypeError in module X"],
}
@pytest.fixture
def temp_memory_dir(tmp_path):
"""
Create temporary memory directory structure for PM Agent tests
Args:
tmp_path: pytest's temporary path fixture
Returns:
Path to temporary memory directory
"""
memory_dir = tmp_path / "docs" / "memory"
memory_dir.mkdir(parents=True)
# Create empty memory files
(memory_dir / "pm_context.md").write_text("# PM Context\n")
(memory_dir / "last_session.md").write_text("# Last Session\n")
(memory_dir / "next_actions.md").write_text("# Next Actions\n")
(memory_dir / "reflexion.jsonl").write_text("")
return memory_dir