#5 Improve test coverage (#6)

* Improve test coverage of BaseUserDatabase

* Improve unit test isolation

* Improve coverage of router and authentication
This commit is contained in:
François Voron
2019-10-15 07:54:53 +02:00
committed by GitHub
parent 66ef56758a
commit f2892aa378
12 changed files with 335 additions and 312 deletions

View File

@ -1,4 +1,4 @@
import inspect
import asyncio
from typing import Any, Callable, Type
import jwt
@ -28,7 +28,7 @@ def get_user_router(
models = Models(user_model)
reset_password_token_audience = "fastapi-users:reset"
is_on_after_forgot_password_async = inspect.iscoroutinefunction(
is_on_after_forgot_password_async = asyncio.iscoroutinefunction(
on_after_forgot_password
)
@ -87,9 +87,8 @@ def get_user_router(
if user is None or not user.is_active:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST)
updated_user = BaseUserDB(**user.dict())
updated_user.hashed_password = get_password_hash(password)
await user_db.update(updated_user)
user.hashed_password = get_password_hash(password)
await user_db.update(user)
except jwt.PyJWTError:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST)