File size: 1,419 Bytes
78e01dd
 
 
 
 
 
 
 
 
 
b9da630
 
78e01dd
 
 
 
 
 
 
 
 
 
 
 
 
 
b9da630
 
 
78e01dd
b9da630
78e01dd
b9da630
78e01dd
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import sys
from pathlib import Path

# Add project root to path
project_root = Path(__file__).parent
sys.path.append(str(project_root))

from core.redis_client import redis_client

def test_hardcoded_connection():
    """Test Redis connection with new hardcoded configuration"""
    print("Testing Redis connection with new hardcoded configuration...")
    
    # Test the actual client being used
    print("\nTesting application Redis client...")
    client = redis_client.get_client()
    
    if client is None:
        print("❌ Application Redis client is None")
        return 1
    
    try:
        client.ping()
        print("βœ… Application Redis client ping successful")
        
        # Test set/get operations
        client.set('new_database_test_key', 'new_database_test_value')
        value = client.get('new_database_test_key')
        client.delete('new_database_test_key')  # Cleanup
        
        if value == 'new_database_test_value':
            print("βœ… Set/Get operations work correctly")
            print("\nπŸŽ‰ New Redis database connection test passed!")
            return 0
        else:
            print("❌ Set/Get operations failed")
            return 1
            
    except Exception as e:
        print(f"❌ Application Redis client test failed: {e}")
        return 1

if __name__ == "__main__":
    exit_code = test_hardcoded_connection()
    sys.exit(exit_code)