Download backend/crappy_test.py from posix4e/puppet: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/posix4e/puppet/resolve/main/backend/crappy_test.py
- Command line
-
hf download hf://spaces/posix4e/puppet/backend/crappy_test.py
-
curl -L -o crappy_test.py https://huggingface.co/spaces/posix4e/puppet/resolve/main/backend/crappy_test.py
1.44 kB
| import uuid | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| import backend | |
| client = TestClient(backend.app) | |
| async def test_register_new_key(): | |
| data = {"openai_key": "new_key"} | |
| response = client.post("/register", json=data) | |
| assert response.status_code == 200 | |
| assert "uid" in response.json() | |
| uid = response.json()["uid"] | |
| data = {"openai_key": "new_key"} | |
| response = client.post("/register", json=data) | |
| assert response.status_code == 200 | |
| assert "uid" in response.json() | |
| assert response.json()["uid"] == uid | |
| async def test_register_existing_key(): | |
| data = {"openai_key": "existing_key"} | |
| response = client.post("/register", json=data) | |
| assert response.status_code == 200 | |
| assert "uid" in response.json() | |
| uid = response.json()["uid"] | |
| data = {"openai_key": "existing_key"} | |
| response = client.post("/register", json=data) | |
| assert response.status_code == 200 | |
| assert "uid" in response.json() | |
| assert response.json()["uid"] == uid | |
| async def test_send_event(): | |
| data = { | |
| "uid": str(uuid.uuid4()), | |
| "event": "test event", | |
| } | |
| client.post("/register", json=data) | |
| async def test_assist(): | |
| data = { | |
| "uid": str(uuid.uuid4()), | |
| "prompt": "test prompt", | |
| "version": "davinci-fake", | |
| } | |
| client.post("/assist", json=data) | |