diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py index 4447b1b9..d0f7f6ab 100644 --- a/tests/unit_tests/conftest.py +++ b/tests/unit_tests/conftest.py @@ -277,6 +277,15 @@ async def mock_beanie_get_user_by_id(mocker): return async_mock +@pytest.fixture +async def mock_beanie_user_update(mocker): + """Mocks async call to external method to update user""" + async_mock = AsyncMock() + mocker.patch('fastapi_users_db_beanie.BeanieUserDatabase.update', + side_effect=async_mock) + return async_mock + + @pytest.fixture def mock_auth_current_user(mocker): """ diff --git a/tests/unit_tests/test_root_handler.py b/tests/unit_tests/test_root_handler.py index 295ebefc..9d0efa5b 100644 --- a/tests/unit_tests/test_root_handler.py +++ b/tests/unit_tests/test_root_handler.py @@ -15,6 +15,6 @@ def test_root_endpoint(test_client): HTTP Response Code 200 OK JSON with 'message' key """ - response = test_client.get("/latest") + response = test_client.get("/") assert response.status_code == 200 assert response.json() == {"message": "KernelCI API"} diff --git a/tests/unit_tests/test_token_handler.py b/tests/unit_tests/test_token_handler.py index dc5d07a3..d5753faa 100644 --- a/tests/unit_tests/test_token_handler.py +++ b/tests/unit_tests/test_token_handler.py @@ -15,7 +15,8 @@ @pytest.mark.asyncio -async def test_token_endpoint(test_async_client, mock_user_find): +async def test_token_endpoint(test_async_client, mock_user_find, + mock_beanie_user_update): """ Test Case : Test KernelCI API /user/login endpoint Expected Result : @@ -34,6 +35,8 @@ async def test_token_endpoint(test_async_client, mock_user_find): is_verified=True ) mock_user_find.return_value = user + mock_beanie_user_update.return_value = user + response = await test_async_client.post( "user/login", headers={