66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple test script to verify the stop download functionality works properly.
|
|
This simulates the browser behavior without authentication requirements.
|
|
"""
|
|
|
|
import requests
|
|
import time
|
|
import json
|
|
|
|
def test_stop_download_functionality():
|
|
"""Test the stop download functionality."""
|
|
base_url = "http://127.0.0.1:5000"
|
|
|
|
print("Testing Stop Download Functionality")
|
|
print("=" * 50)
|
|
|
|
# Test 1: Try to stop when no downloads are running
|
|
print("\n1. Testing stop when no downloads are running...")
|
|
try:
|
|
response = requests.post(f"{base_url}/api/queue/stop", timeout=5)
|
|
print(f"Status Code: {response.status_code}")
|
|
print(f"Response: {response.json()}")
|
|
|
|
if response.status_code == 400:
|
|
print("✓ Correctly returns error when no downloads are running")
|
|
elif response.status_code == 401:
|
|
print("⚠ Authentication required - this is expected")
|
|
else:
|
|
print(f"✗ Unexpected response: {response.status_code}")
|
|
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"✗ Connection error: {e}")
|
|
return False
|
|
|
|
# Test 2: Check queue status endpoint
|
|
print("\n2. Testing queue status endpoint...")
|
|
try:
|
|
response = requests.get(f"{base_url}/api/queue/status", timeout=5)
|
|
print(f"Status Code: {response.status_code}")
|
|
if response.status_code == 200:
|
|
print(f"Response: {response.json()}")
|
|
print("✓ Queue status endpoint working")
|
|
elif response.status_code == 401:
|
|
print("⚠ Authentication required for queue status")
|
|
else:
|
|
print(f"✗ Unexpected status code: {response.status_code}")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"✗ Connection error: {e}")
|
|
|
|
# Test 3: Check if the server is responding
|
|
print("\n3. Testing server health...")
|
|
try:
|
|
response = requests.get(f"{base_url}/", timeout=5)
|
|
print(f"Status Code: {response.status_code}")
|
|
if response.status_code == 200:
|
|
print("✓ Server is responding")
|
|
else:
|
|
print(f"⚠ Server returned: {response.status_code}")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"✗ Server connection error: {e}")
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
test_stop_download_functionality() |