From 7f87863734473fca9fa2f77a79e6f8090c2570c0 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Fri, 6 May 2022 04:08:05 +0300 Subject: [PATCH] shorten public imports --- docs/advanced-usage.rst | 2 +- .../application/application_properties.py | 2 +- .../application/application_repository.py | 2 +- src/ahriman/application/handlers/add.py | 2 +- src/ahriman/application/handlers/backup.py | 4 +- src/ahriman/application/handlers/clean.py | 2 +- src/ahriman/application/handlers/dump.py | 4 +- src/ahriman/application/handlers/help.py | 2 +- .../application/handlers/key_import.py | 2 +- src/ahriman/application/handlers/patch.py | 4 +- src/ahriman/application/handlers/rebuild.py | 4 +- src/ahriman/application/handlers/remove.py | 2 +- .../application/handlers/remove_unknown.py | 4 +- src/ahriman/application/handlers/report.py | 2 +- src/ahriman/application/handlers/restore.py | 2 +- src/ahriman/application/handlers/search.py | 7 +- src/ahriman/application/handlers/setup.py | 2 +- src/ahriman/application/handlers/sign.py | 2 +- src/ahriman/application/handlers/status.py | 5 +- .../application/handlers/status_update.py | 2 +- src/ahriman/application/handlers/sync.py | 2 +- .../application/handlers/unsafe_commands.py | 4 +- src/ahriman/application/handlers/update.py | 2 +- src/ahriman/application/handlers/users.py | 6 +- src/ahriman/application/handlers/web.py | 2 +- src/ahriman/core/alpm/remote/__init__.py | 5 ++ src/ahriman/core/alpm/remote/aur.py | 2 +- src/ahriman/core/alpm/remote/official.py | 2 +- .../core/alpm/remote/official_syncdb.py | 2 +- src/ahriman/core/alpm/remote/remote.py | 3 +- src/ahriman/core/auth/__init__.py | 4 ++ src/ahriman/core/auth/auth.py | 6 +- src/ahriman/core/auth/mapping.py | 5 +- src/ahriman/core/auth/oauth.py | 4 +- src/ahriman/core/build_tools/task.py | 2 +- src/ahriman/core/database/__init__.py | 1 + src/ahriman/core/database/data/__init__.py | 3 +- src/ahriman/core/formatters/__init__.py | 32 ++++++---- src/ahriman/core/formatters/aur_printer.py | 2 +- src/ahriman/core/formatters/build_printer.py | 2 +- .../core/formatters/configuration_printer.py | 2 +- .../core/formatters/package_printer.py | 2 +- src/ahriman/core/formatters/status_printer.py | 2 +- src/ahriman/core/formatters/string_printer.py | 2 +- src/ahriman/core/formatters/update_printer.py | 2 +- src/ahriman/core/formatters/user_printer.py | 2 +- src/ahriman/core/report/__init__.py | 7 ++ src/ahriman/core/report/console.py | 4 +- src/ahriman/core/report/email.py | 3 +- src/ahriman/core/report/html.py | 3 +- src/ahriman/core/report/report.py | 8 +-- src/ahriman/core/report/telegram.py | 3 +- src/ahriman/core/repository/executor.py | 4 +- src/ahriman/core/repository/repository.py | 2 +- .../core/repository/repository_properties.py | 2 +- src/ahriman/core/status/watcher.py | 2 +- src/ahriman/core/tree.py | 4 +- src/ahriman/core/upload/__init__.py | 6 ++ src/ahriman/core/upload/github.py | 2 +- src/ahriman/core/upload/http_upload.py | 2 +- src/ahriman/core/upload/rsync.py | 2 +- src/ahriman/core/upload/s3.py | 2 +- src/ahriman/core/upload/upload.py | 6 +- src/ahriman/models/package.py | 4 +- src/ahriman/models/remote_source.py | 4 +- src/ahriman/web/middlewares/auth_handler.py | 2 +- src/ahriman/web/views/base.py | 4 +- src/ahriman/web/views/service/search.py | 2 +- src/ahriman/web/views/user/login.py | 2 +- src/ahriman/web/web.py | 4 +- .../application/application/conftest.py | 8 +-- .../application/test_application_packages.py | 10 +-- tests/ahriman/application/conftest.py | 4 +- .../application/handlers/test_handler_add.py | 4 +- .../handlers/test_handler_backup.py | 2 +- .../application/handlers/test_handler_dump.py | 2 +- .../handlers/test_handler_patch.py | 20 +++--- .../handlers/test_handler_rebuild.py | 10 +-- .../handlers/test_handler_remove_unknown.py | 4 +- .../handlers/test_handler_search.py | 28 ++++---- .../handlers/test_handler_setup.py | 10 +-- .../handlers/test_handler_status.py | 10 +-- .../handlers/test_handler_unsafe_commands.py | 6 +- .../handlers/test_handler_update.py | 8 +-- .../handlers/test_handler_users.py | 22 +++---- tests/ahriman/conftest.py | 4 +- tests/ahriman/core/alpm/remote/conftest.py | 5 +- tests/ahriman/core/alpm/remote/test_aur.py | 6 +- .../ahriman/core/alpm/remote/test_official.py | 6 +- .../core/alpm/remote/test_official_syncdb.py | 2 +- tests/ahriman/core/alpm/remote/test_remote.py | 12 ++-- tests/ahriman/core/auth/conftest.py | 5 +- tests/ahriman/core/auth/test_auth.py | 6 +- tests/ahriman/core/auth/test_mapping.py | 14 ++-- tests/ahriman/core/auth/test_oauth.py | 2 +- tests/ahriman/core/build_tools/test_task.py | 2 +- .../operations/test_auth_operations.py | 2 +- .../operations/test_build_operations.py | 2 +- .../database/operations/test_operations.py | 2 +- .../operations/test_package_operations.py | 20 +++--- .../operations/test_patch_operations.py | 2 +- tests/ahriman/core/database/test_sqlite.py | 4 +- tests/ahriman/core/formatters/conftest.py | 8 +-- .../core/formatters/test_aur_printer.py | 2 +- .../core/formatters/test_build_printer.py | 2 +- .../formatters/test_configuration_printer.py | 2 +- .../core/formatters/test_package_printer.py | 2 +- tests/ahriman/core/formatters/test_printer.py | 4 +- .../core/formatters/test_status_printer.py | 2 +- .../core/formatters/test_string_printer.py | 2 +- .../core/formatters/test_update_printer.py | 2 +- .../core/formatters/test_user_printer.py | 2 +- tests/ahriman/core/report/test_console.py | 4 +- tests/ahriman/core/report/test_email.py | 12 ++-- tests/ahriman/core/report/test_html.py | 2 +- .../core/report/test_jinja_template.py | 2 +- tests/ahriman/core/report/test_report.py | 14 ++-- tests/ahriman/core/report/test_telegram.py | 10 +-- tests/ahriman/core/repository/conftest.py | 2 +- tests/ahriman/core/repository/test_cleaner.py | 2 +- .../ahriman/core/repository/test_executor.py | 16 ++--- .../repository/test_repository_properties.py | 2 +- .../core/repository/test_update_handler.py | 6 +- tests/ahriman/core/status/test_watcher.py | 17 ++--- tests/ahriman/core/test_tree.py | 2 +- tests/ahriman/core/upload/conftest.py | 4 +- tests/ahriman/core/upload/test_github.py | 64 +++++++++---------- tests/ahriman/core/upload/test_http_upload.py | 3 +- tests/ahriman/core/upload/test_rsync.py | 4 +- tests/ahriman/core/upload/test_s3.py | 12 ++-- tests/ahriman/core/upload/test_upload.py | 12 ++-- tests/ahriman/models/test_package.py | 4 +- tests/ahriman/models/test_remote_source.py | 8 +-- tests/ahriman/web/conftest.py | 10 +-- tests/ahriman/web/middlewares/conftest.py | 4 +- .../web/middlewares/test_auth_handler.py | 4 +- tests/ahriman/web/views/conftest.py | 2 +- .../service/test_views_service_search.py | 6 +- .../web/views/user/test_views_user_login.py | 2 - 139 files changed, 374 insertions(+), 373 deletions(-) diff --git a/docs/advanced-usage.rst b/docs/advanced-usage.rst index 3abfe43d..617bca4b 100644 --- a/docs/advanced-usage.rst +++ b/docs/advanced-usage.rst @@ -8,7 +8,7 @@ Depending on the goal the package can be used in different ways. Nevertheless, i from pathlib import Path from ahriman.core.configuration import Configuration - from ahriman.core.database.sqlite import SQLite + from ahriman.core.database import SQLite architecture = "x86_64" configuration = Configuration.from_path(Path("/etc/ahriman.ini"), architecture, quiet=False) diff --git a/src/ahriman/application/application/application_properties.py b/src/ahriman/application/application/application_properties.py index 436f87a3..49f019f3 100644 --- a/src/ahriman/application/application/application_properties.py +++ b/src/ahriman/application/application/application_properties.py @@ -20,7 +20,7 @@ import logging from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.repository import Repository diff --git a/src/ahriman/application/application/application_repository.py b/src/ahriman/application/application/application_repository.py index 32187a55..7bfd60c3 100644 --- a/src/ahriman/application/application/application_repository.py +++ b/src/ahriman/application/application/application_repository.py @@ -24,7 +24,7 @@ from typing import Callable, Iterable, List from ahriman.application.application.application_properties import ApplicationProperties from ahriman.core.build_tools.sources import Sources -from ahriman.core.formatters.update_printer import UpdatePrinter +from ahriman.core.formatters import UpdatePrinter from ahriman.core.tree import Tree from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/src/ahriman/application/handlers/add.py b/src/ahriman/application/handlers/add.py index 654a1daf..9da987e4 100644 --- a/src/ahriman/application/handlers/add.py +++ b/src/ahriman/application/handlers/add.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/backup.py b/src/ahriman/application/handlers/backup.py index e3dafc45..528fd67a 100644 --- a/src/ahriman/application/handlers/backup.py +++ b/src/ahriman/application/handlers/backup.py @@ -24,9 +24,9 @@ from pathlib import Path from tarfile import TarFile from typing import Set, Type -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite class Backup(Handler): diff --git a/src/ahriman/application/handlers/clean.py b/src/ahriman/application/handlers/clean.py index 45396e1a..fa5511c8 100644 --- a/src/ahriman/application/handlers/clean.py +++ b/src/ahriman/application/handlers/clean.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/dump.py b/src/ahriman/application/handlers/dump.py index ad5ced25..07d98a00 100644 --- a/src/ahriman/application/handlers/dump.py +++ b/src/ahriman/application/handlers/dump.py @@ -21,9 +21,9 @@ import argparse from typing import Type -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.formatters.configuration_printer import ConfigurationPrinter +from ahriman.core.formatters import ConfigurationPrinter class Dump(Handler): diff --git a/src/ahriman/application/handlers/help.py b/src/ahriman/application/handlers/help.py index b74a6ac8..dd77d15c 100644 --- a/src/ahriman/application/handlers/help.py +++ b/src/ahriman/application/handlers/help.py @@ -21,7 +21,7 @@ import argparse from typing import Type -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/key_import.py b/src/ahriman/application/handlers/key_import.py index 42ba3c2f..bdb09b3c 100644 --- a/src/ahriman/application/handlers/key_import.py +++ b/src/ahriman/application/handlers/key_import.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/patch.py b/src/ahriman/application/handlers/patch.py index 73d5f1e0..ec46eda6 100644 --- a/src/ahriman/application/handlers/patch.py +++ b/src/ahriman/application/handlers/patch.py @@ -23,10 +23,10 @@ from pathlib import Path from typing import List, Optional, Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.build_tools.sources import Sources from ahriman.core.configuration import Configuration -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.action import Action from ahriman.models.package import Package diff --git a/src/ahriman/application/handlers/rebuild.py b/src/ahriman/application/handlers/rebuild.py index 2e28df2c..3362a7b5 100644 --- a/src/ahriman/application/handlers/rebuild.py +++ b/src/ahriman/application/handlers/rebuild.py @@ -22,9 +22,9 @@ import argparse from typing import List, Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.formatters.update_printer import UpdatePrinter +from ahriman.core.formatters import UpdatePrinter from ahriman.models.package import Package diff --git a/src/ahriman/application/handlers/remove.py b/src/ahriman/application/handlers/remove.py index 99f14c13..84e5b77a 100644 --- a/src/ahriman/application/handlers/remove.py +++ b/src/ahriman/application/handlers/remove.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/remove_unknown.py b/src/ahriman/application/handlers/remove_unknown.py index 415c4f18..8fb7a99a 100644 --- a/src/ahriman/application/handlers/remove_unknown.py +++ b/src/ahriman/application/handlers/remove_unknown.py @@ -22,9 +22,9 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter class RemoveUnknown(Handler): diff --git a/src/ahriman/application/handlers/report.py b/src/ahriman/application/handlers/report.py index 715327e0..4eec462c 100644 --- a/src/ahriman/application/handlers/report.py +++ b/src/ahriman/application/handlers/report.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration from ahriman.models.result import Result diff --git a/src/ahriman/application/handlers/restore.py b/src/ahriman/application/handlers/restore.py index 7cb50339..3d94693c 100644 --- a/src/ahriman/application/handlers/restore.py +++ b/src/ahriman/application/handlers/restore.py @@ -22,7 +22,7 @@ import argparse from typing import Type from tarfile import TarFile -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/search.py b/src/ahriman/application/handlers/search.py index 8c42cf6b..05386a54 100644 --- a/src/ahriman/application/handlers/search.py +++ b/src/ahriman/application/handlers/search.py @@ -23,12 +23,11 @@ from dataclasses import fields from typing import Callable, Iterable, List, Tuple, Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler -from ahriman.core.alpm.remote.aur import AUR -from ahriman.core.alpm.remote.official import Official +from ahriman.application.handlers import Handler +from ahriman.core.alpm.remote import AUR, Official from ahriman.core.configuration import Configuration from ahriman.core.exceptions import InvalidOption -from ahriman.core.formatters.aur_printer import AurPrinter +from ahriman.core.formatters import AurPrinter from ahriman.models.aur_package import AURPackage diff --git a/src/ahriman/application/handlers/setup.py b/src/ahriman/application/handlers/setup.py index 2de59e1f..e5d109db 100644 --- a/src/ahriman/application/handlers/setup.py +++ b/src/ahriman/application/handlers/setup.py @@ -23,7 +23,7 @@ from pathlib import Path from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration from ahriman.models.repository_paths import RepositoryPaths diff --git a/src/ahriman/application/handlers/sign.py b/src/ahriman/application/handlers/sign.py index 5d7a8436..f12d0b6c 100644 --- a/src/ahriman/application/handlers/sign.py +++ b/src/ahriman/application/handlers/sign.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/status.py b/src/ahriman/application/handlers/status.py index 9cf60412..d20a5e09 100644 --- a/src/ahriman/application/handlers/status.py +++ b/src/ahriman/application/handlers/status.py @@ -22,10 +22,9 @@ import argparse from typing import Callable, Iterable, Tuple, Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.formatters.package_printer import PackagePrinter -from ahriman.core.formatters.status_printer import StatusPrinter +from ahriman.core.formatters import PackagePrinter, StatusPrinter from ahriman.models.build_status import BuildStatus from ahriman.models.package import Package diff --git a/src/ahriman/application/handlers/status_update.py b/src/ahriman/application/handlers/status_update.py index fd988382..09f71b5f 100644 --- a/src/ahriman/application/handlers/status_update.py +++ b/src/ahriman/application/handlers/status_update.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration from ahriman.models.action import Action diff --git a/src/ahriman/application/handlers/sync.py b/src/ahriman/application/handlers/sync.py index 66c781a0..5e59adff 100644 --- a/src/ahriman/application/handlers/sync.py +++ b/src/ahriman/application/handlers/sync.py @@ -22,7 +22,7 @@ import argparse from typing import Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/unsafe_commands.py b/src/ahriman/application/handlers/unsafe_commands.py index f14486a1..5a714a26 100644 --- a/src/ahriman/application/handlers/unsafe_commands.py +++ b/src/ahriman/application/handlers/unsafe_commands.py @@ -22,9 +22,9 @@ import shlex from typing import List, Type -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter class UnsafeCommands(Handler): diff --git a/src/ahriman/application/handlers/update.py b/src/ahriman/application/handlers/update.py index 9ac19fd6..f1a30710 100644 --- a/src/ahriman/application/handlers/update.py +++ b/src/ahriman/application/handlers/update.py @@ -22,7 +22,7 @@ import argparse from typing import Callable, Type from ahriman.application.application import Application -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration diff --git a/src/ahriman/application/handlers/users.py b/src/ahriman/application/handlers/users.py index 458cdbb4..b9a933dc 100644 --- a/src/ahriman/application/handlers/users.py +++ b/src/ahriman/application/handlers/users.py @@ -23,10 +23,10 @@ import getpass from pathlib import Path from typing import Type -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite -from ahriman.core.formatters.user_printer import UserPrinter +from ahriman.core.database import SQLite +from ahriman.core.formatters import UserPrinter from ahriman.models.action import Action from ahriman.models.user import User diff --git a/src/ahriman/application/handlers/web.py b/src/ahriman/application/handlers/web.py index 8ac8b894..29a5c5a0 100644 --- a/src/ahriman/application/handlers/web.py +++ b/src/ahriman/application/handlers/web.py @@ -21,7 +21,7 @@ import argparse from typing import Type -from ahriman.application.handlers.handler import Handler +from ahriman.application.handlers import Handler from ahriman.core.configuration import Configuration from ahriman.core.spawn import Spawn diff --git a/src/ahriman/core/alpm/remote/__init__.py b/src/ahriman/core/alpm/remote/__init__.py index 680676f1..cad3198c 100644 --- a/src/ahriman/core/alpm/remote/__init__.py +++ b/src/ahriman/core/alpm/remote/__init__.py @@ -17,3 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +from ahriman.core.alpm.remote.remote import Remote + +from ahriman.core.alpm.remote.aur import AUR +from ahriman.core.alpm.remote.official import Official +from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb diff --git a/src/ahriman/core/alpm/remote/aur.py b/src/ahriman/core/alpm/remote/aur.py index e70e122d..cb521914 100644 --- a/src/ahriman/core/alpm/remote/aur.py +++ b/src/ahriman/core/alpm/remote/aur.py @@ -22,7 +22,7 @@ import requests from typing import Any, Dict, List, Type from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.remote import Remote +from ahriman.core.alpm.remote import Remote from ahriman.core.exceptions import InvalidPackageInfo from ahriman.core.util import exception_response_text from ahriman.models.aur_package import AURPackage diff --git a/src/ahriman/core/alpm/remote/official.py b/src/ahriman/core/alpm/remote/official.py index 22bf71c5..b39e78c1 100644 --- a/src/ahriman/core/alpm/remote/official.py +++ b/src/ahriman/core/alpm/remote/official.py @@ -22,7 +22,7 @@ import requests from typing import Any, Dict, List, Type from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.remote import Remote +from ahriman.core.alpm.remote import Remote from ahriman.core.exceptions import InvalidPackageInfo from ahriman.core.util import exception_response_text from ahriman.models.aur_package import AURPackage diff --git a/src/ahriman/core/alpm/remote/official_syncdb.py b/src/ahriman/core/alpm/remote/official_syncdb.py index 99f8b471..f600dff0 100644 --- a/src/ahriman/core/alpm/remote/official_syncdb.py +++ b/src/ahriman/core/alpm/remote/official_syncdb.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.official import Official +from ahriman.core.alpm.remote import Official from ahriman.models.aur_package import AURPackage diff --git a/src/ahriman/core/alpm/remote/remote.py b/src/ahriman/core/alpm/remote/remote.py index 63c1b0a2..42f09e87 100644 --- a/src/ahriman/core/alpm/remote/remote.py +++ b/src/ahriman/core/alpm/remote/remote.py @@ -38,8 +38,7 @@ class Remote: These classes are designed to be used without instancing. In order to achieve it several class methods are provided: ``info``, ``multisearch`` and ``search``. Thus, the basic flow is the following:: - >>> from ahriman.core.alpm.remote.aur import AUR - >>> from ahriman.core.alpm.remote.official import Official + >>> from ahriman.core.alpm.remote import AUR, Official >>> >>> package = AUR.info("ahriman", pacman=pacman) >>> search_result = Official.multisearch("pacman", "manager", pacman=pacman) diff --git a/src/ahriman/core/auth/__init__.py b/src/ahriman/core/auth/__init__.py index 680676f1..01ddf4b9 100644 --- a/src/ahriman/core/auth/__init__.py +++ b/src/ahriman/core/auth/__init__.py @@ -17,3 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +from ahriman.core.auth.auth import Auth + +from ahriman.core.auth.mapping import Mapping +from ahriman.core.auth.oauth import OAuth diff --git a/src/ahriman/core/auth/auth.py b/src/ahriman/core/auth/auth.py index 3a2f4b17..f2236214 100644 --- a/src/ahriman/core/auth/auth.py +++ b/src/ahriman/core/auth/auth.py @@ -24,7 +24,7 @@ import logging from typing import Optional, Type from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.models.auth_settings import AuthSettings from ahriman.models.user_access import UserAccess @@ -82,10 +82,10 @@ class Auth: """ provider = AuthSettings.from_option(configuration.get("auth", "target", fallback="disabled")) if provider == AuthSettings.Configuration: - from ahriman.core.auth.mapping import Mapping + from ahriman.core.auth import Mapping return Mapping(configuration, database) if provider == AuthSettings.OAuth: - from ahriman.core.auth.oauth import OAuth + from ahriman.core.auth import OAuth return OAuth(configuration, database) return cls(configuration) diff --git a/src/ahriman/core/auth/mapping.py b/src/ahriman/core/auth/mapping.py index 76140151..dceae58c 100644 --- a/src/ahriman/core/auth/mapping.py +++ b/src/ahriman/core/auth/mapping.py @@ -19,10 +19,9 @@ # from typing import Optional -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.auth_settings import AuthSettings from ahriman.models.user import User from ahriman.models.user_access import UserAccess diff --git a/src/ahriman/core/auth/oauth.py b/src/ahriman/core/auth/oauth.py index 55dbb607..97f0e97e 100644 --- a/src/ahriman/core/auth/oauth.py +++ b/src/ahriman/core/auth/oauth.py @@ -21,9 +21,9 @@ import aioauth_client from typing import Optional, Type -from ahriman.core.auth.mapping import Mapping +from ahriman.core.auth import Mapping from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import InvalidOption from ahriman.models.auth_settings import AuthSettings diff --git a/src/ahriman/core/build_tools/task.py b/src/ahriman/core/build_tools/task.py index 1ce93f20..0235a815 100644 --- a/src/ahriman/core/build_tools/task.py +++ b/src/ahriman/core/build_tools/task.py @@ -25,7 +25,7 @@ from typing import List from ahriman.core.build_tools.sources import Sources from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import BuildFailed from ahriman.core.util import check_output from ahriman.models.package import Package diff --git a/src/ahriman/core/database/__init__.py b/src/ahriman/core/database/__init__.py index 680676f1..7f8ee2d9 100644 --- a/src/ahriman/core/database/__init__.py +++ b/src/ahriman/core/database/__init__.py @@ -17,3 +17,4 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +from ahriman.core.database.sqlite import SQLite diff --git a/src/ahriman/core/database/data/__init__.py b/src/ahriman/core/database/data/__init__.py index fc7597be..7a4c08f3 100644 --- a/src/ahriman/core/database/data/__init__.py +++ b/src/ahriman/core/database/data/__init__.py @@ -27,8 +27,7 @@ from ahriman.core.database.data.users import migrate_users_data from ahriman.models.migration_result import MigrationResult -def migrate_data( - result: MigrationResult, connection: Connection, configuration: Configuration) -> None: +def migrate_data(result: MigrationResult, connection: Connection, configuration: Configuration) -> None: """ perform data migration diff --git a/src/ahriman/core/formatters/__init__.py b/src/ahriman/core/formatters/__init__.py index 680676f1..fea8b9d5 100644 --- a/src/ahriman/core/formatters/__init__.py +++ b/src/ahriman/core/formatters/__init__.py @@ -1,19 +1,29 @@ # -# Copyright (c) 2021-2022 ahriman team. +# copyright (c) 2021-2022 ahriman team. # -# This file is part of ahriman +# this file is part of ahriman # (see https://github.com/arcan1s/ahriman). # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# this program is free software: you can redistribute it and/or modify +# it under the terms of the gnu general public license as published by +# the free software foundation, either version 3 of the license, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# this program is distributed in the hope that it will be useful, +# but without any warranty; without even the implied warranty of +# merchantability or fitness for a particular purpose. see the +# gnu general public license for more details. # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# you should have received a copy of the gnu general public license +# along with this program. if not, see . # +from ahriman.core.formatters.printer import Printer +from ahriman.core.formatters.string_printer import StringPrinter + +from ahriman.core.formatters.aur_printer import AurPrinter +from ahriman.core.formatters.build_printer import BuildPrinter +from ahriman.core.formatters.configuration_printer import ConfigurationPrinter +from ahriman.core.formatters.package_printer import PackagePrinter +from ahriman.core.formatters.status_printer import StatusPrinter +from ahriman.core.formatters.update_printer import UpdatePrinter +from ahriman.core.formatters.user_printer import UserPrinter diff --git a/src/ahriman/core/formatters/aur_printer.py b/src/ahriman/core/formatters/aur_printer.py index cafb389f..d19d030e 100644 --- a/src/ahriman/core/formatters/aur_printer.py +++ b/src/ahriman/core/formatters/aur_printer.py @@ -19,7 +19,7 @@ # from typing import List -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.core.util import pretty_datetime from ahriman.models.aur_package import AURPackage from ahriman.models.property import Property diff --git a/src/ahriman/core/formatters/build_printer.py b/src/ahriman/core/formatters/build_printer.py index e510c1e5..6ee4bdc1 100644 --- a/src/ahriman/core/formatters/build_printer.py +++ b/src/ahriman/core/formatters/build_printer.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.package import Package diff --git a/src/ahriman/core/formatters/configuration_printer.py b/src/ahriman/core/formatters/configuration_printer.py index e975949e..1d2b6e2d 100644 --- a/src/ahriman/core/formatters/configuration_printer.py +++ b/src/ahriman/core/formatters/configuration_printer.py @@ -19,7 +19,7 @@ # from typing import Dict, List -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.property import Property diff --git a/src/ahriman/core/formatters/package_printer.py b/src/ahriman/core/formatters/package_printer.py index f27090e1..bd5caf47 100644 --- a/src/ahriman/core/formatters/package_printer.py +++ b/src/ahriman/core/formatters/package_printer.py @@ -19,7 +19,7 @@ # from typing import List -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.build_status import BuildStatus from ahriman.models.package import Package from ahriman.models.property import Property diff --git a/src/ahriman/core/formatters/status_printer.py b/src/ahriman/core/formatters/status_printer.py index 6c754fd9..e0755381 100644 --- a/src/ahriman/core/formatters/status_printer.py +++ b/src/ahriman/core/formatters/status_printer.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.build_status import BuildStatus diff --git a/src/ahriman/core/formatters/string_printer.py b/src/ahriman/core/formatters/string_printer.py index 8c32af86..d9763f7b 100644 --- a/src/ahriman/core/formatters/string_printer.py +++ b/src/ahriman/core/formatters/string_printer.py @@ -19,7 +19,7 @@ # from typing import Optional -from ahriman.core.formatters.printer import Printer +from ahriman.core.formatters import Printer class StringPrinter(Printer): diff --git a/src/ahriman/core/formatters/update_printer.py b/src/ahriman/core/formatters/update_printer.py index d43b1006..4c47a364 100644 --- a/src/ahriman/core/formatters/update_printer.py +++ b/src/ahriman/core/formatters/update_printer.py @@ -19,7 +19,7 @@ # from typing import List, Optional -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.package import Package from ahriman.models.property import Property diff --git a/src/ahriman/core/formatters/user_printer.py b/src/ahriman/core/formatters/user_printer.py index c7c46fd1..8d50adaf 100644 --- a/src/ahriman/core/formatters/user_printer.py +++ b/src/ahriman/core/formatters/user_printer.py @@ -19,7 +19,7 @@ # from typing import List -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter from ahriman.models.property import Property from ahriman.models.user import User diff --git a/src/ahriman/core/report/__init__.py b/src/ahriman/core/report/__init__.py index 680676f1..0f041b75 100644 --- a/src/ahriman/core/report/__init__.py +++ b/src/ahriman/core/report/__init__.py @@ -17,3 +17,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +from ahriman.core.report.report import Report +from ahriman.core.report.jinja_template import JinjaTemplate + +from ahriman.core.report.console import Console +from ahriman.core.report.email import Email +from ahriman.core.report.html import HTML +from ahriman.core.report.telegram import Telegram diff --git a/src/ahriman/core/report/console.py b/src/ahriman/core/report/console.py index f8cd9681..b68ec589 100644 --- a/src/ahriman/core/report/console.py +++ b/src/ahriman/core/report/console.py @@ -20,8 +20,8 @@ from typing import Iterable from ahriman.core.configuration import Configuration -from ahriman.core.formatters.build_printer import BuildPrinter -from ahriman.core.report.report import Report +from ahriman.core.formatters import BuildPrinter +from ahriman.core.report import Report from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/src/ahriman/core/report/email.py b/src/ahriman/core/report/email.py index 1b624437..e763193c 100644 --- a/src/ahriman/core/report/email.py +++ b/src/ahriman/core/report/email.py @@ -25,8 +25,7 @@ from email.mime.text import MIMEText from typing import Dict, Iterable from ahriman.core.configuration import Configuration -from ahriman.core.report.jinja_template import JinjaTemplate -from ahriman.core.report.report import Report +from ahriman.core.report import JinjaTemplate, Report from ahriman.core.util import pretty_datetime from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/src/ahriman/core/report/html.py b/src/ahriman/core/report/html.py index 8162acdf..63fb3756 100644 --- a/src/ahriman/core/report/html.py +++ b/src/ahriman/core/report/html.py @@ -20,8 +20,7 @@ from typing import Iterable from ahriman.core.configuration import Configuration -from ahriman.core.report.jinja_template import JinjaTemplate -from ahriman.core.report.report import Report +from ahriman.core.report import JinjaTemplate, Report from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/src/ahriman/core/report/report.py b/src/ahriman/core/report/report.py index a064aefd..8e76cb96 100644 --- a/src/ahriman/core/report/report.py +++ b/src/ahriman/core/report/report.py @@ -87,16 +87,16 @@ class Report: section, provider_name = configuration.gettype(target, architecture) provider = ReportSettings.from_option(provider_name) if provider == ReportSettings.HTML: - from ahriman.core.report.html import HTML + from ahriman.core.report import HTML return HTML(architecture, configuration, section) if provider == ReportSettings.Email: - from ahriman.core.report.email import Email + from ahriman.core.report import Email return Email(architecture, configuration, section) if provider == ReportSettings.Console: - from ahriman.core.report.console import Console + from ahriman.core.report import Console return Console(architecture, configuration, section) if provider == ReportSettings.Telegram: - from ahriman.core.report.telegram import Telegram + from ahriman.core.report import Telegram return Telegram(architecture, configuration, section) return cls(architecture, configuration) # should never happen diff --git a/src/ahriman/core/report/telegram.py b/src/ahriman/core/report/telegram.py index 7e17a0b1..da400e71 100644 --- a/src/ahriman/core/report/telegram.py +++ b/src/ahriman/core/report/telegram.py @@ -23,8 +23,7 @@ import requests from typing import Iterable from ahriman.core.configuration import Configuration -from ahriman.core.report.jinja_template import JinjaTemplate -from ahriman.core.report.report import Report +from ahriman.core.report import JinjaTemplate, Report from ahriman.core.util import exception_response_text from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/src/ahriman/core/repository/executor.py b/src/ahriman/core/repository/executor.py index d4efb884..8190bd3c 100644 --- a/src/ahriman/core/repository/executor.py +++ b/src/ahriman/core/repository/executor.py @@ -23,9 +23,9 @@ from pathlib import Path from typing import Iterable, List, Optional, Set from ahriman.core.build_tools.task import Task -from ahriman.core.report.report import Report +from ahriman.core.report import Report from ahriman.core.repository.cleaner import Cleaner -from ahriman.core.upload.upload import Upload +from ahriman.core.upload import Upload from ahriman.core.util import tmpdir from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/src/ahriman/core/repository/repository.py b/src/ahriman/core/repository/repository.py index fde934a6..fbe20063 100644 --- a/src/ahriman/core/repository/repository.py +++ b/src/ahriman/core/repository/repository.py @@ -35,7 +35,7 @@ class Repository(Executor, UpdateHandler): sync local repository to remote, generate report, etc:: >>> from ahriman.core.configuration import Configuration - >>> from ahriman.core.database.sqlite import SQLite + >>> from ahriman.core.database import SQLite >>> >>> configuration = Configuration() >>> database = SQLite.load(configuration) diff --git a/src/ahriman/core/repository/repository_properties.py b/src/ahriman/core/repository/repository_properties.py index b712729d..bbd1f474 100644 --- a/src/ahriman/core/repository/repository_properties.py +++ b/src/ahriman/core/repository/repository_properties.py @@ -22,7 +22,7 @@ import logging from ahriman.core.alpm.pacman import Pacman from ahriman.core.alpm.repo import Repo from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import UnsafeRun from ahriman.core.sign.gpg import GPG from ahriman.core.status.client import Client diff --git a/src/ahriman/core/status/watcher.py b/src/ahriman/core/status/watcher.py index 58cb272e..e7aa3566 100644 --- a/src/ahriman/core/status/watcher.py +++ b/src/ahriman/core/status/watcher.py @@ -22,7 +22,7 @@ import logging from typing import Dict, List, Optional, Tuple from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import UnknownPackage from ahriman.core.repository import Repository from ahriman.models.build_status import BuildStatus, BuildStatusEnum diff --git a/src/ahriman/core/tree.py b/src/ahriman/core/tree.py index 1dfcaf4f..8725b871 100644 --- a/src/ahriman/core/tree.py +++ b/src/ahriman/core/tree.py @@ -22,7 +22,7 @@ from __future__ import annotations from typing import Iterable, List, Set, Type from ahriman.core.build_tools.sources import Sources -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.util import tmpdir from ahriman.models.package import Package @@ -102,7 +102,7 @@ class Tree: method:: >>> from ahriman.core.configuration import Configuration - >>> from ahriman.core.database.sqlite import SQLite + >>> from ahriman.core.database import SQLite >>> from ahriman.core.repository import Repository >>> >>> configuration = Configuration() diff --git a/src/ahriman/core/upload/__init__.py b/src/ahriman/core/upload/__init__.py index 680676f1..a33ee865 100644 --- a/src/ahriman/core/upload/__init__.py +++ b/src/ahriman/core/upload/__init__.py @@ -17,3 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +from ahriman.core.upload.upload import Upload +from ahriman.core.upload.http_upload import HttpUpload + +from ahriman.core.upload.github import Github +from ahriman.core.upload.rsync import Rsync +from ahriman.core.upload.s3 import S3 diff --git a/src/ahriman/core/upload/github.py b/src/ahriman/core/upload/github.py index afeb6e0f..af87d99f 100644 --- a/src/ahriman/core/upload/github.py +++ b/src/ahriman/core/upload/github.py @@ -24,7 +24,7 @@ from pathlib import Path from typing import Any, Dict, Iterable, Optional from ahriman.core.configuration import Configuration -from ahriman.core.upload.http_upload import HttpUpload +from ahriman.core.upload import HttpUpload from ahriman.core.util import walk from ahriman.models.package import Package diff --git a/src/ahriman/core/upload/http_upload.py b/src/ahriman/core/upload/http_upload.py index 134d06a2..54b34077 100644 --- a/src/ahriman/core/upload/http_upload.py +++ b/src/ahriman/core/upload/http_upload.py @@ -24,7 +24,7 @@ from pathlib import Path from typing import Any, Dict from ahriman.core.configuration import Configuration -from ahriman.core.upload.upload import Upload +from ahriman.core.upload import Upload from ahriman.core.util import exception_response_text diff --git a/src/ahriman/core/upload/rsync.py b/src/ahriman/core/upload/rsync.py index 942f3084..4200664b 100644 --- a/src/ahriman/core/upload/rsync.py +++ b/src/ahriman/core/upload/rsync.py @@ -21,7 +21,7 @@ from pathlib import Path from typing import Iterable from ahriman.core.configuration import Configuration -from ahriman.core.upload.upload import Upload +from ahriman.core.upload import Upload from ahriman.core.util import check_output from ahriman.models.package import Package diff --git a/src/ahriman/core/upload/s3.py b/src/ahriman/core/upload/s3.py index c1783f69..453e1103 100644 --- a/src/ahriman/core/upload/s3.py +++ b/src/ahriman/core/upload/s3.py @@ -25,7 +25,7 @@ from pathlib import Path from typing import Any, Dict, Iterable from ahriman.core.configuration import Configuration -from ahriman.core.upload.upload import Upload +from ahriman.core.upload import Upload from ahriman.core.util import walk from ahriman.models.package import Package diff --git a/src/ahriman/core/upload/upload.py b/src/ahriman/core/upload/upload.py index 030a2650..5f202050 100644 --- a/src/ahriman/core/upload/upload.py +++ b/src/ahriman/core/upload/upload.py @@ -86,13 +86,13 @@ class Upload: section, provider_name = configuration.gettype(target, architecture) provider = UploadSettings.from_option(provider_name) if provider == UploadSettings.Rsync: - from ahriman.core.upload.rsync import Rsync + from ahriman.core.upload import Rsync return Rsync(architecture, configuration, section) if provider == UploadSettings.S3: - from ahriman.core.upload.s3 import S3 + from ahriman.core.upload import S3 return S3(architecture, configuration, section) if provider == UploadSettings.Github: - from ahriman.core.upload.github import Github + from ahriman.core.upload import Github return Github(architecture, configuration, section) return cls(architecture, configuration) # should never happen diff --git a/src/ahriman/models/package.py b/src/ahriman/models/package.py index 4d909cac..0ea7bde1 100644 --- a/src/ahriman/models/package.py +++ b/src/ahriman/models/package.py @@ -29,9 +29,7 @@ from srcinfo.parse import parse_srcinfo # type: ignore from typing import Any, Dict, Iterable, List, Optional, Set, Type from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.aur import AUR -from ahriman.core.alpm.remote.official import Official -from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb +from ahriman.core.alpm.remote import AUR, Official, OfficialSyncdb from ahriman.core.exceptions import InvalidPackageInfo from ahriman.core.util import check_output, full_version from ahriman.models.package_description import PackageDescription diff --git a/src/ahriman/models/remote_source.py b/src/ahriman/models/remote_source.py index 80f12fdd..2ab9c092 100644 --- a/src/ahriman/models/remote_source.py +++ b/src/ahriman/models/remote_source.py @@ -95,7 +95,7 @@ class RemoteSource: Optional[RemoteSource]: generated remote source if any, None otherwise """ if source == PackageSource.AUR: - from ahriman.core.alpm.remote.aur import AUR + from ahriman.core.alpm.remote import AUR return RemoteSource( git_url=AUR.remote_git_url(package_base, repository), web_url=AUR.remote_web_url(package_base), @@ -104,7 +104,7 @@ class RemoteSource: source=source, ) if source == PackageSource.Repository: - from ahriman.core.alpm.remote.official import Official + from ahriman.core.alpm.remote import Official return RemoteSource( git_url=Official.remote_git_url(package_base, repository), web_url=Official.remote_web_url(package_base), diff --git a/src/ahriman/web/middlewares/auth_handler.py b/src/ahriman/web/middlewares/auth_handler.py index 40a029b7..d3a58b7e 100644 --- a/src/ahriman/web/middlewares/auth_handler.py +++ b/src/ahriman/web/middlewares/auth_handler.py @@ -30,7 +30,7 @@ from aiohttp_session.cookie_storage import EncryptedCookieStorage from cryptography import fernet from typing import Optional -from ahriman.core.auth.auth import Auth +from ahriman.core.auth import Auth from ahriman.models.user_access import UserAccess from ahriman.models.user_identity import UserIdentity from ahriman.web.middlewares import HandlerType, MiddlewareType diff --git a/src/ahriman/web/views/base.py b/src/ahriman/web/views/base.py index 1b29acf7..38d04396 100644 --- a/src/ahriman/web/views/base.py +++ b/src/ahriman/web/views/base.py @@ -22,9 +22,9 @@ from __future__ import annotations from aiohttp.web import Request, View from typing import Any, Dict, List, Optional, Type -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.core.spawn import Spawn from ahriman.core.status.watcher import Watcher from ahriman.models.user_access import UserAccess diff --git a/src/ahriman/web/views/service/search.py b/src/ahriman/web/views/service/search.py index 80cb06b7..b2f98570 100644 --- a/src/ahriman/web/views/service/search.py +++ b/src/ahriman/web/views/service/search.py @@ -20,7 +20,7 @@ from aiohttp.web import HTTPNotFound, Response, json_response from typing import Callable, List -from ahriman.core.alpm.remote.aur import AUR +from ahriman.core.alpm.remote import AUR from ahriman.models.aur_package import AURPackage from ahriman.models.user_access import UserAccess from ahriman.web.views.base import BaseView diff --git a/src/ahriman/web/views/user/login.py b/src/ahriman/web/views/user/login.py index 797111b1..eebe731a 100644 --- a/src/ahriman/web/views/user/login.py +++ b/src/ahriman/web/views/user/login.py @@ -48,7 +48,7 @@ class LoginView(BaseView): HTTPMethodNotAllowed: in case if method is used, but OAuth is disabled HTTPUnauthorized: if case of authorization error """ - from ahriman.core.auth.oauth import OAuth + from ahriman.core.auth import OAuth oauth_provider = self.validator if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway diff --git a/src/ahriman/web/web.py b/src/ahriman/web/web.py index 3ceb729b..b40451fe 100644 --- a/src/ahriman/web/web.py +++ b/src/ahriman/web/web.py @@ -23,9 +23,9 @@ import logging from aiohttp import web -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.core.exceptions import InitializeException from ahriman.core.spawn import Spawn from ahriman.core.status.watcher import Watcher diff --git a/tests/ahriman/application/application/conftest.py b/tests/ahriman/application/application/conftest.py index c8a0db4a..06a4078c 100644 --- a/tests/ahriman/application/application/conftest.py +++ b/tests/ahriman/application/application/conftest.py @@ -6,7 +6,7 @@ from ahriman.application.application.application_packages import ApplicationPack from ahriman.application.application.application_properties import ApplicationProperties from ahriman.application.application.application_repository import ApplicationRepository from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite @pytest.fixture @@ -23,7 +23,7 @@ def application_packages(configuration: Configuration, database: SQLite, mocker: ApplicationPackages: application test instance """ mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) return ApplicationPackages("x86_64", configuration, no_report=True, unsafe=False) @@ -42,7 +42,7 @@ def application_properties(configuration: Configuration, database: SQLite, ApplicationProperties: application test instance """ mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) return ApplicationProperties("x86_64", configuration, no_report=True, unsafe=False) @@ -61,5 +61,5 @@ def application_repository(configuration: Configuration, database: SQLite, ApplicationRepository: application test instance """ mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) return ApplicationRepository("x86_64", configuration, no_report=True, unsafe=False) diff --git a/tests/ahriman/application/application/test_application_packages.py b/tests/ahriman/application/application/test_application_packages.py index d41769d4..7863ad6a 100644 --- a/tests/ahriman/application/application/test_application_packages.py +++ b/tests/ahriman/application/application/test_application_packages.py @@ -48,8 +48,8 @@ def test_add_aur(application_packages: ApplicationPackages, package_ahriman: Pac load_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.load") dependencies_mock = mocker.patch( "ahriman.application.application.application_packages.ApplicationPackages._process_dependencies") - build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert") - update_remote_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.remote_update") + build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_insert") + update_remote_mock = mocker.patch("ahriman.core.database.SQLite.remote_update") application_packages._add_aur(package_ahriman.base, set(), False) load_mock.assert_called_once_with( @@ -87,7 +87,7 @@ def test_add_local(application_packages: ApplicationPackages, package_ahriman: P copytree_mock = mocker.patch("shutil.copytree") dependencies_mock = mocker.patch( "ahriman.application.application.application_packages.ApplicationPackages._process_dependencies") - build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert") + build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_insert") application_packages._add_local(package_ahriman.base, set(), False) copytree_mock.assert_called_once_with( @@ -120,8 +120,8 @@ def test_add_repository(application_packages: ApplicationPackages, package_ahrim must add package from official repository """ mocker.patch("ahriman.models.package.Package.from_official", return_value=package_ahriman) - build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert") - update_remote_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.remote_update") + build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_insert") + update_remote_mock = mocker.patch("ahriman.core.database.SQLite.remote_update") application_packages._add_repository(package_ahriman.base) build_queue_mock.assert_called_once_with(package_ahriman) diff --git a/tests/ahriman/application/conftest.py b/tests/ahriman/application/conftest.py index 29e5b72a..600dd92e 100644 --- a/tests/ahriman/application/conftest.py +++ b/tests/ahriman/application/conftest.py @@ -7,7 +7,7 @@ from ahriman.application.ahriman import _parser from ahriman.application.application import Application from ahriman.application.lock import Lock from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite @pytest.fixture @@ -24,7 +24,7 @@ def application(configuration: Configuration, database: SQLite, mocker: MockerFi Application: application test instance """ mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) return Application("x86_64", configuration, no_report=True, unsafe=False) diff --git a/tests/ahriman/application/handlers/test_handler_add.py b/tests/ahriman/application/handlers/test_handler_add.py index adfb1170..f6f87f1e 100644 --- a/tests/ahriman/application/handlers/test_handler_add.py +++ b/tests/ahriman/application/handlers/test_handler_add.py @@ -52,7 +52,7 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration mocker.patch("ahriman.application.application.Application.add") mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman]) Add.run(args, "x86_64", configuration, True, False) @@ -72,7 +72,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.application.application.Application.update", return_value=Result()) mocker.patch("ahriman.application.application.Application.updates") - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Add.run(args, "x86_64", configuration, True, False) check_mock.assert_called_once_with(True, True) diff --git a/tests/ahriman/application/handlers/test_handler_backup.py b/tests/ahriman/application/handlers/test_handler_backup.py index 61604ca3..d5291e83 100644 --- a/tests/ahriman/application/handlers/test_handler_backup.py +++ b/tests/ahriman/application/handlers/test_handler_backup.py @@ -46,7 +46,7 @@ def test_get_paths(configuration: Configuration, mocker: MockerFixture) -> None: mocker.patch.object(RepositoryPaths, "root_owner", (42, 42)) getpwuid_mock = mocker.patch("pwd.getpwuid", return_value=MagicMock()) # well database does not exist so we override it - database_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.database_path", return_value=configuration.path) + database_mock = mocker.patch("ahriman.core.database.SQLite.database_path", return_value=configuration.path) paths = Backup.get_paths(configuration) getpwuid_mock.assert_called_once_with(42) diff --git a/tests/ahriman/application/handlers/test_handler_dump.py b/tests/ahriman/application/handlers/test_handler_dump.py index a8ea9de5..c20dba01 100644 --- a/tests/ahriman/application/handlers/test_handler_dump.py +++ b/tests/ahriman/application/handlers/test_handler_dump.py @@ -11,7 +11,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc must run command """ mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump", return_value=configuration.dump()) diff --git a/tests/ahriman/application/handlers/test_handler_patch.py b/tests/ahriman/application/handlers/test_handler_patch.py index 80b62f4b..d71cb0d8 100644 --- a/tests/ahriman/application/handlers/test_handler_patch.py +++ b/tests/ahriman/application/handlers/test_handler_patch.py @@ -35,7 +35,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc args = _default_args(args) args.action = Action.Update mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_create") + application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create") Patch.run(args, "x86_64", configuration, True, False) application_mock.assert_called_once_with(pytest.helpers.anyvar(int), Path(args.package), args.track) @@ -48,7 +48,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, mocker args = _default_args(args) args.action = Action.List mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_list") + application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_list") Patch.run(args, "x86_64", configuration, True, False) application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, False) @@ -61,7 +61,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock args = _default_args(args) args.action = Action.Remove mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove") + application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_remove") Patch.run(args, "x86_64", configuration, True, False) application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package) @@ -71,9 +71,9 @@ def test_patch_set_list(application: Application, mocker: MockerFixture) -> None """ must list available patches for the command """ - get_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_list", return_value={"ahriman": "patch"}) - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + get_mock = mocker.patch("ahriman.core.database.SQLite.patches_list", return_value={"ahriman": "patch"}) + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Patch.patch_set_list(application, "ahriman", False) get_mock.assert_called_once_with("ahriman") @@ -85,8 +85,8 @@ def test_patch_set_list_empty_exception(application: Application, mocker: Mocker """ must raise ExitCode exception on empty patch list """ - mocker.patch("ahriman.core.database.sqlite.SQLite.patches_list", return_value={}) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + mocker.patch("ahriman.core.database.SQLite.patches_list", return_value={}) + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Patch.patch_set_list(application, "ahriman", True) check_mock.assert_called_once_with(True, True) @@ -99,7 +99,7 @@ def test_patch_set_create(application: Application, package_ahriman: Package, mo mocker.patch("pathlib.Path.mkdir") mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman) mocker.patch("ahriman.core.build_tools.sources.Sources.patch_create", return_value="patch") - create_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_insert") + create_mock = mocker.patch("ahriman.core.database.SQLite.patches_insert") Patch.patch_set_create(application, Path("path"), ["*.patch"]) create_mock.assert_called_once_with(package_ahriman.base, "patch") @@ -109,6 +109,6 @@ def test_patch_set_remove(application: Application, package_ahriman: Package, mo """ must remove patch set for the package """ - remove_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_remove") + remove_mock = mocker.patch("ahriman.core.database.SQLite.patches_remove") Patch.patch_set_remove(application, package_ahriman.base) remove_mock.assert_called_once_with(package_ahriman.base) diff --git a/tests/ahriman/application/handlers/test_handler_rebuild.py b/tests/ahriman/application/handlers/test_handler_rebuild.py index 022a5d6c..db725ec9 100644 --- a/tests/ahriman/application/handlers/test_handler_rebuild.py +++ b/tests/ahriman/application/handlers/test_handler_rebuild.py @@ -40,7 +40,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[package_ahriman]) application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Rebuild.run(args, "x86_64", configuration, True, False) application_packages_mock.assert_called_once_with(None) @@ -73,7 +73,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[package_ahriman]) application_mock = mocker.patch("ahriman.application.application.Application.update") - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Rebuild.run(args, "x86_64", configuration, True, False) application_mock.assert_not_called() @@ -117,7 +117,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con args.dry_run = True mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Rebuild.run(args, "x86_64", configuration, True, False) check_mock.assert_called_once_with(True, True) @@ -133,7 +133,7 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[package_ahriman]) mocker.patch("ahriman.application.application.Application.update", return_value=Result()) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Rebuild.run(args, "x86_64", configuration, True, False) check_mock.assert_has_calls([mock.call(True, False), mock.call(True, True)]) @@ -143,6 +143,6 @@ def test_extract_packages(application: Application, mocker: MockerFixture) -> No """ must extract packages from database """ - packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get") + packages_mock = mocker.patch("ahriman.core.database.SQLite.packages_get") Rebuild.extract_packages(application) packages_mock.assert_called_once_with() diff --git a/tests/ahriman/application/handlers/test_handler_remove_unknown.py b/tests/ahriman/application/handlers/test_handler_remove_unknown.py index 8c99b00a..90858bd5 100644 --- a/tests/ahriman/application/handlers/test_handler_remove_unknown.py +++ b/tests/ahriman/application/handlers/test_handler_remove_unknown.py @@ -49,7 +49,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, pac application_mock = mocker.patch("ahriman.application.application.Application.unknown", return_value=[package_ahriman]) remove_mock = mocker.patch("ahriman.application.application.Application.remove") - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") RemoveUnknown.run(args, "x86_64", configuration, True, False) application_mock.assert_called_once_with() @@ -69,7 +69,7 @@ def test_run_dry_run_verbose(args: argparse.Namespace, configuration: Configurat application_mock = mocker.patch("ahriman.application.application.Application.unknown", return_value=[package_ahriman]) remove_mock = mocker.patch("ahriman.application.application.Application.remove") - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") RemoveUnknown.run(args, "x86_64", configuration, True, False) application_mock.assert_called_once_with() diff --git a/tests/ahriman/application/handlers/test_handler_search.py b/tests/ahriman/application/handlers/test_handler_search.py index 43976b70..5bb5068d 100644 --- a/tests/ahriman/application/handlers/test_handler_search.py +++ b/tests/ahriman/application/handlers/test_handler_search.py @@ -35,11 +35,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, aur_package """ args = _default_args(args) mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - aur_search_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman]) - official_search_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", + aur_search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman]) + official_search_mock = mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[aur_package_ahriman]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") Search.run(args, "x86_64", configuration, True, False) aur_search_mock.assert_called_once_with("ahriman", pacman=pytest.helpers.anyvar(int)) @@ -54,11 +54,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat """ args = _default_args(args) args.exit_code = True - mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[]) - mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", return_value=[]) - mocker.patch("ahriman.core.formatters.printer.Printer.print") + mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[]) + mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[]) + mocker.patch("ahriman.core.formatters.Printer.print") mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Search.run(args, "x86_64", configuration, True, False) check_mock.assert_called_once_with(True, True) @@ -70,10 +70,10 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, aur_pa must run command with sorting """ args = _default_args(args) - mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman]) - mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", return_value=[]) + mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman]) + mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[]) mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort") + sort_mock = mocker.patch("ahriman.application.handlers.Search.sort") Search.run(args, "x86_64", configuration, True, False) sort_mock.assert_has_calls([ @@ -89,10 +89,10 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, aur """ args = _default_args(args) args.sort_by = "field" - mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman]) - mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", return_value=[]) + mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman]) + mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[]) mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort") + sort_mock = mocker.patch("ahriman.application.handlers.Search.sort") Search.run(args, "x86_64", configuration, True, False) sort_mock.assert_has_calls([ diff --git a/tests/ahriman/application/handlers/test_handler_setup.py b/tests/ahriman/application/handlers/test_handler_setup.py index c7eab2fd..596e10c6 100644 --- a/tests/ahriman/application/handlers/test_handler_setup.py +++ b/tests/ahriman/application/handlers/test_handler_setup.py @@ -39,11 +39,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc """ args = _default_args(args) mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_ahriman") - devtools_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_devtools") - makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_makepkg") - sudo_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_sudo") - executable_mock = mocker.patch("ahriman.application.handlers.setup.Setup.executable_create") + ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_ahriman") + devtools_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_devtools") + makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_makepkg") + sudo_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_sudo") + executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create") init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init") paths = RepositoryPaths(configuration.getpath("repository", "root"), "x86_64") diff --git a/tests/ahriman/application/handlers/test_handler_status.py b/tests/ahriman/application/handlers/test_handler_status.py index 60887047..d1328fb8 100644 --- a/tests/ahriman/application/handlers/test_handler_status.py +++ b/tests/ahriman/application/handlers/test_handler_status.py @@ -38,8 +38,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, package_ahr packages_mock = mocker.patch("ahriman.core.status.client.Client.get", return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)), (package_python_schedule, BuildStatus(BuildStatusEnum.Failed))]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") Status.run(args, "x86_64", configuration, True, False) application_mock.assert_called_once_with() @@ -57,7 +57,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.core.status.client.Client.get_self") mocker.patch("ahriman.core.status.client.Client.get", return_value=[]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Status.run(args, "x86_64", configuration, True, False) check_mock.assert_called_once_with(True, True) @@ -73,7 +73,7 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, pac mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.core.status.client.Client.get", return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))]) - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") Status.run(args, "x86_64", configuration, True, False) print_mock.assert_has_calls([mock.call(True) for _ in range(2)]) @@ -105,7 +105,7 @@ def test_run_by_status(args: argparse.Namespace, configuration: Configuration, p return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)), (package_python_schedule, BuildStatus(BuildStatusEnum.Failed))]) mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") Status.run(args, "x86_64", configuration, True, False) print_mock.assert_has_calls([mock.call(False) for _ in range(2)]) diff --git a/tests/ahriman/application/handlers/test_handler_unsafe_commands.py b/tests/ahriman/application/handlers/test_handler_unsafe_commands.py index dd6e77a2..ca76f91c 100644 --- a/tests/ahriman/application/handlers/test_handler_unsafe_commands.py +++ b/tests/ahriman/application/handlers/test_handler_unsafe_commands.py @@ -30,7 +30,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc args = _default_args(args) commands_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.get_unsafe_commands", return_value=["command"]) - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") UnsafeCommands.run(args, "x86_64", configuration, True, False) commands_mock.assert_called_once_with(pytest.helpers.anyvar(int)) @@ -56,7 +56,7 @@ def test_check_unsafe(mocker: MockerFixture) -> None: """ must check if command is unsafe """ - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") UnsafeCommands.check_unsafe("repo-clean", ["repo-clean"], _parser()) check_mock.assert_called_once_with(True, True) @@ -65,7 +65,7 @@ def test_check_unsafe_safe(mocker: MockerFixture) -> None: """ must check if command is safe """ - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") UnsafeCommands.check_unsafe("package-status", ["repo-clean"], _parser()) check_mock.assert_called_once_with(True, False) diff --git a/tests/ahriman/application/handlers/test_handler_update.py b/tests/ahriman/application/handlers/test_handler_update.py index 87f2c714..c3abce2c 100644 --- a/tests/ahriman/application/handlers/test_handler_update.py +++ b/tests/ahriman/application/handlers/test_handler_update.py @@ -41,7 +41,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, result.add_success(package_ahriman) mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman]) Update.run(args, "x86_64", configuration, True, False) @@ -60,7 +60,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat args.dry_run = True mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.application.application.Application.updates", return_value=[]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Update.run(args, "x86_64", configuration, True, False) check_mock.assert_called_once_with(True, True) @@ -76,7 +76,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") mocker.patch("ahriman.application.application.Application.update", return_value=Result()) mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Update.run(args, "x86_64", configuration, True, False) check_mock.assert_has_calls([mock.call(True, False), mock.call(True, True)]) @@ -90,7 +90,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, moc args.dry_run = True mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create") application_mock = mocker.patch("ahriman.application.application.Application.update") - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") updates_mock = mocker.patch("ahriman.application.application.Application.updates") Update.run(args, "x86_64", configuration, True, False) diff --git a/tests/ahriman/application/handlers/test_handler_users.py b/tests/ahriman/application/handlers/test_handler_users.py index 4c387efa..473c5c73 100644 --- a/tests/ahriman/application/handlers/test_handler_users.py +++ b/tests/ahriman/application/handlers/test_handler_users.py @@ -6,7 +6,7 @@ from pytest_mock import MockerFixture from ahriman.application.handlers import Users from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import InitializeException from ahriman.models.action import Action from ahriman.models.user import User @@ -39,13 +39,13 @@ def test_run(args: argparse.Namespace, configuration: Configuration, database: S """ args = _default_args(args) user = User(args.username, args.password, args.role) - 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.user.User.hash_password", return_value=user) get_auth_configuration_mock = mocker.patch("ahriman.application.handlers.Users.configuration_get") create_configuration_mock = mocker.patch("ahriman.application.handlers.Users.configuration_create") create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user) get_salt_mock = mocker.patch("ahriman.application.handlers.Users.get_salt", return_value="salt") - update_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.user_update") + update_mock = mocker.patch("ahriman.core.database.SQLite.user_update") Users.run(args, "x86_64", configuration, True, False) get_auth_configuration_mock.assert_called_once_with(configuration.include) @@ -63,9 +63,9 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, databa """ args = _default_args(args) args.action = Action.List - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") - list_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.user_list", return_value=[user]) + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") + list_mock = mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[user]) Users.run(args, "x86_64", configuration, True, False) list_mock.assert_called_once_with("user", args.role) @@ -80,9 +80,9 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat args = _default_args(args) args.action = Action.List args.exit_code = True - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) - mocker.patch("ahriman.core.database.sqlite.SQLite.user_list", return_value=[]) - check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty") + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) + mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[]) + check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty") Users.run(args, "x86_64", configuration, True, False) check_mock.assert_called_once_with(True, True) @@ -95,8 +95,8 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, data """ args = _default_args(args) args.action = Action.Remove - mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database) - remove_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.user_remove") + mocker.patch("ahriman.core.database.SQLite.load", return_value=database) + remove_mock = mocker.patch("ahriman.core.database.SQLite.user_remove") Users.run(args, "x86_64", configuration, True, False) remove_mock.assert_called_once_with(args.username) diff --git a/tests/ahriman/conftest.py b/tests/ahriman/conftest.py index 3ddb1286..df6cb436 100644 --- a/tests/ahriman/conftest.py +++ b/tests/ahriman/conftest.py @@ -7,9 +7,9 @@ from typing import Any, Dict, Type, TypeVar from unittest.mock import MagicMock from ahriman.core.alpm.pacman import Pacman -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.core.spawn import Spawn from ahriman.core.status.watcher import Watcher from ahriman.models.aur_package import AURPackage diff --git a/tests/ahriman/core/alpm/remote/conftest.py b/tests/ahriman/core/alpm/remote/conftest.py index 072a6307..0d1273ec 100644 --- a/tests/ahriman/core/alpm/remote/conftest.py +++ b/tests/ahriman/core/alpm/remote/conftest.py @@ -1,9 +1,6 @@ import pytest -from ahriman.core.alpm.remote.aur import AUR -from ahriman.core.alpm.remote.official import Official -from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb -from ahriman.core.alpm.remote.remote import Remote +from ahriman.core.alpm.remote import AUR, Official, OfficialSyncdb, Remote @pytest.fixture diff --git a/tests/ahriman/core/alpm/remote/test_aur.py b/tests/ahriman/core/alpm/remote/test_aur.py index fa87a027..4698c5f0 100644 --- a/tests/ahriman/core/alpm/remote/test_aur.py +++ b/tests/ahriman/core/alpm/remote/test_aur.py @@ -7,7 +7,7 @@ from pytest_mock import MockerFixture from unittest.mock import MagicMock from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.aur import AUR +from ahriman.core.alpm.remote import AUR from ahriman.core.exceptions import InvalidPackageInfo from ahriman.models.aur_package import AURPackage @@ -131,7 +131,7 @@ def test_package_info(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacman, """ must make request for info """ - request_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.make_request", return_value=[aur_package_ahriman]) + request_mock = mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[aur_package_ahriman]) assert aur.package_info(aur_package_ahriman.name, pacman=pacman) == aur_package_ahriman request_mock.assert_called_once_with("info", aur_package_ahriman.name) @@ -140,6 +140,6 @@ def test_package_search(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacma """ must make request for search """ - request_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.make_request", return_value=[aur_package_ahriman]) + request_mock = mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[aur_package_ahriman]) assert aur.package_search(aur_package_ahriman.name, pacman=pacman) == [aur_package_ahriman] request_mock.assert_called_once_with("search", aur_package_ahriman.name, by="name-desc") diff --git a/tests/ahriman/core/alpm/remote/test_official.py b/tests/ahriman/core/alpm/remote/test_official.py index b453d91d..7d9716fd 100644 --- a/tests/ahriman/core/alpm/remote/test_official.py +++ b/tests/ahriman/core/alpm/remote/test_official.py @@ -7,7 +7,7 @@ from pytest_mock import MockerFixture from unittest.mock import MagicMock from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.official import Official +from ahriman.core.alpm.remote import Official from ahriman.core.exceptions import InvalidPackageInfo from ahriman.models.aur_package import AURPackage @@ -111,7 +111,7 @@ def test_package_info(official: Official, aur_package_akonadi: AURPackage, pacma """ must make request for info """ - request_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.make_request", + request_mock = mocker.patch("ahriman.core.alpm.remote.Official.make_request", return_value=[aur_package_akonadi]) assert official.package_info(aur_package_akonadi.name, pacman=pacman) == aur_package_akonadi request_mock.assert_called_once_with(aur_package_akonadi.name, by="name") @@ -122,7 +122,7 @@ def test_package_search(official: Official, aur_package_akonadi: AURPackage, pac """ must make request for search """ - request_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.make_request", + request_mock = mocker.patch("ahriman.core.alpm.remote.Official.make_request", return_value=[aur_package_akonadi]) assert official.package_search(aur_package_akonadi.name, pacman=pacman) == [aur_package_akonadi] request_mock.assert_called_once_with(aur_package_akonadi.name, by="q") diff --git a/tests/ahriman/core/alpm/remote/test_official_syncdb.py b/tests/ahriman/core/alpm/remote/test_official_syncdb.py index 0c00b66f..1ef0e6a4 100644 --- a/tests/ahriman/core/alpm/remote/test_official_syncdb.py +++ b/tests/ahriman/core/alpm/remote/test_official_syncdb.py @@ -1,7 +1,7 @@ from pytest_mock import MockerFixture from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb +from ahriman.core.alpm.remote import OfficialSyncdb from ahriman.models.aur_package import AURPackage diff --git a/tests/ahriman/core/alpm/remote/test_remote.py b/tests/ahriman/core/alpm/remote/test_remote.py index e2a26fa0..75687488 100644 --- a/tests/ahriman/core/alpm/remote/test_remote.py +++ b/tests/ahriman/core/alpm/remote/test_remote.py @@ -4,7 +4,7 @@ from pytest_mock import MockerFixture from unittest import mock from ahriman.core.alpm.pacman import Pacman -from ahriman.core.alpm.remote.remote import Remote +from ahriman.core.alpm.remote import Remote from ahriman.models.aur_package import AURPackage @@ -12,7 +12,7 @@ def test_info(pacman: Pacman, mocker: MockerFixture) -> None: """ must call info method """ - info_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.package_info") + info_mock = mocker.patch("ahriman.core.alpm.remote.Remote.package_info") Remote.info("ahriman", pacman=pacman) info_mock.assert_called_once_with("ahriman", pacman=pacman) @@ -22,7 +22,7 @@ def test_multisearch(aur_package_ahriman: AURPackage, pacman: Pacman, mocker: Mo must search in AUR with multiple words """ terms = ["ahriman", "is", "cool"] - search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search", return_value=[aur_package_ahriman]) + search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman]) assert Remote.multisearch(*terms, pacman=pacman) == [aur_package_ahriman] search_mock.assert_has_calls([mock.call("ahriman", pacman=pacman), mock.call("cool", pacman=pacman)]) @@ -33,7 +33,7 @@ def test_multisearch_empty(pacman: Pacman, mocker: MockerFixture) -> None: must return empty list if no long terms supplied """ terms = ["it", "is"] - search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search") + search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search") assert Remote.multisearch(*terms, pacman=pacman) == [] search_mock.assert_not_called() @@ -43,7 +43,7 @@ def test_multisearch_single(aur_package_ahriman: AURPackage, pacman: Pacman, moc """ must search in AUR with one word """ - search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search", return_value=[aur_package_ahriman]) + search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman]) assert Remote.multisearch("ahriman", pacman=pacman) == [aur_package_ahriman] search_mock.assert_called_once_with("ahriman", pacman=pacman) @@ -68,7 +68,7 @@ def test_search(pacman: Pacman, mocker: MockerFixture) -> None: """ must call search method """ - search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.package_search") + search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.package_search") Remote.search("ahriman", pacman=pacman) search_mock.assert_called_once_with("ahriman", pacman=pacman) diff --git a/tests/ahriman/core/auth/conftest.py b/tests/ahriman/core/auth/conftest.py index c8a5df20..6c60788b 100644 --- a/tests/ahriman/core/auth/conftest.py +++ b/tests/ahriman/core/auth/conftest.py @@ -1,9 +1,8 @@ import pytest -from ahriman.core.auth.mapping import Mapping -from ahriman.core.auth.oauth import OAuth +from ahriman.core.auth import Mapping, OAuth from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite @pytest.fixture diff --git a/tests/ahriman/core/auth/test_auth.py b/tests/ahriman/core/auth/test_auth.py index e3e1bed3..2e94b899 100644 --- a/tests/ahriman/core/auth/test_auth.py +++ b/tests/ahriman/core/auth/test_auth.py @@ -1,8 +1,6 @@ -from ahriman.core.auth.auth import Auth -from ahriman.core.auth.mapping import Mapping -from ahriman.core.auth.oauth import OAuth +from ahriman.core.auth import Auth, Mapping, OAuth 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.models.user_access import UserAccess diff --git a/tests/ahriman/core/auth/test_mapping.py b/tests/ahriman/core/auth/test_mapping.py index 27eada70..0f218f8e 100644 --- a/tests/ahriman/core/auth/test_mapping.py +++ b/tests/ahriman/core/auth/test_mapping.py @@ -1,6 +1,6 @@ from pytest_mock import MockerFixture -from ahriman.core.auth.mapping import Mapping +from ahriman.core.auth import Mapping from ahriman.models.user import User from ahriman.models.user_access import UserAccess @@ -11,7 +11,7 @@ async def test_check_credentials(mapping: Mapping, user: User, mocker: MockerFix """ current_password = user.password user = user.hash_password(mapping.salt) - 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 mapping.check_credentials(user.username, current_password) # here password is hashed so it is invalid assert not await mapping.check_credentials(user.username, user.password) @@ -37,7 +37,7 @@ def test_get_user(mapping: Mapping, user: User, mocker: MockerFixture) -> None: """ must return user from storage by username """ - mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user) + mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user) assert mapping.get_user(user.username) == user @@ -45,7 +45,7 @@ def test_get_user_normalized(mapping: Mapping, user: User, mocker: MockerFixture """ must return user from storage by username case-insensitive """ - mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user) + mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user) assert mapping.get_user(user.username.upper()) == user @@ -60,7 +60,7 @@ async def test_known_username(mapping: Mapping, user: User, mocker: MockerFixtur """ must allow only known users """ - 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 mapping.known_username(user.username) @@ -69,7 +69,7 @@ async def test_known_username_unknown(mapping: Mapping, user: User, mocker: Mock must not allow only known users """ assert not await mapping.known_username(None) - mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=None) + mocker.patch("ahriman.core.database.SQLite.user_get", return_value=None) assert not await mapping.known_username(user.password) @@ -77,6 +77,6 @@ async def test_verify_access(mapping: Mapping, user: User, mocker: MockerFixture """ must verify user access """ - 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 mapping.verify_access(user.username, user.access, None) assert not await mapping.verify_access(user.username, UserAccess.Write, None) diff --git a/tests/ahriman/core/auth/test_oauth.py b/tests/ahriman/core/auth/test_oauth.py index 92150c79..cf454815 100644 --- a/tests/ahriman/core/auth/test_oauth.py +++ b/tests/ahriman/core/auth/test_oauth.py @@ -3,7 +3,7 @@ import pytest from pytest_mock import MockerFixture -from ahriman.core.auth.oauth import OAuth +from ahriman.core.auth import OAuth from ahriman.core.exceptions import InvalidOption diff --git a/tests/ahriman/core/build_tools/test_task.py b/tests/ahriman/core/build_tools/test_task.py index 0df00c02..312d2af2 100644 --- a/tests/ahriman/core/build_tools/test_task.py +++ b/tests/ahriman/core/build_tools/test_task.py @@ -2,7 +2,7 @@ from pathlib import Path from pytest_mock import MockerFixture from ahriman.core.build_tools.task import Task -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite def test_build(task_ahriman: Task, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/core/database/operations/test_auth_operations.py b/tests/ahriman/core/database/operations/test_auth_operations.py index b265bb0f..e488a3ec 100644 --- a/tests/ahriman/core/database/operations/test_auth_operations.py +++ b/tests/ahriman/core/database/operations/test_auth_operations.py @@ -1,4 +1,4 @@ -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.models.user import User from ahriman.models.user_access import UserAccess diff --git a/tests/ahriman/core/database/operations/test_build_operations.py b/tests/ahriman/core/database/operations/test_build_operations.py index b231b5c7..dfe9dada 100644 --- a/tests/ahriman/core/database/operations/test_build_operations.py +++ b/tests/ahriman/core/database/operations/test_build_operations.py @@ -1,4 +1,4 @@ -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.models.package import Package diff --git a/tests/ahriman/core/database/operations/test_operations.py b/tests/ahriman/core/database/operations/test_operations.py index facd7a02..e6362c5f 100644 --- a/tests/ahriman/core/database/operations/test_operations.py +++ b/tests/ahriman/core/database/operations/test_operations.py @@ -3,7 +3,7 @@ import sqlite3 from pytest_mock import MockerFixture from unittest.mock import MagicMock -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite def test_factory(database: SQLite) -> None: diff --git a/tests/ahriman/core/database/operations/test_package_operations.py b/tests/ahriman/core/database/operations/test_package_operations.py index 4181a2c2..cbdd1dcc 100644 --- a/tests/ahriman/core/database/operations/test_package_operations.py +++ b/tests/ahriman/core/database/operations/test_package_operations.py @@ -4,7 +4,7 @@ from pytest_mock import MockerFixture from sqlite3 import Connection from unittest import mock -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.models.build_status import BuildStatus, BuildStatusEnum from ahriman.models.package import Package from ahriman.models.package_source import PackageSource @@ -97,8 +97,8 @@ def test_package_remove(database: SQLite, package_ahriman: Package, mocker: Mock """ must totally remove package from the database """ - remove_package_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_package_base") - remove_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_packages") + remove_package_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_package_base") + remove_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_packages") database.package_remove(package_ahriman.base) remove_package_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.base) @@ -110,10 +110,10 @@ def test_package_update(database: SQLite, package_ahriman: Package, mocker: Mock must update package status """ status = BuildStatus() - insert_base_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_base") - insert_status_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_status") - insert_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_packages") - remove_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_packages") + insert_base_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_base") + insert_status_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_status") + insert_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_packages") + remove_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_packages") database.package_update(package_ahriman, status) insert_base_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman) @@ -127,10 +127,10 @@ def test_packages_get(database: SQLite, package_ahriman: Package, mocker: Mocker """ must return all packages """ - select_bases_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_package_bases", + select_bases_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_package_bases", return_value={package_ahriman.base: package_ahriman}) - select_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_packages") - select_statuses_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_statuses") + select_packages_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_packages") + select_statuses_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_statuses") database.packages_get() select_bases_mock.assert_called_once_with(pytest.helpers.anyvar(int)) diff --git a/tests/ahriman/core/database/operations/test_patch_operations.py b/tests/ahriman/core/database/operations/test_patch_operations.py index 72fb930a..adc14e3e 100644 --- a/tests/ahriman/core/database/operations/test_patch_operations.py +++ b/tests/ahriman/core/database/operations/test_patch_operations.py @@ -1,4 +1,4 @@ -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.models.package import Package diff --git a/tests/ahriman/core/database/test_sqlite.py b/tests/ahriman/core/database/test_sqlite.py index 378d18f6..ff72c990 100644 --- a/tests/ahriman/core/database/test_sqlite.py +++ b/tests/ahriman/core/database/test_sqlite.py @@ -3,14 +3,14 @@ import pytest from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite def test_load(configuration: Configuration, mocker: MockerFixture) -> None: """ must correctly load instance """ - init_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.init") + init_mock = mocker.patch("ahriman.core.database.SQLite.init") SQLite.load(configuration) init_mock.assert_called_once_with(configuration) diff --git a/tests/ahriman/core/formatters/conftest.py b/tests/ahriman/core/formatters/conftest.py index 4ebfc5c4..d362e40d 100644 --- a/tests/ahriman/core/formatters/conftest.py +++ b/tests/ahriman/core/formatters/conftest.py @@ -1,12 +1,6 @@ import pytest -from ahriman.core.formatters.aur_printer import AurPrinter -from ahriman.core.formatters.configuration_printer import ConfigurationPrinter -from ahriman.core.formatters.package_printer import PackagePrinter -from ahriman.core.formatters.status_printer import StatusPrinter -from ahriman.core.formatters.string_printer import StringPrinter -from ahriman.core.formatters.update_printer import UpdatePrinter -from ahriman.core.formatters.user_printer import UserPrinter +from ahriman.core.formatters import AurPrinter, ConfigurationPrinter, PackagePrinter, StatusPrinter, StringPrinter, UpdatePrinter, UserPrinter from ahriman.models.aur_package import AURPackage from ahriman.models.build_status import BuildStatus from ahriman.models.package import Package diff --git a/tests/ahriman/core/formatters/test_aur_printer.py b/tests/ahriman/core/formatters/test_aur_printer.py index 1678fcd9..fc4bf8ba 100644 --- a/tests/ahriman/core/formatters/test_aur_printer.py +++ b/tests/ahriman/core/formatters/test_aur_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.aur_printer import AurPrinter +from ahriman.core.formatters import AurPrinter def test_properties(aur_package_ahriman_printer: AurPrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_build_printer.py b/tests/ahriman/core/formatters/test_build_printer.py index fd5ac9e4..54debc14 100644 --- a/tests/ahriman/core/formatters/test_build_printer.py +++ b/tests/ahriman/core/formatters/test_build_printer.py @@ -1,6 +1,6 @@ import pytest -from ahriman.core.formatters.build_printer import BuildPrinter +from ahriman.core.formatters import BuildPrinter from ahriman.models.package import Package diff --git a/tests/ahriman/core/formatters/test_configuration_printer.py b/tests/ahriman/core/formatters/test_configuration_printer.py index c82dcbf7..55797d2f 100644 --- a/tests/ahriman/core/formatters/test_configuration_printer.py +++ b/tests/ahriman/core/formatters/test_configuration_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.configuration_printer import ConfigurationPrinter +from ahriman.core.formatters import ConfigurationPrinter def test_properties(configuration_printer: ConfigurationPrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_package_printer.py b/tests/ahriman/core/formatters/test_package_printer.py index fa6f77df..443109dc 100644 --- a/tests/ahriman/core/formatters/test_package_printer.py +++ b/tests/ahriman/core/formatters/test_package_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.package_printer import PackagePrinter +from ahriman.core.formatters import PackagePrinter def test_properties(package_ahriman_printer: PackagePrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_printer.py b/tests/ahriman/core/formatters/test_printer.py index 6532d646..530dccac 100644 --- a/tests/ahriman/core/formatters/test_printer.py +++ b/tests/ahriman/core/formatters/test_printer.py @@ -1,7 +1,7 @@ from unittest.mock import MagicMock -from ahriman.core.formatters.package_printer import PackagePrinter -from ahriman.core.formatters.printer import Printer +from ahriman.core.formatters import PackagePrinter +from ahriman.core.formatters import Printer def test_print(package_ahriman_printer: PackagePrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_status_printer.py b/tests/ahriman/core/formatters/test_status_printer.py index 66849c93..22de6d23 100644 --- a/tests/ahriman/core/formatters/test_status_printer.py +++ b/tests/ahriman/core/formatters/test_status_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.status_printer import StatusPrinter +from ahriman.core.formatters import StatusPrinter def test_properties(status_printer: StatusPrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_string_printer.py b/tests/ahriman/core/formatters/test_string_printer.py index b2e4ddc2..5aa0c6f1 100644 --- a/tests/ahriman/core/formatters/test_string_printer.py +++ b/tests/ahriman/core/formatters/test_string_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.string_printer import StringPrinter +from ahriman.core.formatters import StringPrinter def test_properties(string_printer: StringPrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_update_printer.py b/tests/ahriman/core/formatters/test_update_printer.py index ad37c9fc..eacdc61e 100644 --- a/tests/ahriman/core/formatters/test_update_printer.py +++ b/tests/ahriman/core/formatters/test_update_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.update_printer import UpdatePrinter +from ahriman.core.formatters import UpdatePrinter def test_properties(update_printer: UpdatePrinter) -> None: diff --git a/tests/ahriman/core/formatters/test_user_printer.py b/tests/ahriman/core/formatters/test_user_printer.py index 99b81a4f..5558a990 100644 --- a/tests/ahriman/core/formatters/test_user_printer.py +++ b/tests/ahriman/core/formatters/test_user_printer.py @@ -1,4 +1,4 @@ -from ahriman.core.formatters.user_printer import UserPrinter +from ahriman.core.formatters import UserPrinter def test_properties(user_printer: UserPrinter) -> None: diff --git a/tests/ahriman/core/report/test_console.py b/tests/ahriman/core/report/test_console.py index ade89c3f..7f2b64c0 100644 --- a/tests/ahriman/core/report/test_console.py +++ b/tests/ahriman/core/report/test_console.py @@ -2,7 +2,7 @@ from pytest_mock import MockerFixture from unittest import mock from ahriman.core.configuration import Configuration -from ahriman.core.report.console import Console +from ahriman.core.report import Console from ahriman.models.package import Package from ahriman.models.result import Result @@ -12,7 +12,7 @@ def test_generate(configuration: Configuration, result: Result, package_python_s """ must print result to stdout """ - print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print") + print_mock = mocker.patch("ahriman.core.formatters.Printer.print") result.add_failed(package_python_schedule) report = Console("x86_64", configuration, "console") diff --git a/tests/ahriman/core/report/test_email.py b/tests/ahriman/core/report/test_email.py index f215702d..fc2a046d 100644 --- a/tests/ahriman/core/report/test_email.py +++ b/tests/ahriman/core/report/test_email.py @@ -3,7 +3,7 @@ import pytest from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration -from ahriman.core.report.email import Email +from ahriman.core.report import Email from ahriman.models.package import Package from ahriman.models.result import Result @@ -90,7 +90,7 @@ def test_generate(configuration: Configuration, package_ahriman: Package, mocker """ must generate report """ - send_mock = mocker.patch("ahriman.core.report.email.Email._send") + send_mock = mocker.patch("ahriman.core.report.Email._send") report = Email("x86_64", configuration, "email") report.generate([package_ahriman], Result()) @@ -102,7 +102,7 @@ def test_generate_with_built(configuration: Configuration, package_ahriman: Pack """ must generate report with built packages """ - send_mock = mocker.patch("ahriman.core.report.email.Email._send") + send_mock = mocker.patch("ahriman.core.report.Email._send") report = Email("x86_64", configuration, "email") report.generate([package_ahriman], result) @@ -117,7 +117,7 @@ def test_generate_with_built_and_full_path( """ must generate report with built packages and full packages lists """ - send_mock = mocker.patch("ahriman.core.report.email.Email._send") + send_mock = mocker.patch("ahriman.core.report.Email._send") report = Email("x86_64", configuration, "email") report.full_template_path = report.template_path @@ -130,7 +130,7 @@ def test_generate_no_empty(configuration: Configuration, package_ahriman: Packag must not generate report with built packages if no_empty_report is set """ configuration.set_option("email", "no_empty_report", "yes") - send_mock = mocker.patch("ahriman.core.report.email.Email._send") + send_mock = mocker.patch("ahriman.core.report.Email._send") report = Email("x86_64", configuration, "email") report.generate([package_ahriman], Result()) @@ -143,7 +143,7 @@ def test_generate_no_empty_with_built(configuration: Configuration, package_ahri must generate report with built packages if no_empty_report is set """ configuration.set_option("email", "no_empty_report", "yes") - send_mock = mocker.patch("ahriman.core.report.email.Email._send") + send_mock = mocker.patch("ahriman.core.report.Email._send") report = Email("x86_64", configuration, "email") report.generate([package_ahriman], result) diff --git a/tests/ahriman/core/report/test_html.py b/tests/ahriman/core/report/test_html.py index b57e3b60..bb8c540e 100644 --- a/tests/ahriman/core/report/test_html.py +++ b/tests/ahriman/core/report/test_html.py @@ -3,7 +3,7 @@ import pytest from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration -from ahriman.core.report.html import HTML +from ahriman.core.report import HTML from ahriman.models.package import Package diff --git a/tests/ahriman/core/report/test_jinja_template.py b/tests/ahriman/core/report/test_jinja_template.py index 93deccbf..7a9783c0 100644 --- a/tests/ahriman/core/report/test_jinja_template.py +++ b/tests/ahriman/core/report/test_jinja_template.py @@ -1,5 +1,5 @@ from ahriman.core.configuration import Configuration -from ahriman.core.report.jinja_template import JinjaTemplate +from ahriman.core.report import JinjaTemplate from ahriman.models.package import Package from ahriman.models.result import Result diff --git a/tests/ahriman/core/report/test_report.py b/tests/ahriman/core/report/test_report.py index 58099264..fdc46e87 100644 --- a/tests/ahriman/core/report/test_report.py +++ b/tests/ahriman/core/report/test_report.py @@ -4,7 +4,7 @@ from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration from ahriman.core.exceptions import ReportFailed -from ahriman.core.report.report import Report +from ahriman.core.report import Report from ahriman.models.report_settings import ReportSettings from ahriman.models.result import Result @@ -13,7 +13,7 @@ def test_report_failure(configuration: Configuration, mocker: MockerFixture) -> """ must raise ReportFailed on errors """ - mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception()) + mocker.patch("ahriman.core.report.HTML.generate", side_effect=Exception()) with pytest.raises(ReportFailed): Report.load("x86_64", configuration, "html").run([], Result()) @@ -23,7 +23,7 @@ def test_report_dummy(configuration: Configuration, result: Result, mocker: Mock must construct dummy report class """ mocker.patch("ahriman.models.report_settings.ReportSettings.from_option", return_value=ReportSettings.Disabled) - report_mock = mocker.patch("ahriman.core.report.report.Report.generate") + report_mock = mocker.patch("ahriman.core.report.Report.generate") Report.load("x86_64", configuration, "disabled").run([], result) report_mock.assert_called_once_with([], result) @@ -32,7 +32,7 @@ def test_report_console(configuration: Configuration, result: Result, mocker: Mo """ must generate console report """ - report_mock = mocker.patch("ahriman.core.report.console.Console.generate") + report_mock = mocker.patch("ahriman.core.report.Console.generate") Report.load("x86_64", configuration, "console").run([], result) report_mock.assert_called_once_with([], result) @@ -41,7 +41,7 @@ def test_report_email(configuration: Configuration, result: Result, mocker: Mock """ must generate email report """ - report_mock = mocker.patch("ahriman.core.report.email.Email.generate") + report_mock = mocker.patch("ahriman.core.report.Email.generate") Report.load("x86_64", configuration, "email").run([], result) report_mock.assert_called_once_with([], result) @@ -50,7 +50,7 @@ def test_report_html(configuration: Configuration, result: Result, mocker: Mocke """ must generate html report """ - report_mock = mocker.patch("ahriman.core.report.html.HTML.generate") + report_mock = mocker.patch("ahriman.core.report.HTML.generate") Report.load("x86_64", configuration, "html").run([], result) report_mock.assert_called_once_with([], result) @@ -59,6 +59,6 @@ def test_report_telegram(configuration: Configuration, result: Result, mocker: M """ must generate telegram report """ - report_mock = mocker.patch("ahriman.core.report.telegram.Telegram.generate") + report_mock = mocker.patch("ahriman.core.report.Telegram.generate") Report.load("x86_64", configuration, "telegram").run([], result) report_mock.assert_called_once_with([], result) diff --git a/tests/ahriman/core/report/test_telegram.py b/tests/ahriman/core/report/test_telegram.py index 92645595..2809c9d9 100644 --- a/tests/ahriman/core/report/test_telegram.py +++ b/tests/ahriman/core/report/test_telegram.py @@ -5,7 +5,7 @@ from pytest_mock import MockerFixture from unittest import mock from ahriman.core.configuration import Configuration -from ahriman.core.report.telegram import Telegram +from ahriman.core.report import Telegram from ahriman.models.package import Package from ahriman.models.result import Result @@ -50,7 +50,7 @@ def test_generate(configuration: Configuration, package_ahriman: Package, result """ must generate report """ - send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send") + send_mock = mocker.patch("ahriman.core.report.Telegram._send") report = Telegram("x86_64", configuration, "telegram") report.generate([package_ahriman], result) @@ -62,8 +62,8 @@ def test_generate_big_text(configuration: Configuration, package_ahriman: Packag """ must generate report with big text """ - mocker.patch("ahriman.core.report.jinja_template.JinjaTemplate.make_html", return_value="a\n" * 4096) - send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send") + mocker.patch("ahriman.core.report.JinjaTemplate.make_html", return_value="a\n" * 4096) + send_mock = mocker.patch("ahriman.core.report.Telegram._send") report = Telegram("x86_64", configuration, "telegram") report.generate([package_ahriman], result) @@ -76,7 +76,7 @@ def test_generate_no_empty(configuration: Configuration, package_ahriman: Packag """ must generate report """ - send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send") + send_mock = mocker.patch("ahriman.core.report.Telegram._send") report = Telegram("x86_64", configuration, "telegram") report.generate([package_ahriman], Result()) diff --git a/tests/ahriman/core/repository/conftest.py b/tests/ahriman/core/repository/conftest.py index b78e5cf8..9936e42c 100644 --- a/tests/ahriman/core/repository/conftest.py +++ b/tests/ahriman/core/repository/conftest.py @@ -3,7 +3,7 @@ import pytest from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.repository import Repository from ahriman.core.repository.cleaner import Cleaner from ahriman.core.repository.executor import Executor diff --git a/tests/ahriman/core/repository/test_cleaner.py b/tests/ahriman/core/repository/test_cleaner.py index 60eb6189..4054f3f6 100644 --- a/tests/ahriman/core/repository/test_cleaner.py +++ b/tests/ahriman/core/repository/test_cleaner.py @@ -72,6 +72,6 @@ def test_clear_queue(cleaner: Cleaner, mocker: MockerFixture) -> None: """ must clear queued packages from the database """ - clear_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear") + clear_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear") cleaner.clear_queue() clear_mock.assert_called_once_with(None) diff --git a/tests/ahriman/core/repository/test_executor.py b/tests/ahriman/core/repository/test_executor.py index c1c24075..590ab77e 100644 --- a/tests/ahriman/core/repository/test_executor.py +++ b/tests/ahriman/core/repository/test_executor.py @@ -5,9 +5,9 @@ from pytest_mock import MockerFixture from unittest import mock from unittest.mock import MagicMock -from ahriman.core.report.report import Report +from ahriman.core.report import Report from ahriman.core.repository.executor import Executor -from ahriman.core.upload.upload import Upload +from ahriman.core.upload import Upload from ahriman.models.package import Package @@ -64,8 +64,8 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman]) tree_clear_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_clear") repo_remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove") - build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear") - patches_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_remove") + build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear") + patches_mock = mocker.patch("ahriman.core.database.SQLite.patches_remove") status_client_mock = mocker.patch("ahriman.core.status.client.Client.remove") executor.process_remove([package_ahriman.base]) @@ -150,8 +150,8 @@ def test_process_report(executor: Executor, package_ahriman: Package, mocker: Mo must process report """ mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.core.report.report.Report.load", return_value=Report("x86_64", executor.configuration)) - report_mock = mocker.patch("ahriman.core.report.report.Report.run") + mocker.patch("ahriman.core.report.Report.load", return_value=Report("x86_64", executor.configuration)) + report_mock = mocker.patch("ahriman.core.report.Report.run") executor.process_report(["dummy"], []) report_mock.assert_called_once_with([package_ahriman], []) @@ -170,8 +170,8 @@ def test_process_upload(executor: Executor, mocker: MockerFixture) -> None: """ must process sync """ - mocker.patch("ahriman.core.upload.upload.Upload.load", return_value=Upload("x86_64", executor.configuration)) - upload_mock = mocker.patch("ahriman.core.upload.upload.Upload.run") + mocker.patch("ahriman.core.upload.Upload.load", return_value=Upload("x86_64", executor.configuration)) + upload_mock = mocker.patch("ahriman.core.upload.Upload.run") executor.process_sync(["dummy"], []) upload_mock.assert_called_once_with(executor.paths.repository, []) diff --git a/tests/ahriman/core/repository/test_repository_properties.py b/tests/ahriman/core/repository/test_repository_properties.py index 3b951047..affb2387 100644 --- a/tests/ahriman/core/repository/test_repository_properties.py +++ b/tests/ahriman/core/repository/test_repository_properties.py @@ -1,7 +1,7 @@ from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import UnsafeRun from ahriman.core.repository.repository_properties import RepositoryProperties from ahriman.core.status.web_client import WebClient diff --git a/tests/ahriman/core/repository/test_update_handler.py b/tests/ahriman/core/repository/test_update_handler.py index 9cf5e1ae..677ed620 100644 --- a/tests/ahriman/core/repository/test_update_handler.py +++ b/tests/ahriman/core/repository/test_update_handler.py @@ -190,7 +190,7 @@ def test_updates_manual_status_known(update_handler: UpdateHandler, package_ahri """ must create record for known package via reporter """ - mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", return_value=[package_ahriman]) + mocker.patch("ahriman.core.database.SQLite.build_queue_get", return_value=[package_ahriman]) mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending") @@ -203,7 +203,7 @@ def test_updates_manual_status_unknown(update_handler: UpdateHandler, package_ah """ must create record for unknown package via reporter """ - mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", return_value=[package_ahriman]) + mocker.patch("ahriman.core.database.SQLite.build_queue_get", return_value=[package_ahriman]) mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[]) status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_unknown") @@ -216,6 +216,6 @@ def test_updates_manual_with_failures(update_handler: UpdateHandler, package_ahr """ must process manual through the packages with failure """ - mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", side_effect=Exception()) + mocker.patch("ahriman.core.database.SQLite.build_queue_get", side_effect=Exception()) mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) assert update_handler.updates_manual() == [] diff --git a/tests/ahriman/core/status/test_watcher.py b/tests/ahriman/core/status/test_watcher.py index 99b6cbf7..bd02d153 100644 --- a/tests/ahriman/core/status/test_watcher.py +++ b/tests/ahriman/core/status/test_watcher.py @@ -1,12 +1,9 @@ import pytest -import tempfile -from pathlib import Path from pytest_mock import MockerFixture -from unittest.mock import PropertyMock from ahriman.core.configuration import Configuration -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.exceptions import UnknownPackage from ahriman.core.status.watcher import Watcher from ahriman.core.status.web_client import WebClient @@ -51,7 +48,7 @@ def test_load(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) must correctly load packages """ mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman]) - cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get") + cache_mock = mocker.patch("ahriman.core.database.SQLite.packages_get") watcher.load() cache_mock.assert_called_once_with() @@ -66,7 +63,7 @@ def test_load_known(watcher: Watcher, package_ahriman: Package, mocker: MockerFi """ status = BuildStatus(BuildStatusEnum.Success) mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get", return_value=[(package_ahriman, status)]) + mocker.patch("ahriman.core.database.SQLite.packages_get", return_value=[(package_ahriman, status)]) watcher.known = {package_ahriman.base: (package_ahriman, status)} watcher.load() @@ -78,7 +75,7 @@ def test_remove(watcher: Watcher, package_ahriman: Package, mocker: MockerFixtur """ must remove package base """ - cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_remove") + cache_mock = mocker.patch("ahriman.core.database.SQLite.package_remove") watcher.known = {package_ahriman.base: (package_ahriman, BuildStatus())} watcher.remove(package_ahriman.base) @@ -90,7 +87,7 @@ def test_remove_unknown(watcher: Watcher, package_ahriman: Package, mocker: Mock """ must not fail on unknown base removal """ - cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_remove") + cache_mock = mocker.patch("ahriman.core.database.SQLite.package_remove") watcher.remove(package_ahriman.base) cache_mock.assert_called_once_with(package_ahriman.base) @@ -100,7 +97,7 @@ def test_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixtur """ must update package status """ - cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_update") + cache_mock = mocker.patch("ahriman.core.database.SQLite.package_update") watcher.update(package_ahriman.base, BuildStatusEnum.Unknown, package_ahriman) cache_mock.assert_called_once_with(package_ahriman, pytest.helpers.anyvar(int)) @@ -113,7 +110,7 @@ def test_update_ping(watcher: Watcher, package_ahriman: Package, mocker: MockerF """ must update package status only for known package """ - cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_update") + cache_mock = mocker.patch("ahriman.core.database.SQLite.package_update") watcher.known = {package_ahriman.base: (package_ahriman, BuildStatus())} watcher.update(package_ahriman.base, BuildStatusEnum.Success, None) diff --git a/tests/ahriman/core/test_tree.py b/tests/ahriman/core/test_tree.py index 219215a6..d277ee27 100644 --- a/tests/ahriman/core/test_tree.py +++ b/tests/ahriman/core/test_tree.py @@ -2,7 +2,7 @@ import pytest from pytest_mock import MockerFixture -from ahriman.core.database.sqlite import SQLite +from ahriman.core.database import SQLite from ahriman.core.tree import Leaf, Tree from ahriman.models.package import Package diff --git a/tests/ahriman/core/upload/conftest.py b/tests/ahriman/core/upload/conftest.py index 24de8b5d..082749e7 100644 --- a/tests/ahriman/core/upload/conftest.py +++ b/tests/ahriman/core/upload/conftest.py @@ -5,9 +5,7 @@ from typing import Any, Dict, List from unittest.mock import MagicMock from ahriman.core.configuration import Configuration -from ahriman.core.upload.github import Github -from ahriman.core.upload.rsync import Rsync -from ahriman.core.upload.s3 import S3 +from ahriman.core.upload import Github, Rsync, S3 _s3_object = namedtuple("s3_object", ["key", "e_tag", "delete"]) diff --git a/tests/ahriman/core/upload/test_github.py b/tests/ahriman/core/upload/test_github.py index 8ff44fd0..483efca9 100644 --- a/tests/ahriman/core/upload/test_github.py +++ b/tests/ahriman/core/upload/test_github.py @@ -6,14 +6,14 @@ from pytest_mock import MockerFixture from typing import Any, Dict from unittest import mock -from ahriman.core.upload.github import Github +from ahriman.core.upload import Github def test_asset_remove(github: Github, github_release: Dict[str, Any], mocker: MockerFixture) -> None: """ must remove asset from the release """ - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") + request_mock = mocker.patch("ahriman.core.upload.Github._request") github.asset_remove(github_release, "asset_name") request_mock.assert_called_once_with("DELETE", "asset_url") @@ -22,7 +22,7 @@ def test_asset_remove_unknown(github: Github, github_release: Dict[str, Any], mo """ must not fail if no asset found """ - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") + request_mock = mocker.patch("ahriman.core.upload.Github._request") github.asset_remove(github_release, "unknown_asset_name") request_mock.assert_not_called() @@ -32,8 +32,8 @@ def test_asset_upload(github: Github, github_release: Dict[str, Any], mocker: Mo must upload asset to the repository """ mocker.patch("pathlib.Path.open", return_value=b"") - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") - remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove") + request_mock = mocker.patch("ahriman.core.upload.Github._request") + remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove") github.asset_upload(github_release, Path("/root/new.tar.xz")) request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"}, @@ -46,8 +46,8 @@ def test_asset_upload_with_removal(github: Github, github_release: Dict[str, Any must remove existing file before upload """ mocker.patch("pathlib.Path.open", return_value=b"") - mocker.patch("ahriman.core.upload.github.Github._request") - remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove") + mocker.patch("ahriman.core.upload.Github._request") + remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove") github.asset_upload(github_release, Path("asset_name")) github.asset_upload(github_release, Path("/root/asset_name")) @@ -62,9 +62,9 @@ def test_asset_upload_empty_mimetype(github: Github, github_release: Dict[str, A must upload asset to the repository with empty mime type if cannot guess it """ mocker.patch("pathlib.Path.open", return_value=b"") - mocker.patch("ahriman.core.upload.github.Github.asset_remove") + mocker.patch("ahriman.core.upload.Github.asset_remove") mocker.patch("mimetypes.guess_type", return_value=(None, None)) - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") + request_mock = mocker.patch("ahriman.core.upload.Github._request") github.asset_upload(github_release, Path("/root/new.tar.xz")) request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"}, @@ -84,7 +84,7 @@ def test_files_remove(github: Github, github_release: Dict[str, Any], mocker: Mo """ must remove files from the remote """ - remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove") + remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove") github.files_remove(github_release, {Path("a"): "a"}, {"a": "a", "b": "b"}) remove_mock.assert_called_once_with(github_release, "b") @@ -93,7 +93,7 @@ def test_files_remove_empty(github: Github, github_release: Dict[str, Any], mock """ must remove nothing if nothing changed """ - remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove") + remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove") github.files_remove(github_release, {Path("a"): "a"}, {"a": "a"}) remove_mock.assert_not_called() @@ -102,7 +102,7 @@ def test_files_upload(github: Github, github_release: Dict[str, Any], mocker: Mo """ must upload files to the remote """ - upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload") + upload_mock = mocker.patch("ahriman.core.upload.Github.asset_upload") github.files_upload(github_release, {Path("a"): "a", Path("b"): "c", Path("c"): "c"}, {"a": "a", "b": "b"}) upload_mock.assert_has_calls([ mock.call(github_release, Path("b")), @@ -114,7 +114,7 @@ def test_files_upload_empty(github: Github, github_release: Dict[str, Any], mock """ must upload nothing if nothing changed """ - upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload") + upload_mock = mocker.patch("ahriman.core.upload.Github.asset_upload") github.files_upload(github_release, {Path("a"): "a"}, {"a": "a"}) upload_mock.assert_not_called() @@ -123,7 +123,7 @@ def test_release_create(github: Github, mocker: MockerFixture) -> None: """ must create release """ - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") + request_mock = mocker.patch("ahriman.core.upload.Github._request") github.release_create() request_mock.assert_called_once_with("POST", pytest.helpers.anyvar(str, True), json={"tag_name": github.architecture, "name": github.architecture}) @@ -133,7 +133,7 @@ def test_release_get(github: Github, mocker: MockerFixture) -> None: """ must get release """ - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") + request_mock = mocker.patch("ahriman.core.upload.Github._request") github.release_get() request_mock.assert_called_once_with("GET", pytest.helpers.anyvar(str, True)) @@ -144,7 +144,7 @@ def test_release_get_empty(github: Github, mocker: MockerFixture) -> None: """ response = requests.Response() response.status_code = 404 - mocker.patch("ahriman.core.upload.github.Github._request", side_effect=requests.HTTPError(response=response)) + mocker.patch("ahriman.core.upload.Github._request", side_effect=requests.HTTPError(response=response)) assert github.release_get() is None @@ -152,7 +152,7 @@ def test_release_get_exception(github: Github, mocker: MockerFixture) -> None: """ must re-raise non HTTPError exception """ - mocker.patch("ahriman.core.upload.github.Github._request", side_effect=Exception()) + mocker.patch("ahriman.core.upload.Github._request", side_effect=Exception()) with pytest.raises(Exception): github.release_get() @@ -162,7 +162,7 @@ def test_release_get_exception_http_error(github: Github, mocker: MockerFixture) must re-raise HTTPError exception with code differs from 404 """ exception = requests.HTTPError(response=requests.Response()) - mocker.patch("ahriman.core.upload.github.Github._request", side_effect=exception) + mocker.patch("ahriman.core.upload.Github._request", side_effect=exception) with pytest.raises(requests.HTTPError): github.release_get() @@ -171,7 +171,7 @@ def test_release_update(github: Github, github_release: Dict[str, Any], mocker: """ must update release """ - request_mock = mocker.patch("ahriman.core.upload.github.Github._request") + request_mock = mocker.patch("ahriman.core.upload.Github._request") github.release_update(github_release, "body") request_mock.assert_called_once_with("POST", "release_url", json={"body": "body"}) @@ -180,12 +180,12 @@ def test_release_sync(github: Github, mocker: MockerFixture) -> None: """ must run sync command """ - release_get_mock = mocker.patch("ahriman.core.upload.github.Github.release_get", return_value={}) - get_hashes_mock = mocker.patch("ahriman.core.upload.github.Github.get_hashes", return_value={}) - get_local_files_mock = mocker.patch("ahriman.core.upload.github.Github.get_local_files", return_value={}) - files_upload_mock = mocker.patch("ahriman.core.upload.github.Github.files_upload") - files_remove_mock = mocker.patch("ahriman.core.upload.github.Github.files_remove") - release_update_mock = mocker.patch("ahriman.core.upload.github.Github.release_update") + release_get_mock = mocker.patch("ahriman.core.upload.Github.release_get", return_value={}) + get_hashes_mock = mocker.patch("ahriman.core.upload.Github.get_hashes", return_value={}) + get_local_files_mock = mocker.patch("ahriman.core.upload.Github.get_local_files", return_value={}) + files_upload_mock = mocker.patch("ahriman.core.upload.Github.files_upload") + files_remove_mock = mocker.patch("ahriman.core.upload.Github.files_remove") + release_update_mock = mocker.patch("ahriman.core.upload.Github.release_update") github.sync(Path("local"), []) release_get_mock.assert_called_once_with() @@ -200,13 +200,13 @@ def test_release_sync_create_release(github: Github, mocker: MockerFixture) -> N """ must create release in case if it does not exist """ - mocker.patch("ahriman.core.upload.github.Github.release_get", return_value=None) - mocker.patch("ahriman.core.upload.github.Github.get_hashes") - mocker.patch("ahriman.core.upload.github.Github.get_local_files") - mocker.patch("ahriman.core.upload.github.Github.files_upload") - mocker.patch("ahriman.core.upload.github.Github.files_remove") - mocker.patch("ahriman.core.upload.github.Github.release_update") - release_create_mock = mocker.patch("ahriman.core.upload.github.Github.release_create") + mocker.patch("ahriman.core.upload.Github.release_get", return_value=None) + mocker.patch("ahriman.core.upload.Github.get_hashes") + mocker.patch("ahriman.core.upload.Github.get_local_files") + mocker.patch("ahriman.core.upload.Github.files_upload") + mocker.patch("ahriman.core.upload.Github.files_remove") + mocker.patch("ahriman.core.upload.Github.release_update") + release_create_mock = mocker.patch("ahriman.core.upload.Github.release_create") github.sync(Path("local"), []) release_create_mock.assert_called_once_with() diff --git a/tests/ahriman/core/upload/test_http_upload.py b/tests/ahriman/core/upload/test_http_upload.py index fd2334d2..e332d10d 100644 --- a/tests/ahriman/core/upload/test_http_upload.py +++ b/tests/ahriman/core/upload/test_http_upload.py @@ -5,8 +5,7 @@ from pathlib import Path from pytest_mock import MockerFixture from unittest.mock import MagicMock -from ahriman.core.upload.github import Github -from ahriman.core.upload.http_upload import HttpUpload +from ahriman.core.upload import Github, HttpUpload def test_calculate_hash_empty(resource_path_root: Path) -> None: diff --git a/tests/ahriman/core/upload/test_rsync.py b/tests/ahriman/core/upload/test_rsync.py index 52bf595a..cdd7f6d7 100644 --- a/tests/ahriman/core/upload/test_rsync.py +++ b/tests/ahriman/core/upload/test_rsync.py @@ -1,13 +1,13 @@ from pathlib import Path from pytest_mock import MockerFixture -from ahriman.core.upload.rsync import Rsync +from ahriman.core.upload import Rsync def test_sync(rsync: Rsync, mocker: MockerFixture) -> None: """ must run sync command """ - check_output_mock = mocker.patch("ahriman.core.upload.rsync.Rsync._check_output") + check_output_mock = mocker.patch("ahriman.core.upload.Rsync._check_output") rsync.sync(Path("path"), []) check_output_mock.assert_called_once_with(*rsync.command, "path", rsync.remote, exception=None, logger=rsync.logger) diff --git a/tests/ahriman/core/upload/test_s3.py b/tests/ahriman/core/upload/test_s3.py index d30c7c1f..f9d71469 100644 --- a/tests/ahriman/core/upload/test_s3.py +++ b/tests/ahriman/core/upload/test_s3.py @@ -1,12 +1,10 @@ -import pytest - from pathlib import Path from pytest_mock import MockerFixture from typing import Any, List, Optional, Tuple from unittest import mock from unittest.mock import MagicMock -from ahriman.core.upload.s3 import S3 +from ahriman.core.upload import S3 _chunk_size = 8 * 1024 * 1024 @@ -106,10 +104,10 @@ def test_sync(s3: S3, mocker: MockerFixture) -> None: """ must run sync command """ - local_files_mock = mocker.patch("ahriman.core.upload.s3.S3.get_local_files", return_value=["a"]) - remote_objects_mock = mocker.patch("ahriman.core.upload.s3.S3.get_remote_objects", return_value=["b"]) - remove_files_mock = mocker.patch("ahriman.core.upload.s3.S3.files_remove") - upload_files_mock = mocker.patch("ahriman.core.upload.s3.S3.files_upload") + local_files_mock = mocker.patch("ahriman.core.upload.S3.get_local_files", return_value=["a"]) + remote_objects_mock = mocker.patch("ahriman.core.upload.S3.get_remote_objects", return_value=["b"]) + remove_files_mock = mocker.patch("ahriman.core.upload.S3.files_remove") + upload_files_mock = mocker.patch("ahriman.core.upload.S3.files_upload") s3.sync(Path("root"), []) remote_objects_mock.assert_called_once_with() diff --git a/tests/ahriman/core/upload/test_upload.py b/tests/ahriman/core/upload/test_upload.py index 10724dc6..396fe335 100644 --- a/tests/ahriman/core/upload/test_upload.py +++ b/tests/ahriman/core/upload/test_upload.py @@ -5,7 +5,7 @@ from pytest_mock import MockerFixture from ahriman.core.configuration import Configuration from ahriman.core.exceptions import SyncFailed -from ahriman.core.upload.upload import Upload +from ahriman.core.upload import Upload from ahriman.models.upload_settings import UploadSettings @@ -13,7 +13,7 @@ def test_upload_failure(configuration: Configuration, mocker: MockerFixture) -> """ must raise SyncFailed on errors """ - mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception()) + mocker.patch("ahriman.core.upload.Rsync.sync", side_effect=Exception()) with pytest.raises(SyncFailed): Upload.load("x86_64", configuration, "rsync").run(Path("path"), []) @@ -23,7 +23,7 @@ def test_report_dummy(configuration: Configuration, mocker: MockerFixture) -> No must construct dummy upload class """ mocker.patch("ahriman.models.upload_settings.UploadSettings.from_option", return_value=UploadSettings.Disabled) - upload_mock = mocker.patch("ahriman.core.upload.upload.Upload.sync") + upload_mock = mocker.patch("ahriman.core.upload.Upload.sync") Upload.load("x86_64", configuration, "disabled").run(Path("path"), []) upload_mock.assert_called_once_with(Path("path"), []) @@ -32,7 +32,7 @@ def test_upload_rsync(configuration: Configuration, mocker: MockerFixture) -> No """ must upload via rsync """ - upload_mock = mocker.patch("ahriman.core.upload.rsync.Rsync.sync") + upload_mock = mocker.patch("ahriman.core.upload.Rsync.sync") Upload.load("x86_64", configuration, "rsync").run(Path("path"), []) upload_mock.assert_called_once_with(Path("path"), []) @@ -41,7 +41,7 @@ def test_upload_s3(configuration: Configuration, mocker: MockerFixture) -> None: """ must upload via s3 """ - upload_mock = mocker.patch("ahriman.core.upload.s3.S3.sync") + upload_mock = mocker.patch("ahriman.core.upload.S3.sync") Upload.load("x86_64", configuration, "customs3").run(Path("path"), []) upload_mock.assert_called_once_with(Path("path"), []) @@ -50,6 +50,6 @@ def test_upload_github(configuration: Configuration, mocker: MockerFixture) -> N """ must upload via github """ - upload_mock = mocker.patch("ahriman.core.upload.github.Github.sync") + upload_mock = mocker.patch("ahriman.core.upload.Github.sync") Upload.load("x86_64", configuration, "github").run(Path("path"), []) upload_mock.assert_called_once_with(Path("path"), []) diff --git a/tests/ahriman/models/test_package.py b/tests/ahriman/models/test_package.py index 0bf89816..e1f42f8e 100644 --- a/tests/ahriman/models/test_package.py +++ b/tests/ahriman/models/test_package.py @@ -85,7 +85,7 @@ def test_from_aur(package_ahriman: Package, aur_package_ahriman: AURPackage, pac """ must construct package from aur """ - mocker.patch("ahriman.core.alpm.remote.aur.AUR.info", return_value=aur_package_ahriman) + mocker.patch("ahriman.core.alpm.remote.AUR.info", return_value=aur_package_ahriman) package = Package.from_aur(package_ahriman.base, pacman) assert package_ahriman.base == package.base @@ -144,7 +144,7 @@ def test_from_official(package_ahriman: Package, aur_package_ahriman: AURPackage """ must construct package from official repository """ - mocker.patch("ahriman.core.alpm.remote.official.Official.info", return_value=aur_package_ahriman) + mocker.patch("ahriman.core.alpm.remote.Official.info", return_value=aur_package_ahriman) package = Package.from_official(package_ahriman.base, pacman) assert package_ahriman.base == package.base diff --git a/tests/ahriman/models/test_remote_source.py b/tests/ahriman/models/test_remote_source.py index ce252a41..c1817cec 100644 --- a/tests/ahriman/models/test_remote_source.py +++ b/tests/ahriman/models/test_remote_source.py @@ -46,8 +46,8 @@ def test_from_source_aur(package_ahriman: Package, mocker: MockerFixture) -> Non """ must construct remote from AUR source """ - remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.remote_git_url") - remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.remote_web_url") + remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.AUR.remote_git_url") + remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.AUR.remote_web_url") remote = RemoteSource.from_source(PackageSource.AUR, package_ahriman.base, "aur") remote_git_url_mock.assert_called_once_with(package_ahriman.base, "aur") @@ -61,8 +61,8 @@ def test_from_source_official(package_ahriman: Package, mocker: MockerFixture) - """ must construct remote from official repository source """ - remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.remote_git_url") - remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.remote_web_url") + remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.Official.remote_git_url") + remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.Official.remote_web_url") remote = RemoteSource.from_source(PackageSource.Repository, package_ahriman.base, "community") remote_git_url_mock.assert_called_once_with(package_ahriman.base, "community") diff --git a/tests/ahriman/web/conftest.py b/tests/ahriman/web/conftest.py index 29f6e532..8253f6fe 100644 --- a/tests/ahriman/web/conftest.py +++ b/tests/ahriman/web/conftest.py @@ -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) diff --git a/tests/ahriman/web/middlewares/conftest.py b/tests/ahriman/web/middlewares/conftest.py index 549c959f..7929e5ad 100644 --- a/tests/ahriman/web/middlewares/conftest.py +++ b/tests/ahriman/web/middlewares/conftest.py @@ -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 diff --git a/tests/ahriman/web/middlewares/test_auth_handler.py b/tests/ahriman/web/middlewares/test_auth_handler.py index b4715bef..bd5c299c 100644 --- a/tests/ahriman/web/middlewares/test_auth_handler.py +++ b/tests/ahriman/web/middlewares/test_auth_handler.py @@ -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 diff --git a/tests/ahriman/web/views/conftest.py b/tests/ahriman/web/views/conftest.py index b3b40d6f..1f64f2eb 100644 --- a/tests/ahriman/web/views/conftest.py +++ b/tests/ahriman/web/views/conftest.py @@ -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 diff --git a/tests/ahriman/web/views/service/test_views_service_search.py b/tests/ahriman/web/views/service/test_views_service_search.py index ff3d1b3e..2e16d9fd 100644 --- a/tests/ahriman/web/views/service/test_views_service_search.py +++ b/tests/ahriman/web/views/service/test_views_service_search.py @@ -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 diff --git a/tests/ahriman/web/views/user/test_views_user_login.py b/tests/ahriman/web/views/user/test_views_user_login.py index ae069b6d..3a381e42 100644 --- a/tests/ahriman/web/views/user/test_views_user_login.py +++ b/tests/ahriman/web/views/user/test_views_user_login.py @@ -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