make_post_sell/test_requests_lib.py
Russell Ballestrini 4fbe9fedd4 Apply black code formatting
Formatted Python code using black for:
- crypto_clients.py
- crypto_watcher.py
- test_crypto_watcher.py

Maintains consistent code style across the codebase.
2025-09-23 10:49:26 -04:00

37 lines
No EOL
1.3 KiB
Python

#!/usr/bin/env python3
"""
Test if the requests library works better than urllib for Digest auth.
If requests works, we can see what it does differently.
"""
try:
import requests
from requests.auth import HTTPDigestAuth
def test_with_requests():
print("=== Testing with requests library ===")
url = "http://127.0.0.1:18083/json_rpc"
payload = {"jsonrpc": "2.0", "id": 1, "method": "get_height"}
auth = HTTPDigestAuth("test_user", "test_pass")
try:
response = requests.post(url, json=payload, auth=auth, timeout=15)
if response.status_code == 200:
result = response.json()
print(f"✓ requests SUCCESS: {result}")
return True
else:
print(f"✗ requests FAILED: {response.status_code} {response.reason}")
print(f"Response: {response.text}")
return False
except Exception as e:
print(f"✗ requests ERROR: {e}")
return False
if __name__ == "__main__":
test_with_requests()
except ImportError:
print("requests library not installed. Install with: pip install requests")
print("This would help us compare urllib vs requests for Digest auth.")