agentleFS
skywinderskywinder/osm-edit-mcp/.cursor/rules/testing-and-quality.mdc

osm-edit-mcp / rules

Cursor rule4 starsChanged 3 months agoMITView on GitHub

  • Reads credentials

The file

Show its rules and text

We split this testing-and-quality.mdc into the rules it gives an agent

35 rules. About 0 are common, 30 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈30

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Follow TESTING_CHECKLIST.md for systematic manual validation:

    line 26
  2. Distinctive:

    Automated Testing: Run comprehensive test suite

    line 30
  3. Distinctive:

    Test dev/prod switching in .env:

    line 52
  4. Distinctive:

    Verify log levels in .env:

    line 64
  5. Very specific:

    Use known good IDs that exist on api06.dev.openstreetmap.org:

    line 75
  6. Distinctive:

    Use valid, safe test coordinates:

    line 81
  7. Distinctive:

    Test with appropriately sized bounding boxes:

    line 87
  8. Distinctive:

    All errors should return structured responses:

    line 114
  9. Distinctive:

    Never log OAuth tokens or secrets

    line 145
  10. Distinctive:

    Verify .env is not committed to version control

    line 146
  11. Distinctive:

    Test with invalid credentials (should fail gracefully)

    line 147
  12. Very specific:

    Verify keyring usage when USE_KEYRING=true

    line 148
  13. Distinctive:

    Test with malicious coordinate values

    line 151
  14. Distinctive:

    Test with oversized input data

    line 152
  15. Distinctive:

    Test with special characters in tags

    line 153
  16. Distinctive:

    Verify SQL injection protection

    line 154
  17. Distinctive:

    Verify HTTPS usage for all API calls

    line 158
  18. Distinctive:

    Check that sensitive data isn't logged

    line 159
  19. Distinctive:

    Test with malformed API responses

    line 160
  20. Distinctive:

    Document baseline success rate

    line 166
  21. Distinctive:

    Update test expectations if needed

    line 173
  22. Distinctive:

    Test dev/prod configuration switching

    line 177
  23. Distinctive:

    Verify all safety features enabled

    line 178
  24. Distinctive:

    Test OAuth flow if configured

    line 179
  25. Distinctive:

    Start: Run baseline tests

    line 207
  26. Very specific:

    Test: Add test case to test_comprehensive.py

    line 209
  27. Distinctive:

    Validate: Run full test suite

    line 210
  28. Distinctive:

    Document: Update README.md if needed

    line 211
  29. Distinctive:

    Reproduce: Use tests to confirm bug

    line 214
  30. Distinctive:

    Regression: Run full test suite

    line 217
  31. Distinctive:

    Document: Update test expectations

    line 218
  32. Very specific:

    Change: Update .env or server.py

    line 222
  33. Distinctive:

    Validate: Test new configuration

    line 223
  34. Distinctive:

    Document: Update README.md with new options

    line 224
  35. Distinctive:

    Compatibility: Ensure backward compatibility

    line 225

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
testing-and-quality.mdc
---
description:
globs:
alwaysApply: false
---
# Testing and Quality Assurance Guide

## Comprehensive Testing Framework

### Automated Testing with test_comprehensive.py
The [test_comprehensive.py](mcp:test_comprehensive.py) provides systematic testing of all 31 MCP tools:

```bash
# Run full test suite
python test_comprehensive.py

# Expected output: JSON report, logs, and console summary
```

#### Test Categories
1. **Read Operations (Tests 1-15)**: Safe operations that should mostly pass
2. **Write Operations (Tests 16-27)**: OAuth-protected, expected to fail without auth
3. **Natural Language (Tests 28-31)**: Input validation and processing

### Manual Testing with TESTING_CHECKLIST.md
Follow [TESTING_CHECKLIST.md](mcp:TESTING_CHECKLIST.md) for systematic manual validation:

#### Testing Phases
1. **Pre-test Setup**: Configuration verification
2. **Automated Testing**: Run comprehensive test suite
3. **Manual Testing**: Phase-by-phase validation
4. **Configuration Testing**: Dev/prod switching
5. **Error Handling**: Edge cases and failures
6. **Performance Testing**: Response times and memory
7. **Security Testing**: Credential handling and validation

### Test Results Analysis
Review [TEST_RESULTS_SUMMARY.md](mcp:TEST_RESULTS_SUMMARY.md) for:
- ✅ **Working tools** (ready for use)
- ❌ **Expected failures** (OAuth-dependent, normal)
- 🔧 **Issues to debug** (actual problems requiring fixes)

## Quality Standards

### Test Success Criteria
- **Read operations**: ≥80% success rate
- **Write operations**: Expected 401/auth failures
- **Validation tools**: 100% success rate
- **Error handling**: Graceful failures with informative messages

### Configuration Testing
Test dev/prod switching in [.env](mcp:.env):
```bash
# Test development mode
OSM_USE_DEV_API=true
python -c "from src.osm_edit_mcp.server import config; print(config.current_api_base_url)"

# Test production mode (careful!)
OSM_USE_DEV_API=false
python -c "from src.osm_edit_mcp.server import config; print(config.current_api_base_url)"
```

