Spaces:
Paused
Paused
Download tests/test_forgot_password.py from TeamError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/TeamError404/nexus/resolve/main/tests/test_forgot_password.py
- Command line
-
hf download hf://spaces/TeamError404/nexus/tests/test_forgot_password.py
-
curl -L -o test_forgot_password.py https://huggingface.co/spaces/TeamError404/nexus/resolve/main/tests/test_forgot_password.py
1.59 kB
| import pytest | |
| from httpx import AsyncClient | |
| async def test_forgot_password_user_exists(client: AsyncClient): | |
| """Test forgot password with a valid user.""" | |
| # Using 'customer@a.com' from conftest.py / existing seeds if they are there | |
| # But since tests use their own db, I'll rely on the conftest setup. | |
| response = await client.post( | |
| "/api/v1/auth/forgot-password", | |
| json={"email": "customer@a.com"} | |
| ) | |
| # If customer@a.com exists in tests, it should be 200/201 (actually 200 in code) | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert "reset_token" in data | |
| assert "simulated" in data["message"] | |
| async def test_forgot_password_user_not_exists(client: AsyncClient): | |
| """Test forgot password with a non-existent user.""" | |
| response = await client.post( | |
| "/api/v1/auth/forgot-password", | |
| json={"email": "nonexistent@example.com"} | |
| ) | |
| # Should be 404 because of my change | |
| assert response.status_code == 404 | |
| assert response.json()["detail"] == "No account found with this email address." | |
| async def test_reset_password_invalid_token(client: AsyncClient): | |
| """Test reset password with an invalid token.""" | |
| response = await client.post( | |
| "/api/v1/auth/reset-password", | |
| json={"token": "invalid-token", "new_password": "NewPassword123!"} | |
| ) | |
| # Should be 400 because of my change (JWTError caught) | |
| assert response.status_code == 400 | |
| assert response.json()["detail"] == "Invalid or expired reset token" | |