diff --git a/README.md b/README.md index c3d087c4..2d293663 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Wrapper for managing custom repository inspired by [repo-scripts](https://github * Multi-architecture support. * VCS packages support. * Sign support with gpg (repository, package, per package settings). -* Synchronization to remote services (rsync, s3) and report generation (html). +* Synchronization to remote services (rsync, s3 and github) and report generation (html). * Dependency manager. -* Ability to patch AUR packages. +* Ability to patch AUR packages and even create package from local PKGBUILDs. * Repository status interface with optional authorization and control options: ![web interface](web.png) diff --git a/tests/ahriman/application/handlers/test_handler_patch.py b/tests/ahriman/application/handlers/test_handler_patch.py index 51984fd5..5e289af5 100644 --- a/tests/ahriman/application/handlers/test_handler_patch.py +++ b/tests/ahriman/application/handlers/test_handler_patch.py @@ -70,7 +70,7 @@ def test_patch_set_list(application: Application, mocker: MockerFixture) -> None print_mock = mocker.patch("ahriman.application.handlers.patch.Patch._print") Patch.patch_set_list(application, "ahriman") - glob_mock.assert_called_with("*.patch") + glob_mock.assert_called_once_with("*.patch") print_mock.assert_called() @@ -96,7 +96,7 @@ def test_patch_set_create(application: Application, package_ahriman: Package, mo patch_dir = application.repository.paths.patches_for(package_ahriman.base) Patch.patch_set_create(application, Path("path"), ["*.patch"]) - create_mock.assert_called_with(Path("path"), patch_dir / "00-main.patch", "*.patch") + create_mock.assert_called_once_with(Path("path"), patch_dir / "00-main.patch", "*.patch") def test_patch_set_create_clear(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -120,4 +120,4 @@ def test_patch_set_remove(application: Application, package_ahriman: Package, mo patch_dir = application.repository.paths.patches_for(package_ahriman.base) Patch.patch_set_remove(application, package_ahriman.base) - remove_mock.assert_called_with(patch_dir, ignore_errors=True) + remove_mock.assert_called_once_with(patch_dir, ignore_errors=True) diff --git a/tests/ahriman/application/handlers/test_handler_rebuild.py b/tests/ahriman/application/handlers/test_handler_rebuild.py index f77b70b1..058ef306 100644 --- a/tests/ahriman/application/handlers/test_handler_rebuild.py +++ b/tests/ahriman/application/handlers/test_handler_rebuild.py @@ -45,7 +45,7 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration, application_mock = mocker.patch("ahriman.application.application.Application.update") Rebuild.run(args, "x86_64", configuration, True) - application_mock.assert_called_with([package_ahriman]) + application_mock.assert_called_once_with([package_ahriman]) def test_run_without_filter(args: argparse.Namespace, configuration: Configuration, @@ -61,4 +61,4 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati application_mock = mocker.patch("ahriman.application.application.Application.update") Rebuild.run(args, "x86_64", configuration, True) - application_mock.assert_called_with([package_ahriman, package_python_schedule]) + application_mock.assert_called_once_with([package_ahriman, package_python_schedule]) diff --git a/tests/ahriman/application/handlers/test_handler_remove_unknown.py b/tests/ahriman/application/handlers/test_handler_remove_unknown.py index 861b6377..b9cac3f4 100644 --- a/tests/ahriman/application/handlers/test_handler_remove_unknown.py +++ b/tests/ahriman/application/handlers/test_handler_remove_unknown.py @@ -47,7 +47,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, pac RemoveUnknown.run(args, "x86_64", configuration, True) application_mock.assert_called_once() remove_mock.assert_not_called() - log_fn_mock.assert_called_with(package_ahriman) + log_fn_mock.assert_called_once_with(package_ahriman) def test_log_fn(package_ahriman: Package, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/application/handlers/test_handler_search.py b/tests/ahriman/application/handlers/test_handler_search.py index 43bf6d2c..aff5d29f 100644 --- a/tests/ahriman/application/handlers/test_handler_search.py +++ b/tests/ahriman/application/handlers/test_handler_search.py @@ -39,7 +39,7 @@ def test_run_multiple_search(args: argparse.Namespace, configuration: Configurat search_mock = mocker.patch("aur.search") Search.run(args, "x86_64", configuration, True) - search_mock.assert_called_with(" ".join(args.search)) + search_mock.assert_called_once_with(" ".join(args.search)) def test_log_fn(args: argparse.Namespace, configuration: Configuration, aur_package_ahriman: aur.Package, diff --git a/tests/ahriman/application/handlers/test_handler_setup.py b/tests/ahriman/application/handlers/test_handler_setup.py index 0d16559d..4db81edc 100644 --- a/tests/ahriman/application/handlers/test_handler_setup.py +++ b/tests/ahriman/application/handlers/test_handler_setup.py @@ -134,7 +134,7 @@ def test_create_sudo_configuration(args: argparse.Namespace, mocker: MockerFixtu write_text_mock = mocker.patch("pathlib.Path.write_text") Setup.create_sudo_configuration(args.build_command, "x86_64") - chmod_text_mock.assert_called_with(0o400) + chmod_text_mock.assert_called_once_with(0o400) write_text_mock.assert_called_once() diff --git a/tests/ahriman/application/handlers/test_handler_status.py b/tests/ahriman/application/handlers/test_handler_status.py index 83f4ecf6..7b058daf 100644 --- a/tests/ahriman/application/handlers/test_handler_status.py +++ b/tests/ahriman/application/handlers/test_handler_status.py @@ -51,7 +51,7 @@ def test_run_with_package_filter(args: argparse.Namespace, configuration: Config return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))]) Status.run(args, "x86_64", configuration, True) - packages_mock.assert_called_with(package_ahriman.base) + packages_mock.assert_called_once_with(package_ahriman.base) def test_run_by_status(args: argparse.Namespace, configuration: Configuration, package_ahriman: Package, diff --git a/tests/ahriman/application/test_application.py b/tests/ahriman/application/test_application.py index d6333cc1..d9f25ae0 100644 --- a/tests/ahriman/application/test_application.py +++ b/tests/ahriman/application/test_application.py @@ -41,7 +41,7 @@ def test_get_updates_all(application: Application, package_ahriman: Package, moc updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual") application.get_updates([], no_aur=False, no_manual=False, no_vcs=False, log_fn=print) - updates_aur_mock.assert_called_with([], False) + updates_aur_mock.assert_called_once_with([], False) updates_manual_mock.assert_called_once() @@ -77,7 +77,7 @@ def test_get_updates_no_manual(application: Application, mocker: MockerFixture) updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual") application.get_updates([], no_aur=False, no_manual=True, no_vcs=False, log_fn=print) - updates_aur_mock.assert_called_with([], False) + updates_aur_mock.assert_called_once_with([], False) updates_manual_mock.assert_not_called() @@ -89,7 +89,7 @@ def test_get_updates_no_vcs(application: Application, mocker: MockerFixture) -> updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual") application.get_updates([], no_aur=False, no_manual=False, no_vcs=True, log_fn=print) - updates_aur_mock.assert_called_with([], True) + updates_aur_mock.assert_called_once_with([], True) updates_manual_mock.assert_called_once() @@ -101,7 +101,7 @@ def test_get_updates_with_filter(application: Application, mocker: MockerFixture updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual") application.get_updates(["filter"], no_aur=False, no_manual=False, no_vcs=False, log_fn=print) - updates_aur_mock.assert_called_with(["filter"], False) + updates_aur_mock.assert_called_once_with(["filter"], False) updates_manual_mock.assert_called_once() @@ -271,7 +271,7 @@ def test_sign(application: Application, package_ahriman: Package, package_python mock.call(pytest.helpers.anyvar(str), pytest.helpers.anyvar(str)), mock.call(pytest.helpers.anyvar(str), pytest.helpers.anyvar(str)) ]) - update_mock.assert_called_with([]) + update_mock.assert_called_once_with([]) sign_repository_mock.assert_called_once() finalize_mock.assert_called_once() @@ -301,7 +301,7 @@ def test_sign_specific(application: Application, package_ahriman: Package, packa application.sign([package_ahriman.base]) copy_mock.assert_called_once() - update_mock.assert_called_with([]) + update_mock.assert_called_once_with([]) sign_repository_mock.assert_called_once() finalize_mock.assert_called_once() @@ -366,5 +366,5 @@ def test_update(application: Application, package_ahriman: Package, mocker: Mock application.update([package_ahriman]) build_mock.assert_called_once() - update_mock.assert_called_with(paths) - finalize_mock.assert_called_with([package_ahriman]) + update_mock.assert_called_once_with(paths) + finalize_mock.assert_called_once_with([package_ahriman]) diff --git a/tests/ahriman/core/auth/test_oauth.py b/tests/ahriman/core/auth/test_oauth.py index 73dc2ffc..77381216 100644 --- a/tests/ahriman/core/auth/test_oauth.py +++ b/tests/ahriman/core/auth/test_oauth.py @@ -58,7 +58,7 @@ def test_get_oauth_url(oauth: OAuth, mocker: MockerFixture) -> None: """ authorize_url_mock = mocker.patch("aioauth_client.GoogleClient.get_authorize_url") oauth.get_oauth_url() - authorize_url_mock.assert_called_with(scope=oauth.scopes, redirect_uri=oauth.redirect_uri) + authorize_url_mock.assert_called_once_with(scope=oauth.scopes, redirect_uri=oauth.redirect_uri) async def test_get_oauth_username(oauth: OAuth, mocker: MockerFixture) -> None: @@ -70,7 +70,7 @@ async def test_get_oauth_username(oauth: OAuth, mocker: MockerFixture) -> None: return_value=(aioauth_client.User(email="email"), "")) email = await oauth.get_oauth_username("code") - access_token_mock.assert_called_with("code", redirect_uri=oauth.redirect_uri) + access_token_mock.assert_called_once_with("code", redirect_uri=oauth.redirect_uri) user_info_mock.assert_called_once() assert email == "email" diff --git a/tests/ahriman/core/build_tools/test_sources.py b/tests/ahriman/core/build_tools/test_sources.py index a3ef10a1..4892b353 100644 --- a/tests/ahriman/core/build_tools/test_sources.py +++ b/tests/ahriman/core/build_tools/test_sources.py @@ -17,7 +17,7 @@ def test_add(mocker: MockerFixture) -> None: local = Path("local") Sources.add(local, "pattern1", "pattern2") glob_mock.assert_has_calls([mock.call("pattern1"), mock.call("pattern2")]) - check_output_mock.assert_called_with( + check_output_mock.assert_called_once_with( "git", "add", "--intent-to-add", "1", "2", "1", "2", exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) @@ -32,7 +32,8 @@ def test_diff(mocker: MockerFixture) -> None: local = Path("local") Sources.diff(local, Path("patch")) write_mock.assert_called_once() - check_output_mock.assert_called_with("git", "diff", exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) + check_output_mock.assert_called_once_with("git", "diff", + exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) def test_fetch_empty(mocker: MockerFixture) -> None: @@ -93,7 +94,8 @@ def test_has_remotes(mocker: MockerFixture) -> None: local = Path("local") assert Sources.has_remotes(local) - check_output_mock.assert_called_with("git", "remote", exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) + check_output_mock.assert_called_once_with("git", "remote", + exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) def test_has_remotes_empty(mocker: MockerFixture) -> None: @@ -112,8 +114,8 @@ def test_init(mocker: MockerFixture) -> None: local = Path("local") Sources.init(local) - check_output_mock.assert_called_with("git", "init", "--initial-branch", Sources._branch, - exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) + check_output_mock.assert_called_once_with("git", "init", "--initial-branch", Sources._branch, + exception=None, cwd=local, logger=pytest.helpers.anyvar(int)) def test_load(mocker: MockerFixture) -> None: @@ -124,8 +126,8 @@ def test_load(mocker: MockerFixture) -> None: patch_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.patch_apply") Sources.load(Path("local"), "remote", Path("patches")) - fetch_mock.assert_called_with(Path("local"), "remote") - patch_mock.assert_called_with(Path("local"), Path("patches")) + fetch_mock.assert_called_once_with(Path("local"), "remote") + patch_mock.assert_called_once_with(Path("local"), Path("patches")) def test_patch_apply(mocker: MockerFixture) -> None: @@ -178,5 +180,5 @@ def test_patch_create(mocker: MockerFixture) -> None: diff_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.diff") Sources.patch_create(Path("local"), Path("patch"), "glob") - add_mock.assert_called_with(Path("local"), "glob") - diff_mock.assert_called_with(Path("local"), Path("patch")) + add_mock.assert_called_once_with(Path("local"), "glob") + diff_mock.assert_called_once_with(Path("local"), Path("patch")) diff --git a/tests/ahriman/core/repository/test_executor.py b/tests/ahriman/core/repository/test_executor.py index d8ca4e7c..b9b48c89 100644 --- a/tests/ahriman/core/repository/test_executor.py +++ b/tests/ahriman/core/repository/test_executor.py @@ -68,7 +68,7 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke # must remove via alpm wrapper repo_remove_mock.assert_called_once() # must update status and remove package files - tree_clear_mock.assert_called_with(package_ahriman.base) + tree_clear_mock.assert_called_once_with(package_ahriman.base) status_client_mock.assert_called_once() @@ -218,7 +218,7 @@ def test_process_update_group(executor: Executor, package_python_schedule: Packa mock.call(executor.paths.repository / package.filepath) for package in package_python_schedule.packages.values() ], any_order=True) - status_client_mock.assert_called_with(package_python_schedule) + status_client_mock.assert_called_once_with(package_python_schedule) def test_process_empty_filename(executor: Executor, package_ahriman: Package, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/core/status/test_client.py b/tests/ahriman/core/status/test_client.py index 60e7f573..fb6e84eb 100644 --- a/tests/ahriman/core/status/test_client.py +++ b/tests/ahriman/core/status/test_client.py @@ -96,7 +96,7 @@ def test_set_building(client: Client, package_ahriman: Package, mocker: MockerFi update_mock = mocker.patch("ahriman.core.status.client.Client.update") client.set_building(package_ahriman.base) - update_mock.assert_called_with(package_ahriman.base, BuildStatusEnum.Building) + update_mock.assert_called_once_with(package_ahriman.base, BuildStatusEnum.Building) def test_set_failed(client: Client, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -106,7 +106,7 @@ def test_set_failed(client: Client, package_ahriman: Package, mocker: MockerFixt update_mock = mocker.patch("ahriman.core.status.client.Client.update") client.set_failed(package_ahriman.base) - update_mock.assert_called_with(package_ahriman.base, BuildStatusEnum.Failed) + update_mock.assert_called_once_with(package_ahriman.base, BuildStatusEnum.Failed) def test_set_pending(client: Client, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -116,7 +116,7 @@ def test_set_pending(client: Client, package_ahriman: Package, mocker: MockerFix update_mock = mocker.patch("ahriman.core.status.client.Client.update") client.set_pending(package_ahriman.base) - update_mock.assert_called_with(package_ahriman.base, BuildStatusEnum.Pending) + update_mock.assert_called_once_with(package_ahriman.base, BuildStatusEnum.Pending) def test_set_success(client: Client, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -126,7 +126,7 @@ def test_set_success(client: Client, package_ahriman: Package, mocker: MockerFix add_mock = mocker.patch("ahriman.core.status.client.Client.add") client.set_success(package_ahriman) - add_mock.assert_called_with(package_ahriman, BuildStatusEnum.Success) + add_mock.assert_called_once_with(package_ahriman, BuildStatusEnum.Success) def test_set_unknown(client: Client, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -136,4 +136,4 @@ def test_set_unknown(client: Client, package_ahriman: Package, mocker: MockerFix add_mock = mocker.patch("ahriman.core.status.client.Client.add") client.set_unknown(package_ahriman) - add_mock.assert_called_with(package_ahriman, BuildStatusEnum.Unknown) + add_mock.assert_called_once_with(package_ahriman, BuildStatusEnum.Unknown) diff --git a/tests/ahriman/core/status/test_web_client.py b/tests/ahriman/core/status/test_web_client.py index 22d1f5cb..31fbc42e 100644 --- a/tests/ahriman/core/status/test_web_client.py +++ b/tests/ahriman/core/status/test_web_client.py @@ -53,7 +53,7 @@ def test_login(web_client: WebClient, user: User, mocker: MockerFixture) -> None } web_client._login() - requests_mock.assert_called_with(pytest.helpers.anyvar(str, True), json=payload) + requests_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), json=payload) def test_login_failed(web_client: WebClient, user: User, mocker: MockerFixture) -> None: @@ -99,7 +99,7 @@ def test_add(web_client: WebClient, package_ahriman: Package, mocker: MockerFixt payload = pytest.helpers.get_package_status(package_ahriman) web_client.add(package_ahriman, BuildStatusEnum.Unknown) - requests_mock.assert_called_with(pytest.helpers.anyvar(str, True), json=payload) + requests_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), json=payload) def test_add_failed(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -237,7 +237,7 @@ def test_reload_auth(web_client: WebClient, mocker: MockerFixture) -> None: requests_mock = mocker.patch("requests.Session.post") web_client.reload_auth() - requests_mock.assert_called_with(pytest.helpers.anyvar(str, True)) + requests_mock.assert_called_once_with(pytest.helpers.anyvar(str, True)) def test_reload_auth_failed(web_client: WebClient, mocker: MockerFixture) -> None: @@ -263,7 +263,7 @@ def test_remove(web_client: WebClient, package_ahriman: Package, mocker: MockerF requests_mock = mocker.patch("requests.Session.delete") web_client.remove(package_ahriman.base) - requests_mock.assert_called_with(pytest.helpers.anyvar(str, True)) + requests_mock.assert_called_once_with(pytest.helpers.anyvar(str, True)) def test_remove_failed(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -289,7 +289,8 @@ def test_update(web_client: WebClient, package_ahriman: Package, mocker: MockerF requests_mock = mocker.patch("requests.Session.post") web_client.update(package_ahriman.base, BuildStatusEnum.Unknown) - requests_mock.assert_called_with(pytest.helpers.anyvar(str, True), json={"status": BuildStatusEnum.Unknown.value}) + requests_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), json={ + "status": BuildStatusEnum.Unknown.value}) def test_update_failed(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None: @@ -315,7 +316,8 @@ def test_update_self(web_client: WebClient, mocker: MockerFixture) -> None: requests_mock = mocker.patch("requests.Session.post") web_client.update_self(BuildStatusEnum.Unknown) - requests_mock.assert_called_with(pytest.helpers.anyvar(str, True), json={"status": BuildStatusEnum.Unknown.value}) + requests_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), json={ + "status": BuildStatusEnum.Unknown.value}) def test_update_self_failed(web_client: WebClient, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/core/test_configuration.py b/tests/ahriman/core/test_configuration.py index f4064265..22ebff8f 100644 --- a/tests/ahriman/core/test_configuration.py +++ b/tests/ahriman/core/test_configuration.py @@ -19,7 +19,7 @@ def test_from_path(mocker: MockerFixture) -> None: configuration = Configuration.from_path(path, "x86_64", True) assert configuration.path == path - read_mock.assert_called_with(path) + read_mock.assert_called_once_with(path) load_includes_mock.assert_called_once() load_logging_mock.assert_called_once() diff --git a/tests/ahriman/core/test_spawn.py b/tests/ahriman/core/test_spawn.py index 695dda61..24c02a15 100644 --- a/tests/ahriman/core/test_spawn.py +++ b/tests/ahriman/core/test_spawn.py @@ -14,7 +14,7 @@ def test_process(spawner: Spawn) -> None: spawner.process(callback, args, spawner.architecture, "id", spawner.queue) - callback.assert_called_with(args, spawner.architecture) + callback.assert_called_once_with(args, spawner.architecture) (uuid, status) = spawner.queue.get() assert uuid == "id" assert status @@ -42,7 +42,7 @@ def test_packages_add(spawner: Spawn, mocker: MockerFixture) -> None: """ spawn_mock = mocker.patch("ahriman.core.spawn.Spawn.spawn_process") spawner.packages_add(["ahriman", "linux"], now=False) - spawn_mock.assert_called_with("add", "ahriman", "linux", source="aur") + spawn_mock.assert_called_once_with("add", "ahriman", "linux", source="aur") def test_packages_add_with_build(spawner: Spawn, mocker: MockerFixture) -> None: @@ -51,7 +51,7 @@ def test_packages_add_with_build(spawner: Spawn, mocker: MockerFixture) -> None: """ spawn_mock = mocker.patch("ahriman.core.spawn.Spawn.spawn_process") spawner.packages_add(["ahriman", "linux"], now=True) - spawn_mock.assert_called_with("add", "ahriman", "linux", source="aur", now="") + spawn_mock.assert_called_once_with("add", "ahriman", "linux", source="aur", now="") def test_packages_remove(spawner: Spawn, mocker: MockerFixture) -> None: @@ -60,7 +60,7 @@ def test_packages_remove(spawner: Spawn, mocker: MockerFixture) -> None: """ spawn_mock = mocker.patch("ahriman.core.spawn.Spawn.spawn_process") spawner.packages_remove(["ahriman", "linux"]) - spawn_mock.assert_called_with("remove", "ahriman", "linux") + spawn_mock.assert_called_once_with("remove", "ahriman", "linux") def test_spawn_process(spawner: Spawn, mocker: MockerFixture) -> None: @@ -71,7 +71,7 @@ def test_spawn_process(spawner: Spawn, mocker: MockerFixture) -> None: spawner.spawn_process("add", "ahriman", now="", maybe="?") start_mock.assert_called_once() - spawner.args_parser.parse_args.assert_called_with([ + spawner.args_parser.parse_args.assert_called_once_with([ "--architecture", spawner.architecture, "--configuration", str(spawner.configuration.path), "add", "ahriman", "--now", "--maybe", "?" ]) diff --git a/tests/ahriman/core/upload/test_github.py b/tests/ahriman/core/upload/test_github.py index a864b88a..e30b27e3 100644 --- a/tests/ahriman/core/upload/test_github.py +++ b/tests/ahriman/core/upload/test_github.py @@ -70,7 +70,7 @@ def test_asset_remove(github: Github, github_release: Dict[str, Any], mocker: Mo """ request_mock = mocker.patch("ahriman.core.upload.github.Github._request") github.asset_remove(github_release, "asset_name") - request_mock.assert_called_with("DELETE", "asset_url") + request_mock.assert_called_once_with("DELETE", "asset_url") def test_asset_remove_unknown(github: Github, github_release: Dict[str, Any], mocker: MockerFixture) -> None: @@ -91,8 +91,8 @@ def test_asset_upload(github: Github, github_release: Dict[str, Any], mocker: Mo remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove") github.asset_upload(github_release, Path("/root/new.tar.xz")) - request_mock.assert_called_with("POST", "upload_url", params={"name": "new.tar.xz"}, - data=b"", headers={"Content-Type": "application/x-tar"}) + request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"}, + data=b"", headers={"Content-Type": "application/x-tar"}) remove_mock.assert_not_called() @@ -105,10 +105,11 @@ def test_asset_upload_with_removal(github: Github, github_release: Dict[str, Any remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove") github.asset_upload(github_release, Path("asset_name")) - remove_mock.assert_called_with(github_release, "asset_name") - github.asset_upload(github_release, Path("/root/asset_name")) - remove_mock.assert_called_with(github_release, "asset_name") + remove_mock.assert_has_calls([ + mock.call(github_release, "asset_name"), + mock.call(github_release, "asset_name"), + ]) def test_asset_upload_empty_mimetype(github: Github, github_release: Dict[str, Any], mocker: MockerFixture) -> None: @@ -121,8 +122,8 @@ def test_asset_upload_empty_mimetype(github: Github, github_release: Dict[str, A request_mock = mocker.patch("ahriman.core.upload.github.Github._request") github.asset_upload(github_release, Path("/root/new.tar.xz")) - request_mock.assert_called_with("POST", "upload_url", params={"name": "new.tar.xz"}, - data=b"", headers={"Content-Type": "application/octet-stream"}) + request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"}, + data=b"", headers={"Content-Type": "application/octet-stream"}) def test_get_local_files(github: Github, resource_path_root: Path, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/web/middlewares/test_auth_handler.py b/tests/ahriman/web/middlewares/test_auth_handler.py index 40498b8e..148dc58e 100644 --- a/tests/ahriman/web/middlewares/test_auth_handler.py +++ b/tests/ahriman/web/middlewares/test_auth_handler.py @@ -37,7 +37,7 @@ async def test_permits(authorization_policy: AuthorizationPolicy, user: User) -> authorization_policy.validator.verify_access.side_effect = lambda username, *args: username == user.username assert await authorization_policy.permits(_identity(user.username), user.access, "/endpoint") - authorization_policy.validator.verify_access.assert_called_with(user.username, user.access, "/endpoint") + authorization_policy.validator.verify_access.assert_called_once_with(user.username, user.access, "/endpoint") assert not await authorization_policy.permits(_identity("somerandomname"), user.access, "/endpoint") assert not await authorization_policy.permits(user.username, user.access, "/endpoint") @@ -54,7 +54,7 @@ async def test_auth_handler_api(mocker: MockerFixture) -> None: handler = auth_handler() await handler(aiohttp_request, request_handler) - check_permission_mock.assert_called_with(aiohttp_request, UserAccess.Read, aiohttp_request.path) + check_permission_mock.assert_called_once_with(aiohttp_request, UserAccess.Read, aiohttp_request.path) async def test_auth_handler_api_no_method(mocker: MockerFixture) -> None: @@ -68,7 +68,7 @@ async def test_auth_handler_api_no_method(mocker: MockerFixture) -> None: handler = auth_handler() await handler(aiohttp_request, request_handler) - check_permission_mock.assert_called_with(aiohttp_request, UserAccess.Write, aiohttp_request.path) + check_permission_mock.assert_called_once_with(aiohttp_request, UserAccess.Write, aiohttp_request.path) async def test_auth_handler_api_post(mocker: MockerFixture) -> None: @@ -82,7 +82,7 @@ async def test_auth_handler_api_post(mocker: MockerFixture) -> None: handler = auth_handler() await handler(aiohttp_request, request_handler) - check_permission_mock.assert_called_with(aiohttp_request, UserAccess.Write, aiohttp_request.path) + check_permission_mock.assert_called_once_with(aiohttp_request, UserAccess.Write, aiohttp_request.path) async def test_auth_handler_read(mocker: MockerFixture) -> None: @@ -97,7 +97,7 @@ async def test_auth_handler_read(mocker: MockerFixture) -> None: handler = auth_handler() await handler(aiohttp_request, request_handler) - check_permission_mock.assert_called_with(aiohttp_request, UserAccess.Read, aiohttp_request.path) + check_permission_mock.assert_called_once_with(aiohttp_request, UserAccess.Read, aiohttp_request.path) async def test_auth_handler_write(mocker: MockerFixture) -> None: @@ -112,7 +112,7 @@ async def test_auth_handler_write(mocker: MockerFixture) -> None: handler = auth_handler() await handler(aiohttp_request, request_handler) - check_permission_mock.assert_called_with(aiohttp_request, UserAccess.Write, aiohttp_request.path) + check_permission_mock.assert_called_once_with(aiohttp_request, UserAccess.Write, aiohttp_request.path) def test_setup_auth(application_with_auth: web.Application, auth: Auth, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/web/test_web.py b/tests/ahriman/web/test_web.py index e2edd8db..515e5ae7 100644 --- a/tests/ahriman/web/test_web.py +++ b/tests/ahriman/web/test_web.py @@ -39,8 +39,8 @@ def test_run(application: web.Application, mocker: MockerFixture) -> None: run_application_mock = mocker.patch("aiohttp.web.run_app") run_server(application) - run_application_mock.assert_called_with(application, host="127.0.0.1", port=port, - handle_signals=False, access_log=pytest.helpers.anyvar(int)) + run_application_mock.assert_called_once_with(application, host="127.0.0.1", port=port, + handle_signals=False, access_log=pytest.helpers.anyvar(int)) def test_run_with_auth(application_with_auth: web.Application, mocker: MockerFixture) -> None: @@ -52,8 +52,8 @@ def test_run_with_auth(application_with_auth: web.Application, mocker: MockerFix run_application_mock = mocker.patch("aiohttp.web.run_app") run_server(application_with_auth) - run_application_mock.assert_called_with(application_with_auth, host="127.0.0.1", port=port, - handle_signals=False, access_log=pytest.helpers.anyvar(int)) + run_application_mock.assert_called_once_with(application_with_auth, host="127.0.0.1", port=port, + handle_signals=False, access_log=pytest.helpers.anyvar(int)) def test_run_with_debug(application_with_debug: web.Application, mocker: MockerFixture) -> None: @@ -65,5 +65,5 @@ def test_run_with_debug(application_with_debug: web.Application, mocker: MockerF run_application_mock = mocker.patch("aiohttp.web.run_app") run_server(application_with_debug) - run_application_mock.assert_called_with(application_with_debug, host="127.0.0.1", port=port, - handle_signals=False, access_log=pytest.helpers.anyvar(int)) + run_application_mock.assert_called_once_with(application_with_debug, host="127.0.0.1", port=port, + handle_signals=False, access_log=pytest.helpers.anyvar(int)) diff --git a/tests/ahriman/web/views/service/test_views_service_add.py b/tests/ahriman/web/views/service/test_views_service_add.py index 592e3aba..f989fa0c 100644 --- a/tests/ahriman/web/views/service/test_views_service_add.py +++ b/tests/ahriman/web/views/service/test_views_service_add.py @@ -24,7 +24,7 @@ async def test_post(client: TestClient, mocker: MockerFixture) -> None: response = await client.post("/service-api/v1/add", json={"packages": ["ahriman"]}) assert response.ok - add_mock.assert_called_with(["ahriman"], now=True) + add_mock.assert_called_once_with(["ahriman"], now=True) async def test_post_exception(client: TestClient, mocker: MockerFixture) -> None: @@ -46,4 +46,4 @@ async def test_post_update(client: TestClient, mocker: MockerFixture) -> None: response = await client.post("/service-api/v1/update", json={"packages": ["ahriman"]}) assert response.ok - add_mock.assert_called_with(["ahriman"], now=True) + add_mock.assert_called_once_with(["ahriman"], now=True) diff --git a/tests/ahriman/web/views/service/test_views_service_reload_auth.py b/tests/ahriman/web/views/service/test_views_service_reload_auth.py index 5594c366..4f4b7443 100644 --- a/tests/ahriman/web/views/service/test_views_service_reload_auth.py +++ b/tests/ahriman/web/views/service/test_views_service_reload_auth.py @@ -27,7 +27,7 @@ async def test_post(client_with_auth: TestClient, mocker: MockerFixture) -> None assert response.ok reload_mock.assert_called_once() - load_mock.assert_called_with(client_with_auth.app["configuration"]) + load_mock.assert_called_once_with(client_with_auth.app["configuration"]) async def test_post_no_auth(client: TestClient, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/web/views/service/test_views_service_remove.py b/tests/ahriman/web/views/service/test_views_service_remove.py index 3f60aa1a..0aedaef8 100644 --- a/tests/ahriman/web/views/service/test_views_service_remove.py +++ b/tests/ahriman/web/views/service/test_views_service_remove.py @@ -24,7 +24,7 @@ async def test_post(client: TestClient, mocker: MockerFixture) -> None: response = await client.post("/service-api/v1/remove", json={"packages": ["ahriman"]}) assert response.ok - remove_mock.assert_called_with(["ahriman"]) + remove_mock.assert_called_once_with(["ahriman"]) async def test_post_exception(client: TestClient, mocker: MockerFixture) -> None: diff --git a/tests/ahriman/web/views/service/test_views_service_request.py b/tests/ahriman/web/views/service/test_views_service_request.py index 550ba926..0d0390ad 100644 --- a/tests/ahriman/web/views/service/test_views_service_request.py +++ b/tests/ahriman/web/views/service/test_views_service_request.py @@ -24,7 +24,7 @@ async def test_post(client: TestClient, mocker: MockerFixture) -> None: response = await client.post("/service-api/v1/request", json={"packages": ["ahriman"]}) assert response.ok - add_mock.assert_called_with(["ahriman"], now=False) + add_mock.assert_called_once_with(["ahriman"], now=False) async def test_post_exception(client: TestClient, mocker: MockerFixture) -> None: 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 fca7c088..2296d91c 100644 --- a/tests/ahriman/web/views/service/test_views_service_search.py +++ b/tests/ahriman/web/views/service/test_views_service_search.py @@ -48,7 +48,7 @@ async def test_get_join(client: TestClient, mocker: MockerFixture) -> None: response = await client.get("/service-api/v1/search", params=[("for", "ahriman"), ("for", "maybe")]) assert response.ok - search_mock.assert_called_with("ahriman maybe") + search_mock.assert_called_once_with("ahriman maybe") async def test_get_join_filter(client: TestClient, mocker: MockerFixture) -> None: @@ -59,7 +59,7 @@ async def test_get_join_filter(client: TestClient, mocker: MockerFixture) -> Non response = await client.get("/service-api/v1/search", params=[("for", "ah"), ("for", "maybe")]) assert response.ok - search_mock.assert_called_with("maybe") + search_mock.assert_called_once_with("maybe") async def test_get_join_filter_empty(client: TestClient, mocker: MockerFixture) -> None: 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 6e4608d1..de980e36 100644 --- a/tests/ahriman/web/views/user/test_views_user_login.py +++ b/tests/ahriman/web/views/user/test_views_user_login.py @@ -64,8 +64,8 @@ async def test_get(client_with_auth: TestClient, mocker: MockerFixture) -> None: get_response = await client_with_auth.get("/user-api/v1/login", params={"code": "code"}) assert get_response.ok - oauth.get_oauth_username.assert_called_with("code") - oauth.known_username.assert_called_with("user") + oauth.get_oauth_username.assert_called_once_with("code") + oauth.known_username.assert_called_once_with("user") remember_mock.assert_called_once()