Files
fastapi-users/tests/test_db_interface.py
2019-10-06 11:53:42 +02:00

32 lines
937 B
Python

import pytest
from fastapi_users.models import UserLogin
class TestAuthenticate:
@pytest.mark.asyncio
async def test_unknown_user(self, mock_db_interface):
user = await mock_db_interface.authenticate(UserLogin(
email='lancelot@camelot.bt',
password='guinevere',
))
assert user is None
@pytest.mark.asyncio
async def test_wrong_password(self, mock_db_interface):
user = await mock_db_interface.authenticate(UserLogin(
email='king.arthur@camelot.bt',
password='percival',
))
assert user is None
@pytest.mark.asyncio
async def test_valid_credentials(self, mock_db_interface):
user = await mock_db_interface.authenticate(UserLogin(
email='king.arthur@camelot.bt',
password='guinevere',
))
assert user is not None
assert user.email == 'king.arthur@camelot.bt'