strict test checks

This commit is contained in:
2022-03-03 22:35:10 +03:00
parent 9529525cb5
commit 9964a96296
62 changed files with 326 additions and 269 deletions

View File

@ -14,7 +14,7 @@ from ahriman.web.middlewares.auth_handler import auth_handler, AuthorizationPoli
def _identity(username: str) -> str:
"""
generate identity from user
:param user: user fixture object
:param username: name of the user
:return: user identity string
"""
return f"{username} {UserIdentity.expire_when(60)}"
@ -119,7 +119,7 @@ def test_setup_auth(application_with_auth: web.Application, auth: Auth, mocker:
"""
must setup authorization
"""
aiohttp_security_setup_mock = mocker.patch("aiohttp_security.setup")
setup_mock = mocker.patch("aiohttp_security.setup")
application = setup_auth(application_with_auth, auth)
assert application.get("validator") is not None
aiohttp_security_setup_mock.assert_called_once()
setup_mock.assert_called_once_with(application_with_auth, pytest.helpers.anyvar(int), pytest.helpers.anyvar(int))

View File

@ -71,7 +71,7 @@ async def test_exception_handler_server_error(mocker: MockerFixture) -> None:
handler = exception_handler(logging.getLogger())
response = await handler(request, request_handler)
assert _extract_body(response) == {"error": HTTPInternalServerError().reason}
logging_mock.assert_called_once()
logging_mock.assert_called_once() # we do not check logging arguments
async def test_exception_handler_unknown_error(mocker: MockerFixture) -> None:
@ -85,4 +85,4 @@ async def test_exception_handler_unknown_error(mocker: MockerFixture) -> None:
handler = exception_handler(logging.getLogger())
response = await handler(request, request_handler)
assert _extract_body(response) == {"error": "An error"}
logging_mock.assert_called_once()
logging_mock.assert_called_once() # we do not check logging arguments