1+ # mypy: ignore-errors
12import pytest
23from httpx import AsyncClient , ASGITransport
34from unittest .mock import patch
67
78@pytest .fixture
89def patch_dependencies ():
9- with patch ('attackmate_api_server.main.get_user_hash' ) as mock_get_user_hash , \
10- patch ('attackmate_api_server.main.verify_password' ) as mock_verify_password , \
11- patch ('attackmate_api_server.main.create_access_token' , return_value = 'mock_access_token' ) \
12- as mock_create_access_token , \
13- patch ('attackmate_api_server.routers.commands.get_persistent_instance' ) \
14- as mock_get_persistent_instance , \
15- patch ('attackmate_api_server.routers.commands.varstore_to_state_model' ,
16- return_value = {'state' : 'data' }) as mock_varstore_to_state :
10+ with patch (
11+ 'attackmate_api_server.main.get_user_hash'
12+ ) as mock_get_user_hash , patch (
13+ 'attackmate_api_server.main.verify_password'
14+ ) as mock_verify_password , patch (
15+ 'attackmate_api_server.main.create_access_token' , return_value = 'mock_access_token'
16+ ) as mock_create_access_token , patch (
17+ 'attackmate_api_server.routers.commands.get_persistent_instance'
18+ ) as mock_get_persistent_instance , patch (
19+ 'attackmate_api_server.routers.commands.varstore_to_state_model' ,
20+ return_value = {'state' : 'data' }
21+ ) as mock_varstore_to_state :
1722 yield {
1823 'get_user_hash' : mock_get_user_hash ,
1924 'verify_password' : mock_verify_password ,
@@ -24,14 +29,14 @@ def patch_dependencies():
2429
2530
2631@pytest .mark .asyncio
27- async def test_root_endpoint ():
32+ async def test_root_endpoint () -> None :
2833 async with AsyncClient (transport = ASGITransport (app = app ), base_url = 'http://test' ) as client :
2934 response = await client .get ('/' )
3035 assert response .status_code == 200
3136
3237
3338@pytest .mark .asyncio
34- async def test_login_success (patch_dependencies ):
39+ async def test_login_success (patch_dependencies ) -> None :
3540 patch_dependencies ['get_user_hash' ].return_value = 'hashed_password'
3641 patch_dependencies ['verify_password' ].return_value = True
3742
@@ -46,7 +51,7 @@ async def test_login_success(patch_dependencies):
4651
4752
4853@pytest .mark .asyncio
49- async def test_login_failure_user_not_found (patch_dependencies ):
54+ async def test_login_failure_user_not_found (patch_dependencies ) -> None :
5055 patch_dependencies ['get_user_hash' ].return_value = None
5156
5257 async with AsyncClient (transport = ASGITransport (app = app ), base_url = 'http://test' ) as client :
@@ -62,7 +67,7 @@ async def test_login_failure_user_not_found(patch_dependencies):
6267
6368
6469@pytest .mark .asyncio
65- async def test_login_failure_invalid_password (patch_dependencies ):
70+ async def test_login_failure_invalid_password (patch_dependencies ) -> None :
6671 patch_dependencies ['get_user_hash' ].return_value = 'hashed_password'
6772 patch_dependencies ['verify_password' ].return_value = False
6873
0 commit comments