This proposal adds comprehensive pytest testing for all existing features: - Unit tests for validation logic - Integration tests for database operations and GraphQL resolvers - E2E tests for complete API flows - MCP server tests for all 6 tools 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4.1 KiB
4.1 KiB
Implementation Tasks: add-pytest-tests
1. Test Infrastructure Setup
- Create
tests/directory structuretests/unit/for pure logic teststests/integration/for database and resolver teststests/e2e/for full API teststests/mcp/for MCP server tests
- Create
tests/conftest.pywith shared fixtures- Database fixture (in-memory SQLite)
- Async session fixture
- Test client fixture for FastAPI/GraphQL
- Create
tests/__init__.py
2. Unit Tests
tests/unit/test_validation.py- Test
validate_first_name()with valid input - Test
validate_first_name()with empty string - Test
validate_first_name()with whitespace only - Test
validate_email()with valid emails - Test
validate_email()with invalid emails - Test
validate_email()with None (should pass) - Test
validate_email()with empty string (should pass) - Test
validate_phone()with valid E.164 numbers - Test
validate_phone()with invalid numbers - Test
validate_phone()with None (should pass) - Test
validate_phone()with empty string (should pass)
- Test
3. Integration Tests - Database
tests/integration/test_member_model.py- Test creating member with minimal data (firstName only)
- Test creating member with complete data
- Test member timestamps (created_at, updated_at)
- Test member repr
4. Integration Tests - GraphQL Resolvers
-
tests/integration/test_member_queries.py- Test
member(id)query with existing member - Test
member(id)query with non-existent ID (returns None) - Test
membersquery with multiple members - Test
membersquery returns empty array when no members - Test
memberssorting (last name nulls last, then first name)
- Test
-
tests/integration/test_member_mutations.py- Test
createMemberwith minimal data (firstName only) - Test
createMemberwith complete data - Test
createMemberwith invalid email (validation error) - Test
createMemberwith invalid phone (validation error) - Test
createMemberwith empty firstName (validation error) - Test
updateMembersuccessfully updates fields - Test
updateMemberwith non-existent ID (MemberNotFoundError) - Test
updateMemberwith partial data (only updates provided fields) - Test
updateMemberwith invalid email (validation error) - Test
deleteMembersuccessfully deletes member - Test
deleteMemberwith non-existent ID (MemberNotFoundError)
- Test
5. E2E Tests - GraphQL API
tests/e2e/test_graphql_api.py- Test complete query flow (list members via HTTP)
- Test complete mutation flow (create member via HTTP)
- Test GraphQL introspection query (__schema)
- Test GraphQL type introspection (__type)
- Test error responses (400 for validation errors)
6. MCP Server Tests
tests/mcp/test_mcp_server.py- Test MCP server initialization
- Test
list_tools()returns 6 tools - Test
list_memberstool execution - Test
get_membertool execution - Test
get_memberwith non-existent ID - Test
create_membertool execution - Test
update_membertool execution - Test
get_graphql_schematool execution - Test
execute_graphql_querytool with simple query - Test
execute_graphql_querytool with variables - Test error handling when API is unavailable
7. Documentation
- Update README.md
- Add "Running Tests" section
- Add test command examples
- Add "Test Organization" section
- Document test coverage goals
8. Validation
- Run
uv run pytestand verify all tests pass - Run
uv run pytest --verbosefor detailed output - Run
uv run pytest tests/unitto test unit tests - Run
uv run pytest tests/integrationto test integration tests - Run
uv run pytest tests/e2eto test e2e tests - Run
uv run pytest tests/mcpto test MCP tests - Verify no changes to production code (except bug fixes if found)
- Run
openspec validate add-pytest-tests --strict