Skip to content

Add test infrastructure post refactoring (issue #24) - #38

Open
atarukun wants to merge 1 commit into
mainfrom
feature/add-test-infrastructure
Open

Add test infrastructure post refactoring (issue #24)#38
atarukun wants to merge 1 commit into
mainfrom
feature/add-test-infrastructure

Conversation

@atarukun

Copy link
Copy Markdown
Owner

Summary

This PR implements the test infrastructure as specified in issue #24, adding comprehensive testing capabilities and linting configuration to the Slack MCP project.

Changes Made

1. Development Dependencies

  • Added [project.optional-dependencies] section to pyproject.toml
  • Included all required tools: pytest, pytest-asyncio, pytest-cov, flake8, mypy, black, isort

2. Tool Configuration

  • Added comprehensive tool settings in pyproject.toml for:
    • black (line-length: 120)
    • isort (profile: black, line-length: 120)
    • mypy (Python 3.12, ignore missing imports)
    • pytest (test paths, async mode)
    • coverage (source paths, exclusions)
  • Created .flake8 configuration file with max-line-length: 120 and appropriate ignores

3. Test Infrastructure

  • Created tests/ directory with proper structure
  • Added conftest.py with comprehensive fixtures:
    • Mock Slack clients (sync and async)
    • Sample API responses for channels, users, and messages
    • Mock MCP server instance
  • Created unit test files for all 4 tool modules:
    • test_core.py - Tests for 7 core tools
    • test_message_management.py - Tests for 8 message tools
    • test_channel_management.py - Tests for 9 channel tools
    • test_user_management.py - Tests for 4 user tools
  • Added test_utils.py for utility function tests
  • Added test_integration.py for integration test framework

4. GitHub Actions CI/CD

  • Created .github/workflows/test.yml with:
    • Python 3.12 test matrix
    • Pip caching for faster builds
    • Test execution with coverage reporting
    • Non-blocking linting checks (flake8, mypy, black, isort)
    • PR comment integration for linting results

5. Gitignore Updates

  • Added missing Python patterns: *.pyc, .mypy_cache/
  • Already had coverage and pytest cache patterns

Verification

  • Tool count confirmed: 28 tools (7 + 8 + 9 + 4)
  • All linters configured in check-only/notify-only mode
  • Tests are discoverable by pytest
  • GitHub Actions workflow has valid YAML syntax
  • File operations references removed (as per codebase changes)

Testing

To run the tests locally:

pip install -e ".[dev]"
pytest tests/

To run linters (informational only):

flake8 src/
mypy src/
black --check src/
isort --check-only src/

Notes

  • All linting is intentionally non-blocking to allow gradual code quality improvements
  • Tests focus on mocking Slack API calls to avoid requiring real tokens
  • Integration test framework is ready for future expansion

Closes #24

- Add development dependencies to pyproject.toml (pytest, flake8, mypy, black, isort)
- Configure tool settings in pyproject.toml for all linters
- Create .flake8 configuration file with appropriate settings
- Add comprehensive test structure with fixtures in conftest.py
- Add unit tests for all 4 tool modules (core, message, channel, user)
- Add utility tests and integration test framework
- Create GitHub Actions workflow for CI/CD with non-blocking linting
- Update .gitignore with missing Python patterns (*.pyc, .mypy_cache/)
- Configure all linters in notify-only mode as requested
- Total of 28 tools confirmed in repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Test Infrastructure Post Refactoring

1 participant