### Logging Level Testing
Verify log levels in [.env](mcp:.env):
```bash
LOG_LEVEL=DEBUG   # Should show detailed debug info
LOG_LEVEL=INFO    # Should show operation info
LOG_LEVEL=WARNING # Should show only warnings/errors
LOG_LEVEL=ERROR   # Should show only errors
```

## Test Data Management

### Valid Test Data for Dev Server
Use known good IDs that exist on `api06.dev.openstreetmap.org`:
- **Node**: 150537 (working in tests)
- **Way**: Need to find valid dev server way ID
- **Relation**: Need to find valid dev server relation ID

### Test Coordinates
Use valid, safe test coordinates:
- **London**: 51.5074, -0.1278 (working)
- **New York**: 40.7580, -73.9855 (working)
- **Paris**: 48.8566, 2.3522 (alternative)

### Bounding Box Testing
Test with appropriately sized bounding boxes:
```bash
# Small area (working for some operations)
"-0.1279,-0.1278,51.5074,51.5075"

# Larger area (may work better for dev server)
"-0.13,-0.12,51.50,51.51"
```

## Error Handling Quality

### Expected Error Patterns
Tools should handle these error types gracefully:

#### HTTP Errors
- **401 Unauthorized**: OAuth required (expected for write operations)
- **404 Not Found**: Element doesn't exist (handle gracefully)
- **400 Bad Request**: Invalid parameters (informative error)
- **429 Rate Limited**: Too many requests (retry logic)

#### Input Validation Errors
- Invalid coordinates (lat/lon out of range)
- Missing required parameters
- Malformed data structures
- Invalid OSM element references

### Error Response Quality
All errors should return structured responses:
```python
{
    "success": False,
    "error": "Technical error details for debugging",
    "message": "Human-readable explanation for users"
}
```

## Performance Standards

### Response Time Expectations
- **Simple operations**: < 1 second
- **Complex searches**: < 5 seconds
- **Large data exports**: < 30 seconds
- **Authentication**: < 2 seconds

### Memory Usage
- **Base server**: < 100MB
- **During testing**: < 500MB
- **Large operations**: < 1GB

### API Rate Limiting
Respect OSM API limits configured in [.env](mcp:.env):
- `RATE_LIMIT_PER_MINUTE=60`
- `MAX_CHANGESET_SIZE=50`
- Handle 429 responses gracefully

## Security Testing

### Credential Security
- Never log OAuth tokens or secrets
- Verify [.env](mcp:.env) is not committed to version control
- Test with invalid credentials (should fail gracefully)
- Verify keyring usage when `USE_KEYRING=true`

### Input Sanitization
- Test with malicious coordinate values
- Test with oversized input data
- Test with special characters in tags
- Verify SQL injection protection

### API Security
- Test parameter tampering
- Verify HTTPS usage for all API calls
- Check that sensitive data isn't logged
- Test with malformed API responses

## Continuous Quality Assurance

### Before Code Changes
1. Run [test_comprehensive.py](mcp:test_comprehensive.py)
2. Document baseline success rate
3. Note any failing tests

### After Code Changes
1. Re-run [test_comprehensive.py](mcp:test_comprehensive.py)
2. Compare results with baseline
3. Investigate any new failures
4. Update test expectations if needed

### Before Deployment
1. Complete [TESTING_CHECKLIST.md](mcp:TESTING_CHECKLIST.md)
2. Test dev/prod configuration switching
3. Verify all safety features enabled
4. Test OAuth flow if configured
5. Performance test with realistic data

## Test Result Documentation

### Generated Test Reports
- **test_report.json**: Detailed JSON with all test results
- **test_results.log**: Comprehensive execution logs
- **Console output**: Summary with pass/fail status

### Tracking Test Health
Monitor these metrics over time:
- Overall success rate (target: maintain or improve)
- Response times (target: stable or decreasing)
- Error rates by category
- New tool test coverage

### Issue Tracking
For failed tests, document:
- Error type and frequency
- Steps to reproduce
- Potential fixes
- Workarounds available
- Impact on functionality

## Development Testing Workflow

### Feature Development
1. **Start**: Run baseline tests
2. **Develop**: Implement new feature following patterns in [server.py](mcp:src/osm_edit_mcp/server.py)
3. **Test**: Add test case to [test_comprehensive.py](mcp:test_comprehensive.py)
4. **Validate**: Run full test suite
5. **Document**: Update [README.md](mcp:README.md) if needed

### Bug Fixes
1. **Reproduce**: Use tests to confirm bug
2. **Fix**: Implement solution
3. **Verify**: Confirm fix with tests
4. **Regression**: Run full test suite
5. **Document**: Update test expectations

### Configuration Changes
1. **Test current**: Baseline with existing config
2. **Change**: Update [.env](mcp:.env) or [server.py](mcp:src/osm_edit_mcp/server.py)
3. **Validate**: Test new configuration
4. **Document**: Update [README.md](mcp:README.md) with new options
5. **Compatibility**: Ensure backward compatibility

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.