Files
media-downloader/tests/test_pushover.py
Todd 0d7b2b1aab Initial commit
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 22:42:55 -04:00

93 lines
2.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Test Pushover Notifications
Sends a test notification to verify credentials and setup
"""
import sys
import json
from pathlib import Path
from datetime import datetime
# Add modules to path
sys.path.insert(0, str(Path(__file__).parent))
sys.path.insert(0, str(Path(__file__).parent / 'modules'))
from modules.pushover_notifier import PushoverNotifier
def load_config():
"""Load configuration from settings.json"""
config_path = Path(__file__).parent / 'config' / 'settings.json'
with open(config_path, 'r') as f:
return json.load(f)
def main():
print("Testing Pushover Notifications...")
print("-" * 50)
# Load config
config = load_config()
pushover_config = config.get('pushover', {})
# Check if enabled
if not pushover_config.get('enabled'):
print("❌ Pushover is disabled in config")
print(" Set 'enabled': true in config/settings.json")
return 1
# Check credentials
user_key = pushover_config.get('user_key')
api_token = pushover_config.get('api_token')
if not user_key or not api_token:
print("❌ Missing Pushover credentials")
print(" Add 'user_key' and 'api_token' to config/settings.json")
return 1
print(f"✓ Pushover enabled")
print(f"✓ User key: {user_key[:10]}...")
print(f"✓ API token: {api_token[:10]}...")
print()
# Create notifier
notifier = PushoverNotifier(
user_key=user_key,
api_token=api_token,
enabled=True,
default_priority=pushover_config.get('priority', 0),
device=pushover_config.get('device')
)
# Send test notification
print("Sending test notification...")
success = notifier.notify_download(
platform='instagram',
source='evalongoria',
content_type='story',
filename='test_story_20251019.mp4',
count=3,
metadata={'post_date': datetime.now()}
)
if success:
print("✅ Test notification sent successfully!")
print()
print("Check your Pushover app for the notification.")
print()
print("Stats:", notifier.get_stats())
return 0
else:
print("❌ Failed to send notification")
print()
print("Stats:", notifier.get_stats())
print()
print("Possible issues:")
print(" - Invalid user_key or api_token")
print(" - No internet connection")
print(" - Pushover service down")
return 1
if __name__ == '__main__':
sys.exit(main())