mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-29 13:49:57 +00:00
exactly one called with instead of last call check
This commit is contained in:
@ -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"
|
||||
|
||||
|
@ -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"))
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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", "?"
|
||||
])
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user