Spaces:
Runtime error

ai-tester-platform / tests /integration /test_bots_fallback_api.py
BattleFiven's picture
deploy: round 6 save_intermediate light (sha 05316bb)
ed86a97
Raw History Blame Contribute Delete
1.33 kB
from fastapi.testclient import TestClient
from src.api.main import app
from src.db import init_db
def test_create_and_update_bot_deterministic_fallbacks():
init_db()
client = TestClient(app)
create_payload = {
"name": "Fallback API Bot",
"url": "https://example.org/chat",
"description": "Bot for fallback API test",
"deterministic_fallbacks": [
"Non posso aiutarti su questo argomento.",
"Fuori dal mio ambito di conoscenza.",
],
}
create_response = client.post("/api/bots/", json=create_payload)
assert create_response.status_code == 200, create_response.text
created = create_response.json()
bot_id = created["id"]
assert created["deterministic_fallbacks"] == create_payload["deterministic_fallbacks"]
update_payload = {
"deterministic_fallbacks": [
"Richiesta fuori perimetro.",
]
}
update_response = client.put(f"/api/bots/{bot_id}", json=update_payload)
assert update_response.status_code == 200, update_response.text
updated = update_response.json()
assert updated["deterministic_fallbacks"] == update_payload["deterministic_fallbacks"]
delete_response = client.delete(f"/api/bots/{bot_id}")
assert delete_response.status_code == 200, delete_response.text