#!/usr/bin/env python3
"""Test script for execute_command function."""

import logging
import alexa_api

# Configure logging to see debug messages
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

# Replace these with your actual values
REFRESH_TOKEN = "Atnr|EwICIC9NE9meNY29gQXCwVdmHJHFSW00nNTzVx2n4pYOAr0yLKQmKepjQgVdwkxrw6SLi4P3cwo-WcyLQnXQklT-iz-Uvf7or4nUyWax3pUqMmIxbQ26xTHFlo8OF2RtUgrHXPvIKmeTAIktMsJs_IBuId-KxWB0UcCIlmVM1_gSEJxe0tJxwsrHcpuogm9fsY8JW1MkfWmVw945o9o9pgb7ZmpOUU0vcLkRHyWPNpcxM9kJSF4ZiUod-3g7s5JUt1PJNd7r55ekKvZS6UPyxiTwRfPul4oaUsx3dW2o-6TWSr4SEF7hji65kghNEKUyTz9SUw4"
DEVICE_NAME = "Srijan's Echo Dot"  # e.g., "Echo Dot"

def test_speak():
    """Test the speak command."""
    print("\n=== Testing SPEAK command ===")
    status_code, response_text = alexa_api.execute_command(
        command_type="speak",
        command_message="Hello, this is a test message",
        refresh_token=REFRESH_TOKEN,
        device=DEVICE_NAME
    )
    print(f"Status Code: {status_code}")
    print(f"Response: {response_text}")
    return status_code, response_text

def test_textcommand():
    """Test the textcommand command."""
    print("\n=== Testing TEXTCOMMAND ===")
    status_code, response_text = alexa_api.execute_command(
        command_type="textcommand",
        command_message="What time is it?",
        refresh_token=REFRESH_TOKEN,
        device=DEVICE_NAME
    )
    print(f"Status Code: {status_code}")
    print(f"Response: {response_text}")
    return status_code, response_text

def test_get_device_list():
    """Test getting the device list first."""
    print("\n=== Getting Device List ===")
    devices = alexa_api.get_device_list(REFRESH_TOKEN)
    print(f"Available devices: {devices}")
    return devices

if __name__ == "__main__":
    # First, let's see what devices are available
    devices = test_get_device_list()
    
    if not devices:
        print("No devices found. Please check your refresh token.")
    else:
        print(f"\nUsing device: {DEVICE_NAME}")
        
        # Test speak command
        test_speak()
        
        # Uncomment to test textcommand as well
        # test_textcommand()

