From 40a062882fb63ec119749495f1a38fb1853ae74d Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Sun, 20 Oct 2024 23:26:04 +0300 Subject: [PATCH] test: remove duplicated descriptions from tests --- .../application/test_application_packages.py | 2 +- .../test_application_repository.py | 2 +- .../application/handlers/test_handler.py | 2 +- .../handlers/test_handler_rebuild.py | 2 +- .../handlers/test_handler_shell.py | 2 +- tests/ahriman/core/alpm/remote/test_aur.py | 2 +- tests/ahriman/core/alpm/test_pacman.py | 2 +- .../operations/test_patch_operations.py | 2 +- tests/ahriman/core/log/test_lazy_logging.py | 2 +- tests/ahriman/core/report/test_email.py | 2 +- tests/ahriman/core/report/test_telegram.py | 2 +- tests/ahriman/core/repository/test_cleaner.py | 2 +- .../core/repository/test_update_handler.py | 2 +- tests/ahriman/core/sign/test_gpg.py | 55 ++++--------------- tests/ahriman/core/status/test_client.py | 2 +- tests/ahriman/core/status/test_web_client.py | 10 ++-- .../core/triggers/test_trigger_loader.py | 2 +- tests/ahriman/models/test_package.py | 4 +- tests/ahriman/models/test_package_source.py | 2 +- tests/ahriman/models/test_pkgbuild_patch.py | 4 +- .../web/middlewares/test_exception_handler.py | 2 +- tests/ahriman/web/test_web.py | 2 +- .../views/v1/user/test_view_v1_user_login.py | 2 +- 23 files changed, 38 insertions(+), 73 deletions(-) diff --git a/tests/ahriman/application/application/test_application_packages.py b/tests/ahriman/application/application/test_application_packages.py index 94210120c..882ebd38d 100644 --- a/tests/ahriman/application/application/test_application_packages.py +++ b/tests/ahriman/application/application/test_application_packages.py @@ -139,7 +139,7 @@ def test_add_remote(application_packages: ApplicationPackages, package_descripti def test_add_remote_missing(application_packages: ApplicationPackages, mocker: MockerFixture) -> None: """ - must add package from remote source + must raise UnknownPackageError if remote package wasn't found """ mocker.patch("requests.get", side_effect=Exception()) with pytest.raises(UnknownPackageError): diff --git a/tests/ahriman/application/application/test_application_repository.py b/tests/ahriman/application/application/test_application_repository.py index c9e2b3152..531b4e5ad 100644 --- a/tests/ahriman/application/application/test_application_repository.py +++ b/tests/ahriman/application/application/test_application_repository.py @@ -79,7 +79,7 @@ def test_clean_packages(application_repository: ApplicationRepository, mocker: M def test_clean_pacman(application_repository: ApplicationRepository, mocker: MockerFixture) -> None: """ - must clean packages directory + must clean pacman directory """ clear_mock = mocker.patch("ahriman.core.repository.Repository.clear_pacman") application_repository.clean(cache=False, chroot=False, manual=False, packages=False, pacman=True) diff --git a/tests/ahriman/application/handlers/test_handler.py b/tests/ahriman/application/handlers/test_handler.py index a43b6d43e..49307cd0c 100644 --- a/tests/ahriman/application/handlers/test_handler.py +++ b/tests/ahriman/application/handlers/test_handler.py @@ -171,7 +171,7 @@ def test_repositories_extract_repository(args: argparse.Namespace, configuration def test_repositories_extract_repository_legacy(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None: """ - must generate list of available repositories based on flags and tree + must generate list of available repositories based on flags and tree (legacy mode) """ args.architecture = "arch" args.configuration = configuration.path diff --git a/tests/ahriman/application/handlers/test_handler_rebuild.py b/tests/ahriman/application/handlers/test_handler_rebuild.py index c0d950121..a126b02a9 100644 --- a/tests/ahriman/application/handlers/test_handler_rebuild.py +++ b/tests/ahriman/application/handlers/test_handler_rebuild.py @@ -190,7 +190,7 @@ def test_extract_packages_by_status(application: Application, mocker: MockerFixt def test_extract_packages_from_database(application: Application, mocker: MockerFixture) -> None: """ - must extract packages from database + must extract packages from database from database """ packages_mock = mocker.patch("ahriman.core.database.SQLite.packages_get") Rebuild.extract_packages(application, None, from_database=True) diff --git a/tests/ahriman/application/handlers/test_handler_shell.py b/tests/ahriman/application/handlers/test_handler_shell.py index af46976aa..8d164f1e6 100644 --- a/tests/ahriman/application/handlers/test_handler_shell.py +++ b/tests/ahriman/application/handlers/test_handler_shell.py @@ -40,7 +40,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository: def test_run_eval(args: argparse.Namespace, configuration: Configuration, repository: Repository, mocker: MockerFixture) -> None: """ - must run command + must run command via eval """ args = _default_args(args) args.code = """print("hello world")""" diff --git a/tests/ahriman/core/alpm/remote/test_aur.py b/tests/ahriman/core/alpm/remote/test_aur.py index 55282ae7d..b8722962c 100644 --- a/tests/ahriman/core/alpm/remote/test_aur.py +++ b/tests/ahriman/core/alpm/remote/test_aur.py @@ -60,7 +60,7 @@ def test_remote_git_url(aur_package_ahriman: AURPackage) -> None: def test_remote_web_url(aur_package_ahriman: AURPackage) -> None: """ - must generate package git url + must generate package web url """ web_url = AUR.remote_web_url(aur_package_ahriman.package_base) assert web_url.startswith(AUR.DEFAULT_AUR_URL) diff --git a/tests/ahriman/core/alpm/test_pacman.py b/tests/ahriman/core/alpm/test_pacman.py index 9b10fdfe7..f3d0f48ed 100644 --- a/tests/ahriman/core/alpm/test_pacman.py +++ b/tests/ahriman/core/alpm/test_pacman.py @@ -87,7 +87,7 @@ def test_database_copy_skip(pacman: Pacman, mocker: MockerFixture) -> None: def test_database_copy_no_directory(pacman: Pacman, mocker: MockerFixture) -> None: """ - must do not copy database if local cache already exists + must do not copy database if directory does not exist """ database = next(db for db in pacman.handle.get_syncdbs() if db.name == "core") path = Path("randomname") diff --git a/tests/ahriman/core/database/operations/test_patch_operations.py b/tests/ahriman/core/database/operations/test_patch_operations.py index 26f9c4178..7436fed7e 100644 --- a/tests/ahriman/core/database/operations/test_patch_operations.py +++ b/tests/ahriman/core/database/operations/test_patch_operations.py @@ -44,7 +44,7 @@ def test_patches_list_filter(database: SQLite, package_ahriman: Package, package def test_patches_list_filter_by_variable(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None: """ - must list all patches filtered by package name (same as get) + must list all patches filtered by variable (same as get) """ database.patches_insert(package_ahriman.base, [PkgbuildPatch(None, "patch1")]) database.patches_insert(package_ahriman.base, [PkgbuildPatch("key", "patch2")]) diff --git a/tests/ahriman/core/log/test_lazy_logging.py b/tests/ahriman/core/log/test_lazy_logging.py index a1afaf418..9e0ce3170 100644 --- a/tests/ahriman/core/log/test_lazy_logging.py +++ b/tests/ahriman/core/log/test_lazy_logging.py @@ -63,7 +63,7 @@ def test_in_package_context(database: SQLite, package_ahriman: Package, mocker: def test_in_package_context_empty_version(database: SQLite, package_ahriman: Package, mocker: MockerFixture) -> None: """ - must set package log context + must set package log context with empty version """ set_mock = mocker.patch("ahriman.core.log.LazyLogging._package_logger_set") reset_mock = mocker.patch("ahriman.core.log.LazyLogging._package_logger_reset") diff --git a/tests/ahriman/core/report/test_email.py b/tests/ahriman/core/report/test_email.py index 2515d8573..52e2b7e11 100644 --- a/tests/ahriman/core/report/test_email.py +++ b/tests/ahriman/core/report/test_email.py @@ -24,7 +24,7 @@ def test_template(configuration: Configuration) -> None: def test_template_full(configuration: Configuration) -> None: """ - must correctly parse template name and path + must correctly parse full template name and path """ template = "template" root, repository_id = configuration.check_loaded() diff --git a/tests/ahriman/core/report/test_telegram.py b/tests/ahriman/core/report/test_telegram.py index 76cadbbae..ebe889aad 100644 --- a/tests/ahriman/core/report/test_telegram.py +++ b/tests/ahriman/core/report/test_telegram.py @@ -107,7 +107,7 @@ def test_generate_very_big_text(telegram: Telegram, package_ahriman: Package, re def test_generate_no_empty(telegram: Telegram, package_ahriman: Package, mocker: MockerFixture) -> None: """ - must generate report + must skip report generation if result is empty """ send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send") telegram.generate([package_ahriman], Result()) diff --git a/tests/ahriman/core/repository/test_cleaner.py b/tests/ahriman/core/repository/test_cleaner.py index 4a9cf5ac6..fd89461ce 100644 --- a/tests/ahriman/core/repository/test_cleaner.py +++ b/tests/ahriman/core/repository/test_cleaner.py @@ -62,7 +62,7 @@ def test_clear_packages(cleaner: Cleaner, mocker: MockerFixture) -> None: def test_clear_pacman(cleaner: Cleaner, mocker: MockerFixture) -> None: """ - must delete built packages + must clear pacman root """ _mock_clear(mocker) cleaner.clear_pacman() diff --git a/tests/ahriman/core/repository/test_update_handler.py b/tests/ahriman/core/repository/test_update_handler.py index c57df9156..b4c4c0f64 100644 --- a/tests/ahriman/core/repository/test_update_handler.py +++ b/tests/ahriman/core/repository/test_update_handler.py @@ -142,7 +142,7 @@ def package_selector(name: str, *_: Any) -> Package: def test_updates_aur_load_by_package_failed(update_handler: UpdateHandler, package_ahriman: Package, mocker: MockerFixture) -> None: """ - must update status via client for failed load + must update status via client for failed load if no remote package found """ mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) mocker.patch("ahriman.models.package.Package.from_aur", side_effect=UnknownPackageError(package_ahriman.base)) diff --git a/tests/ahriman/core/sign/test_gpg.py b/tests/ahriman/core/sign/test_gpg.py index 62747ae22..ae5eda101 100644 --- a/tests/ahriman/core/sign/test_gpg.py +++ b/tests/ahriman/core/sign/test_gpg.py @@ -9,50 +9,35 @@ from ahriman.models.sign_settings import SignSettings -def test_repository_sign_args_1(gpg_with_key: GPG) -> None: +def test_repository_sign_args(gpg_with_key: GPG) -> None: """ must generate correct sign args """ gpg_with_key.targets = {SignSettings.Repository} assert gpg_with_key.repository_sign_args - -def test_repository_sign_args_2(gpg_with_key: GPG) -> None: - """ - must generate correct sign args - """ gpg_with_key.targets = {SignSettings.Packages, SignSettings.Repository} assert gpg_with_key.repository_sign_args -def test_repository_sign_args_skip_1(gpg_with_key: GPG) -> None: +def test_repository_sign_args_skip(gpg_with_key: GPG) -> None: """ must return empty args if it is not set """ gpg_with_key.targets = {} assert not gpg_with_key.repository_sign_args - -def test_repository_sign_args_skip_2(gpg_with_key: GPG) -> None: - """ - must return empty args if it is not set - """ gpg_with_key.targets = {SignSettings.Packages} assert not gpg_with_key.repository_sign_args -def test_repository_sign_args_skip_3(gpg: GPG) -> None: +def test_repository_sign_args_skip_no_key(gpg: GPG) -> None: """ - must return empty args if it is not set + must return empty args if it is not set if no key set """ gpg.targets = {SignSettings.Repository} assert not gpg.repository_sign_args - -def test_repository_sign_args_skip_4(gpg: GPG) -> None: - """ - must return empty args if it is not set - """ gpg.targets = {SignSettings.Packages, SignSettings.Repository} assert not gpg.repository_sign_args @@ -188,7 +173,7 @@ def test_process_sign_package_3(gpg_with_key: GPG, mocker: MockerFixture) -> Non def test_process_sign_package_skip_1(gpg_with_key: GPG, mocker: MockerFixture) -> None: """ - must not sign package if it is not set + must not sign package on empty target list """ process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") gpg_with_key.targets = {} @@ -198,7 +183,7 @@ def test_process_sign_package_skip_1(gpg_with_key: GPG, mocker: MockerFixture) - def test_process_sign_package_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None: """ - must not sign package if it is not set + must not sign package if repository only is enabled """ process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") gpg_with_key.targets = {SignSettings.Repository} @@ -208,7 +193,7 @@ def test_process_sign_package_skip_2(gpg_with_key: GPG, mocker: MockerFixture) - def test_process_sign_package_skip_3(gpg: GPG, mocker: MockerFixture) -> None: """ - must not sign package if it is not set + must not sign package if key is not set """ process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") gpg.targets = {SignSettings.Packages} @@ -216,16 +201,6 @@ def test_process_sign_package_skip_3(gpg: GPG, mocker: MockerFixture) -> None: process_mock.assert_not_called() -def test_process_sign_package_skip_4(gpg: GPG, mocker: MockerFixture) -> None: - """ - must not sign package if it is not set - """ - process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") - gpg.targets = {SignSettings.Packages, SignSettings.Repository} - gpg.process_sign_package(Path("a"), None) - process_mock.assert_not_called() - - def test_process_sign_package_skip_already_signed(gpg_with_key: GPG, mocker: MockerFixture) -> None: """ must not sign package if it was already signed @@ -264,7 +239,7 @@ def test_process_sign_repository_2(gpg_with_key: GPG, mocker: MockerFixture) -> def test_process_sign_repository_skip_1(gpg_with_key: GPG, mocker: MockerFixture) -> None: """ - must not sign repository if it is not set + must not sign repository if no targets set """ process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") gpg_with_key.targets = {} @@ -274,7 +249,7 @@ def test_process_sign_repository_skip_1(gpg_with_key: GPG, mocker: MockerFixture def test_process_sign_repository_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None: """ - must not sign repository if it is not set + must not sign repository if repository target is not set """ process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") gpg_with_key.targets = {SignSettings.Packages} @@ -284,19 +259,9 @@ def test_process_sign_repository_skip_2(gpg_with_key: GPG, mocker: MockerFixture def test_process_sign_repository_skip_3(gpg: GPG, mocker: MockerFixture) -> None: """ - must not sign repository if it is not set + must not sign repository if key is not set """ process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") gpg.targets = {SignSettings.Repository} gpg.process_sign_repository(Path("a")) process_mock.assert_not_called() - - -def test_process_sign_repository_skip_4(gpg: GPG, mocker: MockerFixture) -> None: - """ - must not sign repository if it is not set - """ - process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process") - gpg.targets = {SignSettings.Packages, SignSettings.Repository} - gpg.process_sign_repository(Path("a")) - process_mock.assert_not_called() diff --git a/tests/ahriman/core/status/test_client.py b/tests/ahriman/core/status/test_client.py index 477c45536..4faad81c4 100644 --- a/tests/ahriman/core/status/test_client.py +++ b/tests/ahriman/core/status/test_client.py @@ -245,7 +245,7 @@ def test_set_failed(client: Client, package_ahriman: Package, mocker: MockerFixt def test_set_pending(client: Client, package_ahriman: Package, mocker: MockerFixture) -> None: """ - must set building status to the package + must set pending status to the package """ update_mock = mocker.patch("ahriman.core.status.Client.package_status_update") client.set_pending(package_ahriman.base) diff --git a/tests/ahriman/core/status/test_web_client.py b/tests/ahriman/core/status/test_web_client.py index b092cda31..847e73550 100644 --- a/tests/ahriman/core/status/test_web_client.py +++ b/tests/ahriman/core/status/test_web_client.py @@ -46,7 +46,7 @@ def test_changes_url(web_client: WebClient, package_ahriman: Package) -> None: def test_dependencies_url(web_client: WebClient, package_ahriman: Package) -> None: """ - must generate changes url correctly + must generate dependencies url correctly """ assert web_client._dependencies_url(package_ahriman.base).startswith(web_client.address) assert web_client._dependencies_url(package_ahriman.base).endswith( @@ -74,7 +74,7 @@ def test_logs_url(web_client: WebClient, package_ahriman: Package) -> None: def test_package_url(web_client: WebClient, package_ahriman: Package) -> None: """ - must generate package status url correctly + must generate package url correctly """ assert web_client._package_url("").startswith(web_client.address) assert web_client._package_url("").endswith("/api/v1/packages") @@ -86,7 +86,7 @@ def test_package_url(web_client: WebClient, package_ahriman: Package) -> None: def test_patches_url(web_client: WebClient, package_ahriman: Package) -> None: """ - must generate changes url correctly + must generate patches url correctly """ assert web_client._patches_url(package_ahriman.base).startswith(web_client.address) assert web_client._patches_url(package_ahriman.base).endswith(f"/api/v1/packages/{package_ahriman.base}/patches") @@ -575,7 +575,7 @@ def test_package_logs_add_failed(web_client: WebClient, log_record: logging.LogR def test_package_logs_add_failed_http_error(web_client: WebClient, log_record: logging.LogRecord, package_ahriman: Package, mocker: MockerFixture) -> None: """ - must pass exception during log post + must pass HTTP exception during log post """ mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) log_record.package_base = package_ahriman.base @@ -725,7 +725,7 @@ def test_package_patches_get_failed(web_client: WebClient, package_ahriman: Pack def test_package_patches_get_failed_http_error(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None: """ - must suppress HTTP exception happened during dependencies fetch + must suppress HTTP exception happened during patches fetch """ mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) web_client.package_patches_get(package_ahriman.base, None) diff --git a/tests/ahriman/core/triggers/test_trigger_loader.py b/tests/ahriman/core/triggers/test_trigger_loader.py index 82a5d3614..a4e99faaa 100644 --- a/tests/ahriman/core/triggers/test_trigger_loader.py +++ b/tests/ahriman/core/triggers/test_trigger_loader.py @@ -13,7 +13,7 @@ def test_known_triggers(configuration: Configuration) -> None: """ - must return used triggers + must return known triggers """ configuration.set_option("build", "triggers_known", "a b c") assert TriggerLoader.known_triggers(configuration) == ["a", "b", "c"] diff --git a/tests/ahriman/models/test_package.py b/tests/ahriman/models/test_package.py index 870d03b4f..be8b9dae5 100644 --- a/tests/ahriman/models/test_package.py +++ b/tests/ahriman/models/test_package.py @@ -255,14 +255,14 @@ def test_from_json_view_1(package_ahriman: Package) -> None: def test_from_json_view_2(package_python_schedule: Package) -> None: """ - must construct same object from json + must construct same object from json (double package) """ assert Package.from_json(package_python_schedule.view()) == package_python_schedule def test_from_json_view_3(package_tpacpi_bat_git: Package) -> None: """ - must construct same object from json + must construct same object from json (git package) """ assert Package.from_json(package_tpacpi_bat_git.view()) == package_tpacpi_bat_git diff --git a/tests/ahriman/models/test_package_source.py b/tests/ahriman/models/test_package_source.py index 5ab673123..c5b7b8b16 100644 --- a/tests/ahriman/models/test_package_source.py +++ b/tests/ahriman/models/test_package_source.py @@ -86,7 +86,7 @@ def test_resolve_local(repository_paths: RepositoryPaths, mocker: MockerFixture) def test_resolve_local_cache(repository_paths: RepositoryPaths, mocker: MockerFixture) -> None: """ - must resolve auto type into the local sources + must resolve auto type into the local sources with cache """ cache_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.cache_for", return_value=Path("cache")) mocker.patch("pathlib.Path.is_dir", autospec=True, side_effect=lambda p: p == Path("cache")) diff --git a/tests/ahriman/models/test_pkgbuild_patch.py b/tests/ahriman/models/test_pkgbuild_patch.py index 5725d98a5..96bf1f502 100644 --- a/tests/ahriman/models/test_pkgbuild_patch.py +++ b/tests/ahriman/models/test_pkgbuild_patch.py @@ -27,7 +27,7 @@ def test_is_function() -> None: def test_is_plain_diff() -> None: """ - must correctly define key as function + must correctly define key as a plain diff """ assert not PkgbuildPatch("key", "value").is_plain_diff assert PkgbuildPatch(None, "value").is_plain_diff @@ -112,7 +112,7 @@ def test_from_env_serialize() -> None: def test_serialize_plain_diff() -> None: """ - must correctly serialize function values + must correctly serialize plain diff values """ assert PkgbuildPatch(None, "{ value }").serialize() == "{ value }" diff --git a/tests/ahriman/web/middlewares/test_exception_handler.py b/tests/ahriman/web/middlewares/test_exception_handler.py index b926829a8..3ae807a60 100644 --- a/tests/ahriman/web/middlewares/test_exception_handler.py +++ b/tests/ahriman/web/middlewares/test_exception_handler.py @@ -98,7 +98,7 @@ async def test_exception_handler_unauthorized(mocker: MockerFixture) -> None: async def test_exception_handler_unauthorized_templated(mocker: MockerFixture) -> None: """ - must handle unauthorized exception as json response + must handle unauthorized exception as json response in html context """ request = pytest.helpers.request("", "", "") request_handler = AsyncMock(side_effect=HTTPUnauthorized()) diff --git a/tests/ahriman/web/test_web.py b/tests/ahriman/web/test_web.py index ae64ba45e..bee29e50d 100644 --- a/tests/ahriman/web/test_web.py +++ b/tests/ahriman/web/test_web.py @@ -124,7 +124,7 @@ def test_run_with_auth(application_with_auth: Application, mocker: MockerFixture def test_run_with_socket(application: Application, mocker: MockerFixture) -> None: """ - must run application + must run application with socket """ port = 8080 application[ConfigurationKey].set_option("web", "port", str(port)) diff --git a/tests/ahriman/web/views/v1/user/test_view_v1_user_login.py b/tests/ahriman/web/views/v1/user/test_view_v1_user_login.py index 2d33d753e..75c398678 100644 --- a/tests/ahriman/web/views/v1/user/test_view_v1_user_login.py +++ b/tests/ahriman/web/views/v1/user/test_view_v1_user_login.py @@ -158,7 +158,7 @@ async def test_post_unauthorized(client_with_auth: TestClient, user: User, mocke async def test_post_invalid_json(client_with_auth: TestClient, mocker: MockerFixture) -> None: """ - must return unauthorized on invalid auth + must return unauthorized on invalid payload """ response_schema = pytest.helpers.schema_response(LoginView.post, code=400) remember_mock = mocker.patch("aiohttp_security.remember")