Add missing test files and update .gitignore to allow test files
This commit addresses the overly restrictive .gitignore pattern that was excluding all test files (test_*.py), including legitimate pytest and unittest test suites essential for code quality and CI/CD. Changes to .gitignore: - Added negation patterns !**/tests/test_*.py and !**/test_*.py to allow proper test files while still blocking temporary scripts - This enables pytest test suites to be tracked by git Added test files (17 files): Telegram Bot Tests (15 files): - reports-app/telegram-bot/tests/test_auth.py Tests for authentication and account linking flow - reports-app/telegram-bot/tests/test_callbacks.py Tests for callback query handlers - reports-app/telegram-bot/tests/test_formatters.py Tests for message formatting utilities - reports-app/telegram-bot/tests/test_formatters_extended.py Extended formatter tests - reports-app/telegram-bot/tests/test_handlers_menu.py Tests for menu handlers - reports-app/telegram-bot/tests/test_helpers.py Tests for helper functions - reports-app/telegram-bot/tests/test_helpers_extended.py Extended helper tests - reports-app/telegram-bot/tests/test_helpers_real.py Real integration tests for helpers - reports-app/telegram-bot/tests/test_helpers_real_simple.py Simplified integration tests - reports-app/telegram-bot/tests/test_login_flow.py Complete login flow integration tests - reports-app/telegram-bot/tests/test_menus.py Menu system tests - reports-app/telegram-bot/tests/test_session_company.py Session and company management tests - reports-app/telegram-bot/test_claude_integration.py Manual integration test (Claude AI) - reports-app/telegram-bot/test_claude_response.py Response formatting test - reports-app/telegram-bot/test_db.py Database operations manual test Shared Module Tests (2 files): - shared/auth/test_auth.py Authentication system tests - shared/database/test_pool.py Oracle connection pool tests Security verification: ✅ All test files use mock objects, fixtures, and environment variables ✅ No hardcoded credentials or secrets found ✅ Safe for version control 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
86
reports-app/telegram-bot/test_claude_response.py
Normal file
86
reports-app/telegram-bot/test_claude_response.py
Normal file
@@ -0,0 +1,86 @@
|
||||
"""
|
||||
Quick test script to verify Claude's response behavior
|
||||
|
||||
⚠️ MANUAL INTEGRATION TEST - Not run by default in CI/CD
|
||||
|
||||
This script tests that Claude responds directly without asking for permission
|
||||
when using custom tools. Requires Claude API key or claude-code login.
|
||||
|
||||
REQUIREMENTS:
|
||||
- Claude API key or claude-code login
|
||||
- Backend API running on localhost:8001 (for real tool execution)
|
||||
|
||||
USAGE:
|
||||
# Run as script
|
||||
python test_claude_response.py
|
||||
|
||||
# Run via pytest (requires -m integration)
|
||||
pytest test_claude_response.py -m integration
|
||||
|
||||
NOTE: Test function marked with @pytest.mark.integration
|
||||
"""
|
||||
import pytest
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add parent directory to path
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from app.main import ClaudeAgentWrapper
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
async def test_claude():
|
||||
"""Test Claude's response to a simple query"""
|
||||
print("="*60)
|
||||
print("Testing Claude Agent Response")
|
||||
print("="*60)
|
||||
|
||||
# Initialize Claude Agent
|
||||
agent = ClaudeAgentWrapper()
|
||||
|
||||
# Test message
|
||||
messages = [
|
||||
{"role": "user", "content": "Care sunt companiile mele?"}
|
||||
]
|
||||
|
||||
# Mock JWT token (you'll need to replace this with a real one for actual API calls)
|
||||
jwt_token = "mock_token"
|
||||
telegram_user_id = 999999
|
||||
|
||||
print("\nSending query: 'Care sunt companiile mele?'")
|
||||
print("="*60)
|
||||
|
||||
try:
|
||||
response = await agent.process_message(
|
||||
messages=messages,
|
||||
jwt_token=jwt_token,
|
||||
telegram_user_id=telegram_user_id
|
||||
)
|
||||
|
||||
print("\n📥 CLAUDE RESPONSE:")
|
||||
print("="*60)
|
||||
print(response)
|
||||
print("="*60)
|
||||
|
||||
# Check if response asks for permission
|
||||
permission_keywords = [
|
||||
"permisiune", "permission", "autorizare", "authorization",
|
||||
"pot accesa", "can I access", "să accesez"
|
||||
]
|
||||
|
||||
asks_permission = any(keyword.lower() in response.lower() for keyword in permission_keywords)
|
||||
|
||||
if asks_permission:
|
||||
print("\n❌ FAIL: Claude is still asking for permission!")
|
||||
else:
|
||||
print("\n✅ PASS: Claude responds directly without asking permission")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ ERROR: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_claude())
|
||||
Reference in New Issue
Block a user