Skip to content

Commit

Permalink
chore: Close database connection in login function
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarboni committed Aug 7, 2024
1 parent 69323c5 commit 0e7d2ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ async def login(
except Exception as e:
db.rollback() # Revertir cualquier cambio no confirmado
raise e
finally:
db.close()
if not user or not user.verify_password(password):
return templates.TemplateResponse(request=request, name="login.html", context={"error": "Usuario o contraseña incorrectos"})

Expand Down
3 changes: 1 addition & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ def test_find_best_combination():
[3, 3, 3, 3, 3, 3, 3, 3, 3],
[4, 4, 4, 4, 4, 4, 4, 4, 4]
]
best_teams, min_difference, min_difference_total = find_best_combination(scores)
best_teams, min_difference_total = find_best_combination(scores)

assert len(best_teams) == 1
assert min_difference == 0
assert min_difference_total == 0

# Check if the teams are balanced
Expand Down

0 comments on commit 0e7d2ff

Please sign in to comment.