Download backend/tests/test_auth.py from xunwei/fitAI: direct link, hf CLI and curl.
- Browser
- Download file 1.77 kB
-
https://huggingface.co/spaces/xunwei/fitAI/resolve/main/backend/tests/test_auth.py
- Command line
-
hf download hf://spaces/xunwei/fitAI/backend/tests/test_auth.py
-
curl -L -o test_auth.py https://huggingface.co/spaces/xunwei/fitAI/resolve/main/backend/tests/test_auth.py
1.77 kB
| from tests.conftest import client as _client # noqa: register overrides | |
| def test_register(client): | |
| res = client.post("/auth/register", json={"email": "a@test.com", "password": "pass123"}) | |
| assert res.status_code == 200 | |
| assert "access_token" in res.json() | |
| def test_register_duplicate(client): | |
| client.post("/auth/register", json={"email": "dup@test.com", "password": "pass"}) | |
| res = client.post("/auth/register", json={"email": "dup@test.com", "password": "pass"}) | |
| assert res.status_code == 400 | |
| def test_login(client): | |
| client.post("/auth/register", json={"email": "login@test.com", "password": "secret"}) | |
| res = client.post("/auth/login", json={"email": "login@test.com", "password": "secret"}) | |
| assert res.status_code == 200 | |
| assert "access_token" in res.json() | |
| def test_login_wrong_password(client): | |
| client.post("/auth/register", json={"email": "wp@test.com", "password": "correct"}) | |
| res = client.post("/auth/login", json={"email": "wp@test.com", "password": "wrong"}) | |
| assert res.status_code == 401 | |
| def test_me(client): | |
| reg = client.post("/auth/register", json={"email": "me@test.com", "password": "pass"}) | |
| token = reg.json()["access_token"] | |
| res = client.get("/auth/me", headers={"Authorization": f"Bearer {token}"}) | |
| assert res.status_code == 200 | |
| assert res.json()["email"] == "me@test.com" | |
| def test_update_persona(client): | |
| reg = client.post("/auth/register", json={"email": "persona@test.com", "password": "pass"}) | |
| token = reg.json()["access_token"] | |
| headers = {"Authorization": f"Bearer {token}"} | |
| res = client.patch("/auth/me/persona", json={"coach_persona": "strict"}, headers=headers) | |
| assert res.status_code == 200 | |
| assert res.json()["coach_persona"] == "strict" | |