style: use parebtgeses-less exceptions in side effects (tests only)

This commit is contained in:
2025-07-14 20:33:54 +03:00
parent f5aec4e5c1
commit 228c2cce51
35 changed files with 126 additions and 126 deletions

View File

@@ -72,7 +72,7 @@ async def test_exception_handler_success(mocker: MockerFixture) -> None:
must pass 2xx and 3xx codes
"""
request = pytest.helpers.request("", "", "")
request_handler = AsyncMock(side_effect=HTTPNoContent())
request_handler = AsyncMock(side_effect=HTTPNoContent)
logging_mock = mocker.patch("logging.Logger.exception")
handler = exception_handler(logging.getLogger())
@@ -86,7 +86,7 @@ async def test_exception_handler_unauthorized(mocker: MockerFixture) -> None:
must handle unauthorized exception as json response
"""
request = pytest.helpers.request("", "", "")
request_handler = AsyncMock(side_effect=HTTPUnauthorized())
request_handler = AsyncMock(side_effect=HTTPUnauthorized)
mocker.patch("ahriman.web.middlewares.exception_handler._is_templated_unauthorized", return_value=False)
render_mock = mocker.patch("aiohttp_jinja2.render_template")
@@ -101,7 +101,7 @@ async def test_exception_handler_unauthorized_templated(mocker: MockerFixture) -
must handle unauthorized exception as json response in html context
"""
request = pytest.helpers.request("", "", "")
request_handler = AsyncMock(side_effect=HTTPUnauthorized())
request_handler = AsyncMock(side_effect=HTTPUnauthorized)
mocker.patch("ahriman.web.middlewares.exception_handler._is_templated_unauthorized", return_value=True)
render_mock = mocker.patch("aiohttp_jinja2.render_template")
@@ -154,7 +154,7 @@ async def test_exception_handler_client_error(mocker: MockerFixture) -> None:
must handle client exception
"""
request = pytest.helpers.request("", "", "")
request_handler = AsyncMock(side_effect=HTTPBadRequest())
request_handler = AsyncMock(side_effect=HTTPBadRequest)
logging_mock = mocker.patch("logging.Logger.exception")
handler = exception_handler(logging.getLogger())
@@ -168,7 +168,7 @@ async def test_exception_handler_server_error(mocker: MockerFixture) -> None:
must handle server exception
"""
request = pytest.helpers.request("", "", "")
request_handler = AsyncMock(side_effect=HTTPInternalServerError())
request_handler = AsyncMock(side_effect=HTTPInternalServerError)
logging_mock = mocker.patch("logging.Logger.exception")
handler = exception_handler(logging.getLogger())

View File

@@ -86,7 +86,7 @@ async def test_on_startup_exception(application: Application, watcher: Watcher,
must throw exception on load error
"""
mocker.patch("aiohttp.web.Application.__getitem__", return_value={"": watcher})
mocker.patch("ahriman.core.status.watcher.Watcher.load", side_effect=Exception())
mocker.patch("ahriman.core.status.watcher.Watcher.load", side_effect=Exception)
with pytest.raises(InitializeError):
await _on_startup(application)

View File

@@ -60,7 +60,7 @@ async def test_get_process_exception(client: TestClient, mocker: MockerFixture)
"""
must raise 404 on invalid PGP server response
"""
import_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_download", side_effect=Exception())
import_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_download", side_effect=Exception)
response_schema = pytest.helpers.schema_response(PGPView.get, code=400)
response = await client.get("/api/v1/service/pgp", params={"key": "0xdeadbeaf", "server": "keyserver.ubuntu.com"})

View File

@@ -82,7 +82,7 @@ async def test_post_exception_inside(client: TestClient, mocker: MockerFixture)
exception handler must handle 500 errors
"""
payload = {"status": BuildStatusEnum.Success.value}
mocker.patch("ahriman.core.status.watcher.Watcher.status_update", side_effect=Exception())
mocker.patch("ahriman.core.status.watcher.Watcher.status_update", side_effect=Exception)
response_schema = pytest.helpers.schema_response(StatusView.post, code=500)
response = await client.post("/api/v1/status", json=payload)

View File

@@ -40,7 +40,7 @@ async def test_post_unauthorized(client_with_auth: TestClient, mocker: MockerFix
"""
must raise exception if unauthorized
"""
mocker.patch("ahriman.web.views.v1.user.logout.check_authorized", side_effect=HTTPUnauthorized())
mocker.patch("ahriman.web.views.v1.user.logout.check_authorized", side_effect=HTTPUnauthorized)
forget_mock = mocker.patch("ahriman.web.views.v1.user.logout.forget")
response_schema = pytest.helpers.schema_response(LogoutView.post, code=401)