test
This commit is contained in:
108
TESTING-GUIDE.md
Normal file
108
TESTING-GUIDE.md
Normal file
@@ -0,0 +1,108 @@
|
||||
# Testing Guide for API Response Utilities
|
||||
|
||||
This guide helps you test the new unified response format utilities before merging the PR.
|
||||
|
||||
## Quick Test Script
|
||||
|
||||
Run the simple test script to verify basic functionality:
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
python test_response_utilities.py
|
||||
```
|
||||
|
||||
This will test:
|
||||
- ✅ Import functionality
|
||||
- ✅ `success_response()` function
|
||||
- ✅ `error_response()` function
|
||||
- ✅ `paginated_response()` function
|
||||
|
||||
## Django Unit Tests
|
||||
|
||||
Run the comprehensive unit tests:
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
python manage.py test igny8_core.api.tests.test_response
|
||||
```
|
||||
|
||||
Expected output: All 15 test cases should pass.
|
||||
|
||||
## Test the /api/ping/ Endpoint
|
||||
|
||||
### Option 1: Using curl (if server is running)
|
||||
|
||||
```bash
|
||||
# Test the ping endpoint
|
||||
curl http://localhost:8011/api/ping/
|
||||
|
||||
# Expected response:
|
||||
# {
|
||||
# "success": true,
|
||||
# "data": {
|
||||
# "pong": true,
|
||||
# "time": "2025-01-XX...",
|
||||
# "version": "1.0.0"
|
||||
# },
|
||||
# "message": "API is live"
|
||||
# }
|
||||
```
|
||||
|
||||
### Option 2: Using Postman or Browser
|
||||
|
||||
1. Start Django server: `python manage.py runserver`
|
||||
2. Navigate to: `http://localhost:8000/api/ping/`
|
||||
3. Verify response has `success: true` and `data` fields
|
||||
|
||||
### Option 3: Using Python requests
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
response = requests.get('http://localhost:8011/api/ping/')
|
||||
data = response.json()
|
||||
|
||||
assert data['success'] == True
|
||||
assert 'data' in data
|
||||
assert 'pong' in data['data']
|
||||
print("✅ Ping endpoint works!")
|
||||
```
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
Before merging the PR, verify:
|
||||
|
||||
- [ ] Quick test script passes (`python test_response_utilities.py`)
|
||||
- [ ] Django unit tests pass (`python manage.py test igny8_core.api.tests.test_response`)
|
||||
- [ ] `/api/ping/` endpoint returns unified format
|
||||
- [ ] No linting errors
|
||||
- [ ] All imports work correctly
|
||||
|
||||
## What to Look For
|
||||
|
||||
### ✅ Success Indicators:
|
||||
- All tests pass
|
||||
- Response has `success: true/false` field
|
||||
- Response has `data` field (for success) or `error` field (for errors)
|
||||
- No import errors
|
||||
- No syntax errors
|
||||
|
||||
### ❌ Failure Indicators:
|
||||
- Import errors
|
||||
- Assertion errors in tests
|
||||
- Missing fields in responses
|
||||
- Syntax errors
|
||||
|
||||
## Next Steps After Testing
|
||||
|
||||
If all tests pass:
|
||||
1. ✅ Merge the PR
|
||||
2. Continue with Section 1, Task 2 (refactoring endpoints)
|
||||
3. Or move to Section 2 (Authentication)
|
||||
|
||||
If tests fail:
|
||||
1. Check error messages
|
||||
2. Fix any issues
|
||||
3. Re-test
|
||||
4. Update PR with fixes
|
||||
|
||||
Reference in New Issue
Block a user