Spaces:
Runtime error
Runtime error
Download tests/integration/test_bots_fallback_api.py from BattleFiven/ai-tester-platform: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/BattleFiven/ai-tester-platform/resolve/main/tests/integration/test_bots_fallback_api.py
- Command line
-
hf download hf://spaces/BattleFiven/ai-tester-platform/tests/integration/test_bots_fallback_api.py
-
curl -L -o test_bots_fallback_api.py https://huggingface.co/spaces/BattleFiven/ai-tester-platform/resolve/main/tests/integration/test_bots_fallback_api.py
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 | |