Files
crossfit/tools/test_telegram_notifier.py
kbe a7f9e6bacd Fixed failing tests in test_crossfit_booker_sessions.py
Fixed test_run_auth_failure by patching the correct method (CrossFitBooker.login) and calling the correct method (booker.login())
Fixed test_run_booking_outside_window by patching the correct method (Booker.run) and adding the necessary mocking for the booking cycle
Added proper mocking for auth_token and user_id to avoid authentication errors in the tests
Updated imports to use the src prefix for all imports
Added proper test structure for the booking window logic test
All tests now pass successfully
2025-08-12 01:38:50 +02:00

51 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Test script to manually test the Telegram notifier functionality.
This script sends a test message using the SessionNotifier class.
"""
import os
import logging
from dotenv import load_dotenv
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from src.session_notifier import SessionNotifier
# Load environment variables from .env file
load_dotenv()
# Configure logging
logging.basicConfig(level=logging.DEBUG)
def main():
"""
Main function to test the Telegram notifier.
"""
# Get Telegram credentials from environment variables
telegram_credentials = {
"token": os.getenv("TELEGRAM_TOKEN"),
"chat_id": os.getenv("TELEGRAM_CHAT_ID")
}
# Create a SessionNotifier instance with only Telegram enabled
notifier = SessionNotifier(
email_credentials={},
telegram_credentials=telegram_credentials,
enable_email=False,
enable_telegram=True
)
# Test message
test_message = "This is a test message from the Telegram notifier test script."
# Send the test message
try:
import asyncio
asyncio.run(notifier.send_telegram_notification(test_message))
print("Test message sent successfully!")
except Exception as e:
print(f"Failed to send test message: {str(e)}")
if __name__ == "__main__":
main()