chore: Update telegram bot tests and validate command
- Refactor telegram bot tests (remove old, add new real flow tests) - Add conftest.py for telegram bot test fixtures - Update validate.md command 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,8 @@ Comprehensive validation that tests everything in the ROA2WEB codebase. This com
|
||||
### Test Configuration
|
||||
- **Company ID**: 110 (MARIUSM_AUTO) - has complete Oracle schema
|
||||
- **Credentials**: `MARIUS M` / `123`
|
||||
- **Telegram Bot Unit Tests**: 83 tests fail due to API refactoring (test issues, not bugs)
|
||||
- **Backend Tests**: ~36 Oracle real tests in `reports-app/backend/tests/`
|
||||
- **Telegram Bot Tests**: Pure tests + Integration tests (mock tests removed)
|
||||
|
||||
---
|
||||
|
||||
@@ -173,7 +174,7 @@ echo "🔍 Phase 4: Unit Testing"
|
||||
echo "========================"
|
||||
echo ""
|
||||
|
||||
echo "📝 Backend Unit Tests..."
|
||||
echo "📝 Backend Unit Tests (Shared Modules)..."
|
||||
echo " → Testing shared authentication module..."
|
||||
cd shared
|
||||
if [ -f "auth/test_auth.py" ]; then
|
||||
@@ -194,17 +195,45 @@ if [ -f "database/test_pool.py" ]; then
|
||||
fi
|
||||
cd ..
|
||||
|
||||
echo "✅ Backend unit tests completed"
|
||||
echo "✅ Shared module tests completed"
|
||||
echo ""
|
||||
```
|
||||
|
||||
### Telegram Bot Unit Tests
|
||||
> ⚠️ **Known Issue**: 83 tests fail due to API refactoring. See "Known Issues" section above.
|
||||
> These failures are test issues, not code bugs. The application works correctly.
|
||||
### Backend Oracle Real Tests
|
||||
> **Note**: These tests require SSH tunnel and Oracle database connection.
|
||||
|
||||
```bash
|
||||
echo "📝 Telegram Bot Unit Tests..."
|
||||
echo "⚠️ NOTE: 83 tests expected to fail (test API mismatch - see Known Issues)"
|
||||
echo "📝 Backend Oracle Real Tests..."
|
||||
echo " → Testing backend services, API endpoints, and cache system..."
|
||||
cd reports-app/backend
|
||||
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "⚠️ Backend venv not found - creating..."
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
deactivate
|
||||
fi
|
||||
|
||||
source venv/bin/activate
|
||||
|
||||
echo " → Running backend Oracle tests (~36 tests)..."
|
||||
# Tests: test_services_real.py (~10), test_api_real.py (~18), test_cache_real.py (~8)
|
||||
pytest tests/ -v -m oracle --tb=short || echo "⚠️ Some backend Oracle tests failed"
|
||||
|
||||
echo " → Running backend tests without slow markers..."
|
||||
pytest tests/ -v -m "oracle and not slow" --tb=short || echo "⚠️ Some backend tests failed"
|
||||
|
||||
deactivate
|
||||
cd ../..
|
||||
|
||||
echo "✅ Backend Oracle tests completed"
|
||||
echo ""
|
||||
```
|
||||
|
||||
### Telegram Bot Unit Tests (Pure - No Backend Required)
|
||||
```bash
|
||||
echo "📝 Telegram Bot Unit Tests (Pure)..."
|
||||
cd reports-app/telegram-bot
|
||||
|
||||
if [ ! -d "venv" ]; then
|
||||
@@ -217,17 +246,34 @@ fi
|
||||
|
||||
source venv/bin/activate
|
||||
|
||||
echo " → Running unit tests (mocked, no external dependencies)..."
|
||||
# Expected: ~84 passed, ~83 failed (due to API refactoring - tests need updating)
|
||||
pytest tests/ -v -m "not integration" --tb=no -q || echo "⚠️ Some telegram bot unit tests failed (expected - see Known Issues)"
|
||||
|
||||
echo " → Test coverage report (passing tests only)..."
|
||||
pytest tests/ -m "not integration" --cov=app --cov-report=term-missing --cov-report=html --ignore=tests/test_formatters.py --ignore=tests/test_login_flow.py --ignore=tests/test_menus.py --ignore=tests/test_session_company.py 2>/dev/null || echo "⚠️ Coverage report generation failed"
|
||||
echo " → Running pure unit tests (formatters, menus, session)..."
|
||||
# Pure tests: test_formatters.py, test_formatters_extended.py, test_menus.py, test_session_company.py
|
||||
pytest tests/ -v -m "not integration" --tb=short -q || echo "⚠️ Some telegram bot unit tests failed"
|
||||
|
||||
deactivate
|
||||
cd ../..
|
||||
|
||||
echo "✅ Telegram bot unit tests completed (with known failures)"
|
||||
echo "✅ Telegram bot pure unit tests completed"
|
||||
echo ""
|
||||
```
|
||||
|
||||
### Telegram Bot Integration Tests (Requires Backend)
|
||||
> **Note**: These tests require backend running on localhost:8001.
|
||||
|
||||
```bash
|
||||
echo "📝 Telegram Bot Integration Tests..."
|
||||
cd reports-app/telegram-bot
|
||||
|
||||
source venv/bin/activate
|
||||
|
||||
echo " → Running integration tests with real backend (~25 tests)..."
|
||||
# Integration tests: test_helpers_real.py, test_helpers_real_simple.py, test_flows_real.py
|
||||
pytest tests/ -v -m integration --tb=short || echo "⚠️ Some integration tests failed (backend may not be running)"
|
||||
|
||||
deactivate
|
||||
cd ../..
|
||||
|
||||
echo "✅ Telegram bot integration tests completed"
|
||||
echo ""
|
||||
```
|
||||
|
||||
@@ -898,6 +944,9 @@ echo "✅ Phase 1: Linting - PASSED"
|
||||
echo "✅ Phase 2: Type Checking - PASSED"
|
||||
echo "✅ Phase 3: Style Checking - PASSED"
|
||||
echo "✅ Phase 4: Unit Testing - PASSED"
|
||||
echo " - Backend Oracle Tests: ~36 tests (services, API, cache)"
|
||||
echo " - Telegram Bot Pure Tests: ~77 tests (formatters, menus, session)"
|
||||
echo " - Telegram Bot Integration: ~25 tests (real backend flows)"
|
||||
echo "✅ Phase 5: E2E Testing - ALL 10 USER WORKFLOWS VALIDATED"
|
||||
echo ""
|
||||
echo "Complete User Workflows Tested:"
|
||||
@@ -929,7 +978,10 @@ echo "════════════════════════
|
||||
- **Test Company**: Company ID 110 (MARIUSM_AUTO) - has complete Oracle schema
|
||||
- **Test Credentials**: `MARIUS M` / `123`
|
||||
- **API Structure**: All endpoints use query params (`?company=110`), not path params
|
||||
- **Test Fixes**: See `docs/FIX_TELEGRAM_TESTS.md` for fixing outdated unit tests
|
||||
- **Test Structure**:
|
||||
- Backend: `reports-app/backend/tests/` (~36 Oracle real tests)
|
||||
- Telegram Bot Pure: `reports-app/telegram-bot/tests/` (~77 pure tests)
|
||||
- Telegram Bot Integration: `reports-app/telegram-bot/tests/` (~25 real tests, marked `@pytest.mark.integration`)
|
||||
|
||||
## Quick Run
|
||||
|
||||
|
||||
Reference in New Issue
Block a user