This commit is contained in:
2025-11-11 17:40:29 +01:00
parent 901e8166cd
commit 75a6973a49
11 changed files with 1028 additions and 21 deletions

48
test-newsletter-api.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
# Test script for newsletter API endpoints
echo "=========================================="
echo "Newsletter API Test"
echo "=========================================="
echo ""
BASE_URL="http://localhost:5001"
# Test 1: Get stats
echo "Test 1: Get system stats"
echo "GET $BASE_URL/api/admin/stats"
curl -s $BASE_URL/api/admin/stats | python3 -m json.tool | grep -A 3 "subscribers"
echo ""
# Test 2: Send test email
echo "Test 2: Send test email"
read -p "Enter your email address for test: " TEST_EMAIL
if [ -n "$TEST_EMAIL" ]; then
echo "POST $BASE_URL/api/admin/send-test-email"
curl -s -X POST $BASE_URL/api/admin/send-test-email \
-H "Content-Type: application/json" \
-d "{\"email\": \"$TEST_EMAIL\", \"max_articles\": 2}" | python3 -m json.tool
echo ""
else
echo "Skipped (no email provided)"
echo ""
fi
# Test 3: Send newsletter to all subscribers
echo "Test 3: Send newsletter to all subscribers"
read -p "Send newsletter to all active subscribers? (y/N): " CONFIRM
if [ "$CONFIRM" = "y" ] || [ "$CONFIRM" = "Y" ]; then
echo "POST $BASE_URL/api/admin/send-newsletter"
curl -s -X POST $BASE_URL/api/admin/send-newsletter \
-H "Content-Type: application/json" \
-d '{"max_articles": 5}' | python3 -m json.tool
echo ""
else
echo "Skipped"
echo ""
fi
echo "=========================================="
echo "Test Complete"
echo "=========================================="