Download tests/test_auth.py from isold/meloon: direct link, hf CLI and curl.
- Browser
- Download file 810 Bytes
-
https://huggingface.co/spaces/isold/meloon/resolve/main/tests/test_auth.py
- Command line
-
hf download hf://spaces/isold/meloon/tests/test_auth.py
-
curl -L -o test_auth.py https://huggingface.co/spaces/isold/meloon/resolve/main/tests/test_auth.py
810 Bytes
| from fastapi.testclient import TestClient | |
| import time | |
| def test_register_user(client: TestClient): | |
| # Use timestamp to ensure unique email | |
| email = f"newuser{int(time.time())}@example.com" | |
| response = client.post( | |
| "/api/v1/auth/register", | |
| json={"email": email, "password": "newpassword"}, | |
| ) | |
| assert response.status_code == 201 | |
| def test_login_user(client: TestClient): | |
| email = f"loginuser{int(time.time())}@example.com" | |
| client.post( | |
| "/api/v1/auth/register", | |
| json={"email": email, "password": "loginpassword"}, | |
| ) | |
| response = client.post( | |
| "/api/v1/auth/login", | |
| json={"email": email, "password": "loginpassword"}, | |
| ) | |
| assert response.status_code == 200 | |
| assert "token" in response.json() | |
| assert "user" in response.json() | |