Status: Active Last Updated: August 28, 2025 Scope: Command Line Interface testing patterns and Notion CLI validation
This document provides comprehensive testing guidance for Piper Morgan’s CLI interfaces, with specific focus on the Notion integration CLI that was recently enhanced with full CRUD operations.
Context: Code inspection vs execution verification for integration success Solution: Require actual command execution for integration proof, not just import testing Benefit: Prevents false integration success claims, identifies initialization errors
Implementation:
# REQUIRED: Actual command execution
python cli/commands/notion.py status
# NOT SUFFICIENT: Import testing only
python -c "import cli.commands.notion; print('Import successful')"
Context: Integration features requiring verification of complete data lifecycle Solution: Implement comprehensive testing sequence covering Create, Read, Update, Delete operations
Implementation:
# Full CRUD cycle test for Notion CLI
python cli/commands/notion.py status # Verify connection
python cli/commands/notion.py pages # List existing pages
python cli/commands/notion.py search --query "test" # Search content
python cli/commands/notion.py create "Test Page" # Create new page
python cli/commands/notion.py search --query "Test Page" # Verify creation
| Command | Test Type | Status | Notes |
|---|---|---|---|
status |
Connection | ✅ | Validates API key and workspace access |
test |
Integration | ✅ | Tests live API connection |
search |
Read | ✅ | Validates search functionality |
pages |
Read | ✅ | Lists up to 20 pages with metadata |
create |
Write | ✅ | Creates pages with smart parent selection |
Objective: Verify Notion integration configuration and connectivity
# Test integration status
python cli/commands/notion.py status
# Expected output:
# ✅ Connected to Notion workspace
# 📊 Workspace: [Workspace Name]
# 🔑 API Key: Configured
# 🌐 Base URL: https://api.notion.com/v1
Failure Scenarios:
NOTION_API_KEY environment variableObjective: Validate search and listing functionality
# Test page listing
python cli/commands/notion.py pages
# Test search functionality
python cli/commands/notion.py search --query "project"
Success Criteria:
Objective: Validate page creation with proper error handling
# Test page creation with automatic parent selection
python cli/commands/notion.py create "Test Page $(date '+%I:%M %p')"
# Test page creation with specific parent
python cli/commands/notion.py create "Child Page" --parent-id "parent-id-here"
Success Criteria:
Test Cases:
Example Error Handling:
$ python cli/commands/notion.py status
❌ Notion API key not configured
💡 Please set NOTION_API_KEY environment variable
📖 See docs/features/notion-integration.md for setup instructions
Success Indicators:
Test Command Registration:
# Verify all commands are registered
python cli/commands/notion.py --help
# Expected output should include:
# status, test, search, pages, create
Test Argument Parsing:
# Test required arguments
python cli/commands/notion.py create
# Should show usage error
# Test optional arguments
python cli/commands/notion.py create "Title" --parent-id "valid-id"
# Should work correctly
Test Adapter Connection:
Test Configuration Integration:
Response Time Validation:
Resource Usage:
Pre-Test Setup:
Test Execution:
Post-Test Validation:
Unit Tests:
Integration Tests:
Performance Tests:
Import Errors:
ModuleNotFoundError: No module named 'notion_client'
Solution: Install required dependencies with pip install notion-client
Authentication Failures:
APIResponseError: 401 Unauthorized
Solution: Verify NOTION_API_KEY environment variable
Permission Errors:
APIResponseError: 403 Forbidden
Solution: Grant workspace access to your Notion integration
Network Timeouts:
TimeoutError: Request timed out
Solution: Check network connectivity and Notion API status
Enable Verbose Output:
# Add debug logging to CLI commands
export PYTHONPATH=.
python -m cli.commands.notion status --verbose
Check Adapter State:
# Interactive debugging
python -c "
from services.integrations.mcp.notion_adapter import NotionMCPAdapter
adapter = NotionMCPAdapter()
print(f'Adapter initialized: {adapter}')
print(f'Client configured: {hasattr(adapter, \"client\")}')
"