mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-23 10:49:55 +00:00
shorten public imports
This commit is contained in:
@ -8,7 +8,7 @@ from typing import Any
|
||||
import ahriman.core.auth.helpers
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.spawn import Spawn
|
||||
from ahriman.models.user import User
|
||||
from ahriman.web.web import setup_service
|
||||
@ -50,7 +50,7 @@ def application(configuration: Configuration, spawner: Spawn, database: SQLite,
|
||||
Returns:
|
||||
web.Application: application test instance
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", False)
|
||||
return setup_service("x86_64", configuration, spawner)
|
||||
@ -73,13 +73,13 @@ def application_with_auth(configuration: Configuration, user: User, spawner: Spa
|
||||
web.Application: application test instance
|
||||
"""
|
||||
configuration.set_option("auth", "target", "configuration")
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", True)
|
||||
application = setup_service("x86_64", configuration, spawner)
|
||||
|
||||
generated = user.hash_password(application["validator"].salt)
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=generated)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=generated)
|
||||
|
||||
return application
|
||||
|
||||
@ -101,7 +101,7 @@ def application_with_debug(configuration: Configuration, user: User, spawner: Sp
|
||||
web.Application: application test instance
|
||||
"""
|
||||
configuration.set_option("web", "debug", "yes")
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", False)
|
||||
return setup_service("x86_64", configuration, spawner)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from ahriman.core.auth.auth import Auth
|
||||
from ahriman.core.auth import Auth
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.user import User
|
||||
from ahriman.web.middlewares.auth_handler import AuthorizationPolicy
|
||||
|
||||
|
@ -4,7 +4,7 @@ from aiohttp import web
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from ahriman.core.auth.auth import Auth
|
||||
from ahriman.core.auth import Auth
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.models.user_identity import UserIdentity
|
||||
@ -28,7 +28,7 @@ async def test_authorized_userid(authorization_policy: AuthorizationPolicy, user
|
||||
"""
|
||||
must return authorized user id
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
|
||||
assert await authorization_policy.authorized_userid(_identity(user.username)) == user.username
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.auth.oauth import OAuth
|
||||
from ahriman.core.auth import OAuth
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ async def test_get(client: TestClient, aur_package_ahriman: AURPackage, mocker:
|
||||
"""
|
||||
must call get request correctly
|
||||
"""
|
||||
mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman])
|
||||
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
||||
response = await client.get("/service-api/v1/search", params={"for": "ahriman"})
|
||||
|
||||
assert response.ok
|
||||
@ -33,7 +33,7 @@ async def test_get_exception(client: TestClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise 400 on empty search string
|
||||
"""
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[])
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[])
|
||||
response = await client.get("/service-api/v1/search")
|
||||
|
||||
assert response.status == 404
|
||||
@ -44,7 +44,7 @@ async def test_get_join(client: TestClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must join search args with space
|
||||
"""
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch")
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch")
|
||||
response = await client.get("/service-api/v1/search", params=[("for", "ahriman"), ("for", "maybe")])
|
||||
|
||||
assert response.ok
|
||||
|
@ -2,9 +2,7 @@ import pytest
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.auth.oauth import OAuth
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.views.user.login import LoginView
|
||||
|
Reference in New Issue
Block a user