style: fix some typos and warnings

This commit is contained in:
2024-11-11 18:07:13 +02:00
parent 4b5a645f8d
commit 20e7ba3b1d
20 changed files with 32 additions and 30 deletions

View File

@ -53,7 +53,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
def test_run_remove(args: argparse.Namespace, configuration: Configuration, repository: Repository,
package_ahriman: Package, mocker: MockerFixture) -> None:
"""
must run command and remove packages afterwards
must run command and remove packages afterward
"""
args = _default_args(args)
args.remove = True

View File

@ -191,7 +191,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 from database
must extract packages from database
"""
packages_mock = mocker.patch("ahriman.core.database.SQLite.packages_get")
Rebuild.extract_packages(application, None, from_database=True)

View File

@ -5,7 +5,7 @@ from pathlib import Path
from pytest_mock import MockerFixture
from typing import Any
from unittest.mock import call as MockCall
from urllib.parse import quote_plus as urlencode
from urllib.parse import quote_plus as url_encode
from ahriman.application.handlers.setup import Setup
from ahriman.core.configuration import Configuration
@ -148,7 +148,7 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
MockCall("web", "port", str(args.web_port)),
MockCall("status", "address", f"http://127.0.0.1:{str(args.web_port)}"),
MockCall("web", "unix_socket", str(args.web_unix_socket)),
MockCall("status", "address", f"http+unix://{urlencode(str(args.web_unix_socket))}"),
MockCall("status", "address", f"http+unix://{url_encode(str(args.web_unix_socket))}"),
MockCall("auth", "salt", pytest.helpers.anyvar(str, strict=True)),
])
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))

View File

@ -392,7 +392,7 @@ def test_subparsers_package_status_update(parser: argparse.ArgumentParser) -> No
def test_subparsers_package_status_update_option_status(parser: argparse.ArgumentParser) -> None:
"""
package-status-update command must convert status option to buildstatusenum instance
package-status-update command must convert status option to BuildStatusEnum instance
"""
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "package-status-update"])
assert isinstance(args.status, BuildStatusEnum)

View File

@ -115,7 +115,7 @@ def test_write_skip(lock: Lock) -> None:
def test_write_locked(lock: Lock, mocker: MockerFixture) -> None:
"""
must raise DuplicateRunError if cannot lock file
must raise DuplicateRunError if it cannot lock file
"""
mocker.patch("ahriman.application.lock.Lock.perform_lock", return_value=False)
with pytest.raises(DuplicateRunError):

View File

@ -287,6 +287,7 @@ def local_client(database: SQLite, configuration: Configuration) -> Client:
Args:
database(SQLite): database fixture
configuration(Configuration): configuration fixture
Returns:
Client: local status client test instance

View File

@ -77,7 +77,7 @@ async def test_known_username(pam: PAM, user: User, mocker: MockerFixture) -> No
async def test_known_username_mapping(pam: PAM, user: User, mocker: MockerFixture) -> None:
"""
must fallback to username checking to database if no user found in system
must fall back to username checking to database if no user found in system
"""
mocker.patch("ahriman.core.auth.pam.getpwnam", side_effect=KeyError)
mapping_mock = mocker.patch("ahriman.core.auth.mapping.Mapping.known_username")

View File

@ -32,6 +32,7 @@ def test_process_build(executor: Executor, package_ahriman: Package, passwd: Any
executor.process_build([package_ahriman], Packagers("packager"), bump_pkgrel=False)
init_mock.assert_called_once_with(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int), None)
changes_mock.assert_called_once_with(package_ahriman.base)
depends_on_mock.assert_called_once_with()
dependencies_mock.assert_called_once_with(package_ahriman.base, Dependencies())
# must move files (once)

View File

@ -136,7 +136,7 @@ def test_event_add_failed_http_error(web_client: WebClient, mocker: MockerFixtur
def test_event_add_failed_suppress(web_client: WebClient, mocker: MockerFixture) -> None:
"""
must suppress any exception happened during events creaton and don't log
must suppress any exception happened during events creation and don't log
"""
web_client.suppress_errors = True
mocker.patch("requests.Session.request", side_effect=Exception())

View File

@ -5,7 +5,7 @@ from ahriman.models.scan_paths import ScanPaths
def test_is_allowed() -> None:
"""
must check if path is subpath of one in allowed list
must check if path is sub-path of one in allowed list
"""
assert ScanPaths(["usr"]).is_allowed(Path("usr"))
assert ScanPaths(["usr"]).is_allowed(Path("usr") / "lib")

View File

@ -252,6 +252,6 @@ async def test_username_request(base: BaseView) -> None:
async def test_username_request_exception(base: BaseView) -> None:
"""
must not fail in case if cannot read request
must not fail in case if it cannot read request
"""
assert await base.username() is None