Skip to content

Commit

Permalink
upload tests and README file
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard0803 committed Dec 5, 2023
1 parent f94f4b9 commit 64826ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions gestao/tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ async def test_recover_password_incorrect(
assert response.status_code == 404



@pytest.mark.anyio
async def test_recover_password_AuthenticationError(client: AsyncClient, fastapi_app: FastAPI) -> None:
async def test_recover_password_AuthenticationError(
client: AsyncClient, fastapi_app: FastAPI
) -> None:
url = fastapi_app.url_path_for("create_user")
user = generate_fake_user()
response = await client.post(url, json=user)
Expand All @@ -94,7 +95,7 @@ async def test_recover_password_AuthenticationError(client: AsyncClient, fastapi
assert isinstance(user_instance, User)

user_credentials = {
"email": user_data['email'],
"email": user_data["email"],
}

url = fastapi_app.url_path_for("recover_password")
Expand Down
6 changes: 4 additions & 2 deletions gestao/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ async def test_create_user_incorrect(client: AsyncClient, fastapi_app: FastAPI)


@pytest.mark.anyio
async def test_create_user_UniqueViolation(client: AsyncClient, fastapi_app: FastAPI) -> None:
async def test_create_user_UniqueViolation(
client: AsyncClient, fastapi_app: FastAPI
) -> None:
url = fastapi_app.url_path_for("create_user")
user = generate_fake_user()
response = await client.post(url, json=user)
assert response.status_code == 200

response = await client.post(url, json=user)
assert response.status_code == 400

Expand Down
4 changes: 3 additions & 1 deletion gestao/web/api/login/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ async def recover_password(request: Request, recover_data: RecoverPasswordDTO) -
await user.update(password=new_password)
except SMTPAuthenticationError:
logging.error("Authentication error while sending email", exc_info=True)
raise HTTPException(status_code=400, detail='Authentication error while sending email')
raise HTTPException(
status_code=400, detail="Authentication error while sending email"
)
except Exception:
logging.error("User not found", exc_info=True)
raise HTTPException(status_code=404, detail="User not found")

0 comments on commit 64826ed

Please sign in to comment.