mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
fix some pylint warnings in tests
This commit is contained in:
parent
ce7a8fde3c
commit
bfe37dbac0
@ -27,7 +27,7 @@ def test_path(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
args.lock = Path("/")
|
||||
Lock(args, repository_id, configuration).path # special case
|
||||
assert Lock(args, repository_id, configuration).path # special case
|
||||
|
||||
|
||||
def test_check_user(lock: Lock, mocker: MockerFixture) -> None:
|
||||
@ -205,7 +205,7 @@ def test_exit_with_exception(lock: Lock, mocker: MockerFixture) -> None:
|
||||
mocker.patch("ahriman.application.lock.Lock.create")
|
||||
update_status_mock = mocker.patch("ahriman.core.status.Client.status_update")
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(ValueError):
|
||||
with lock:
|
||||
raise Exception()
|
||||
raise ValueError()
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Failed)])
|
||||
|
@ -128,7 +128,7 @@ def test_database_copy_database_exist(pacman: Pacman, mocker: MockerFixture) ->
|
||||
copy_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_database_init(pacman: Pacman, configuration: Configuration) -> None:
|
||||
def test_database_init(pacman: Pacman) -> None:
|
||||
"""
|
||||
must init database with settings
|
||||
"""
|
||||
@ -184,14 +184,15 @@ def test_files(pacman: Pacman, package_ahriman: Package, mocker: MockerFixture,
|
||||
pacman.handle = handle_mock
|
||||
tarball = resource_path_root / "core" / "arcanisrepo.files.tar.gz"
|
||||
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
open_mock = mocker.patch("ahriman.core.alpm.pacman.tarfile.open", return_value=tarfile.open(tarball, "r:gz"))
|
||||
with tarfile.open(tarball, "r:gz") as fd:
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
open_mock = mocker.patch("ahriman.core.alpm.pacman.tarfile.open", return_value=fd)
|
||||
|
||||
files = pacman.files()
|
||||
assert len(files) == 2
|
||||
assert package_ahriman.base in files
|
||||
assert "usr/bin/ahriman" in files[package_ahriman.base]
|
||||
open_mock.assert_called_once_with(pytest.helpers.anyvar(int), "r:gz")
|
||||
files = pacman.files()
|
||||
assert len(files) == 2
|
||||
assert package_ahriman.base in files
|
||||
assert "usr/bin/ahriman" in files[package_ahriman.base]
|
||||
open_mock.assert_called_once_with(pytest.helpers.anyvar(int), "r:gz")
|
||||
|
||||
|
||||
def test_files_package(pacman: Pacman, package_ahriman: Package, mocker: MockerFixture,
|
||||
@ -205,12 +206,13 @@ def test_files_package(pacman: Pacman, package_ahriman: Package, mocker: MockerF
|
||||
|
||||
tarball = resource_path_root / "core" / "arcanisrepo.files.tar.gz"
|
||||
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
mocker.patch("ahriman.core.alpm.pacman.tarfile.open", return_value=tarfile.open(tarball, "r:gz"))
|
||||
with tarfile.open(tarball, "r:gz") as fd:
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
mocker.patch("ahriman.core.alpm.pacman.tarfile.open", return_value=fd)
|
||||
|
||||
files = pacman.files(package_ahriman.base)
|
||||
assert len(files) == 1
|
||||
assert package_ahriman.base in files
|
||||
files = pacman.files(package_ahriman.base)
|
||||
assert len(files) == 1
|
||||
assert package_ahriman.base in files
|
||||
|
||||
|
||||
def test_files_skip(pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
|
@ -165,7 +165,6 @@ def test_package_update_remove_get(database: SQLite, package_ahriman: Package) -
|
||||
"""
|
||||
must insert, remove and retrieve package
|
||||
"""
|
||||
status = BuildStatus()
|
||||
database.package_update(package_ahriman)
|
||||
database.package_remove(package_ahriman.base)
|
||||
assert not database.packages_get()
|
||||
|
@ -68,9 +68,9 @@ def test_in_package_context_failed(database: SQLite, package_ahriman: Package, m
|
||||
mocker.patch("ahriman.core.log.LazyLogging._package_logger_set")
|
||||
reset_mock = mocker.patch("ahriman.core.log.LazyLogging._package_logger_reset")
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(ValueError):
|
||||
with database.in_package_context(package_ahriman.base, ""):
|
||||
raise Exception()
|
||||
raise ValueError()
|
||||
|
||||
reset_mock.assert_called_once_with()
|
||||
|
||||
@ -81,11 +81,3 @@ def test_logger(database: SQLite) -> None:
|
||||
"""
|
||||
assert database.logger
|
||||
assert database.logger.name == "ahriman.core.database.sqlite.SQLite"
|
||||
|
||||
|
||||
def test_logger_attribute_error(database: SQLite) -> None:
|
||||
"""
|
||||
must raise AttributeError in case if no attribute found
|
||||
"""
|
||||
with pytest.raises(AttributeError):
|
||||
database.loggerrrr
|
||||
|
@ -4,7 +4,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.status.local_client import LocalClient
|
||||
from ahriman.models.build_status import BuildStatusEnum, BuildStatus
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.changes import Changes
|
||||
from ahriman.models.dependencies import Dependencies
|
||||
from ahriman.models.log_record_id import LogRecordId
|
||||
|
@ -2,7 +2,6 @@ import datetime
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
import shlex
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
@ -60,4 +60,4 @@ def test_lt_invalid() -> None:
|
||||
must raise ValueError if other is not valid repository id
|
||||
"""
|
||||
with pytest.raises(ValueError):
|
||||
RepositoryId("x86_64", "a") < 42
|
||||
assert RepositoryId("x86_64", "a") < 42
|
||||
|
@ -30,7 +30,7 @@ async def test_get(client: TestClient, repository_id: RepositoryId) -> None:
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(InfoView.get)
|
||||
|
||||
response = await client.get(f"/api/v1/info")
|
||||
response = await client.get("/api/v1/info")
|
||||
assert response.ok
|
||||
json = await response.json()
|
||||
assert not response_schema.validate(json)
|
||||
|
@ -29,7 +29,7 @@ async def test_get(client: TestClient, repository_id: RepositoryId) -> None:
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(RepositoriesView.get)
|
||||
|
||||
response = await client.get(f"/api/v1/repositories")
|
||||
response = await client.get("/api/v1/repositories")
|
||||
assert response.ok
|
||||
json = await response.json()
|
||||
assert not response_schema.validate(json, many=True)
|
||||
|
Loading…
Reference in New Issue
Block a user