mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-07-24 03:11:14 +00:00
refactor: implement generic optional import mechanisms
this project is actively using optional imports, which leads to duplicate handling here and there. This commit implements logic in special method to reduce complexity and simplify tests paths
This commit is contained in:
@@ -48,7 +48,8 @@ def test_setup_apispec(application: Application, mocker: MockerFixture) -> None:
|
||||
must set api specification
|
||||
"""
|
||||
apispec_mock = mocker.patch("aiohttp_apispec.setup_aiohttp_apispec")
|
||||
assert setup_apispec(application)
|
||||
|
||||
setup_apispec(application)
|
||||
apispec_mock.assert_called_once_with(
|
||||
application,
|
||||
url="/api-docs/swagger.json",
|
||||
|
||||
@@ -37,7 +37,7 @@ async def test_get_import_error(client_with_auth: TestClient, mocker: MockerFixt
|
||||
"""
|
||||
must return 405 on import error
|
||||
"""
|
||||
pytest.helpers.import_error("ahriman.core.auth.oauth", ["OAuth"], mocker)
|
||||
mocker.patch("ahriman.web.views.v1.user.login.optional_module", return_value=None)
|
||||
response = await client_with_auth.get("/api/v1/login")
|
||||
assert response.status == 405
|
||||
|
||||
|
||||
Reference in New Issue
Block a user