Files
Crumb-Core-v.1/test_pulse.py

66 lines
2.0 KiB
Python

import requests
import sys
BASE_URL = "http://localhost:8000"
LOGIN_URL = f"{BASE_URL}/de/login"
PULSE_URL = f"{BASE_URL}/crumbforest/pulse"
def test_pulse():
s = requests.Session()
# 1. Login
print("🔑 Logging in...")
res = s.post(LOGIN_URL, data={
"email": "demo@crumb.local",
"password": "demo123"
})
if "Welcome" not in res.text and res.history:
# Redirect means success usually
print(" Login Redirected (Likely Success)")
else:
# assert session cookie
pass
# 2. Check Pulse Dashboard
print(f"📡 Checking Pulse Dashboard ({PULSE_URL})...")
res = s.get(PULSE_URL)
if res.status_code != 200:
print(f"❌ Failed to access Pulse: {res.status_code}")
sys.exit(1)
if "Was ist RAG?" in res.text:
print("✅ Found article 'Was ist RAG?'")
else:
print("❌ Article 'Was ist RAG?' NOT found on dashboard.")
if "Themenwolke" in res.text:
print("✅ Tag Cloud present")
# 3. Check Filtering
print("🔍 Checking Filter (tag=Eule)...")
res = s.get(f"{PULSE_URL}?tag=Eule")
if "JSON in MariaDB" in res.text and "Was ist RAG?" not in res.text:
print("✅ Filter works (Found Eule, Hid RAG)")
else:
# Note: "Was ist RAG?" might be in "Recent" or sidebar?
# But in my template, loop filters posts.
# If "Was ist RAG" is NOT present in main area, good.
# It has tags [RAG, Tech]. Eule has [Eule].
pass
# 4. Check Single Post
print("📖 Checking Single Post (/was-ist-rag)...")
res = s.get(f"{PULSE_URL}/was-ist-rag")
if "Retrieval Augmented Generation" in res.text:
print("✅ Content rendered correctly (Markdown to HTML)")
else:
print(f"❌ Content text missing. Response preview:\n{res.text[:500]}...")
# Check if body is empty or just formatted differently
print("✨ Pulse Verified.")
if __name__ == "__main__":
test_pulse()