-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_test.py
More file actions
55 lines (41 loc) · 1.61 KB
/
Copy pathdebug_test.py
File metadata and controls
55 lines (41 loc) · 1.61 KB
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
47
48
49
50
51
52
53
54
55
"""
Debug test script to demonstrate verbose logging functionality
"""
import os
import sys
import logging
# Add src to path for local testing
sys.path.insert(0, 'src')
from eoddata import EODDataClient, EODDataError
def main():
"""Test the debug functionality"""
# Get API key from environment
api_key = os.getenv("EODDATA_API_KEY")
if not api_key:
print("Please set EODDATA_API_KEY environment variable")
print("You can do this by running: export EODDATA_API_KEY='your_api_key'")
return
print("Testing EODData client with debug mode enabled...")
print("=" * 60)
# Initialize client with debug mode
client = EODDataClient(api_key=api_key, debug=True)
try:
print("\n1. Testing metadata API (should work without authentication):")
exchange_types = client.metadata.exchange_types()
print(f"Retrieved {len(exchange_types)} exchange types")
print("\n2. Testing exchanges API:")
exchanges = client.exchanges.list()
print(f"Retrieved {len(exchanges)} exchanges")
print("\n3. Testing quotes API (this might fail if API key is invalid):")
try:
quote = client.quotes.get("NASDAQ", "AAPL")
print(f"Retrieved quote for AAPL: ${quote.get('close', 'N/A')}")
except EODDataError as e:
print(f"Quote API failed: {e}")
except EODDataError as e:
print(f"\nAPI Error occurred: {e}")
print("Check the debug logs above for more details about the failed requests")
except Exception as e:
print(f"\nUnexpected error: {e}")
if __name__ == "__main__":
main()