mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-23 23:07:17 +00:00
fix descriptions
This commit is contained in:
parent
8f18ead4cc
commit
4990ce4198
@ -67,7 +67,8 @@ class Packages(Properties):
|
||||
:param without_dependencies: if set, dependency check will be disabled
|
||||
"""
|
||||
package = Package.load(source, PackageSource.AUR, self.repository.pacman, self.repository.aur_url)
|
||||
self.repository.database.build_queue_insert(package)
|
||||
|
||||
self.database.build_queue_insert(package)
|
||||
|
||||
with tmpdir() as local_path:
|
||||
Sources.load(local_path, package.git_url, self.database.patches_get(package.base))
|
||||
@ -93,7 +94,8 @@ class Packages(Properties):
|
||||
cache_dir = self.repository.paths.cache_for(package.base)
|
||||
shutil.copytree(Path(source), cache_dir) # copy package to store in caches
|
||||
Sources.init(cache_dir) # we need to run init command in directory where we do have permissions
|
||||
self.repository.database.build_queue_insert(package)
|
||||
|
||||
self.database.build_queue_insert(package)
|
||||
|
||||
self._process_dependencies(cache_dir, known_packages, without_dependencies)
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
from sqlite3 import Connection
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.data.package_statuses import migrate_package_statuses
|
||||
from ahriman.core.database.data.patches import migrate_patches
|
||||
from ahriman.core.database.data.users import migrate_users_data
|
||||
from ahriman.core.database.data.package_statuses import migrate_package_statuses
|
||||
from ahriman.models.migration_result import MigrationResult
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
@ -37,7 +37,7 @@ def migrate_data(result: MigrationResult, connection: Connection,
|
||||
:param paths: repository paths instance
|
||||
"""
|
||||
# initial data migration
|
||||
if result.old_version == 0:
|
||||
if result.old_version <= 0:
|
||||
migrate_package_statuses(connection, paths)
|
||||
migrate_users_data(connection, configuration)
|
||||
migrate_patches(connection, paths)
|
||||
migrate_users_data(connection, configuration)
|
||||
|
@ -17,8 +17,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlite3 import Connection
|
||||
from typing import List, Optional
|
||||
|
||||
@ -75,7 +73,7 @@ class AuthOperations(Operations):
|
||||
|
||||
def user_update(self, user: User) -> None:
|
||||
"""
|
||||
get user by username
|
||||
update user by username
|
||||
:param user: user descriptor
|
||||
"""
|
||||
def run(connection: Connection) -> None:
|
||||
|
@ -22,6 +22,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import sqlite3
|
||||
|
||||
from pathlib import Path
|
||||
from sqlite3 import Connection
|
||||
from typing import Type
|
||||
|
||||
@ -46,10 +47,20 @@ class SQLite(AuthOperations, BuildOperations, PackageOperations, PatchOperations
|
||||
:param configuration: configuration instance
|
||||
:return: fully initialized instance of the database
|
||||
"""
|
||||
database = cls(configuration.getpath("settings", "database"))
|
||||
path = cls.database_path(configuration)
|
||||
database = cls(path)
|
||||
database.init(configuration)
|
||||
return database
|
||||
|
||||
@staticmethod
|
||||
def database_path(configuration: Configuration) -> Path:
|
||||
"""
|
||||
read database from configuration
|
||||
:param configuration: configuration instance
|
||||
:return: database path according to the configuration
|
||||
"""
|
||||
return configuration.getpath("settings", "database")
|
||||
|
||||
def init(self, configuration: Configuration) -> None:
|
||||
"""
|
||||
perform database migrations
|
||||
|
@ -35,6 +35,7 @@ class PackageSource(Enum):
|
||||
:cvar Directory: source is a directory which contains packages
|
||||
:cvar Local: source is locally stored PKGBUILD
|
||||
:cvar Remote: source is remote (http, ftp etc) link
|
||||
:cvar Repository: source is official repository
|
||||
"""
|
||||
|
||||
Auto = "auto"
|
||||
@ -43,6 +44,7 @@ class PackageSource(Enum):
|
||||
Directory = "directory"
|
||||
Local = "local"
|
||||
Remote = "remote"
|
||||
Repository = "repository"
|
||||
|
||||
def resolve(self, source: str) -> PackageSource:
|
||||
"""
|
||||
|
@ -21,7 +21,7 @@ def test_finalize(application_packages: Packages) -> None:
|
||||
|
||||
def test_known_packages(application_packages: Packages) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing finalize method
|
||||
must raise NotImplemented for missing known_packages method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_packages._known_packages()
|
||||
@ -42,17 +42,17 @@ def test_add_aur(application_packages: Packages, package_ahriman: Package, mocke
|
||||
must add package from AUR
|
||||
"""
|
||||
mocker.patch("ahriman.models.package.Package.load", return_value=package_ahriman)
|
||||
insert_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
|
||||
load_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.load")
|
||||
dependencies_mock = mocker.patch("ahriman.application.application.packages.Packages._process_dependencies")
|
||||
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
|
||||
|
||||
application_packages._add_aur(package_ahriman.base, set(), False)
|
||||
insert_mock.assert_called_once_with(package_ahriman)
|
||||
load_mock.assert_called_once_with(
|
||||
pytest.helpers.anyvar(int),
|
||||
package_ahriman.git_url,
|
||||
pytest.helpers.anyvar(int))
|
||||
dependencies_mock.assert_called_once_with(pytest.helpers.anyvar(int), set(), False)
|
||||
build_queue_mock.assert_called_once_with(package_ahriman)
|
||||
|
||||
|
||||
def test_add_directory(application_packages: Packages, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
@ -75,16 +75,16 @@ def test_add_local(application_packages: Packages, package_ahriman: Package, moc
|
||||
"""
|
||||
mocker.patch("ahriman.models.package.Package.load", return_value=package_ahriman)
|
||||
init_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.init")
|
||||
insert_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
|
||||
copytree_mock = mocker.patch("shutil.copytree")
|
||||
dependencies_mock = mocker.patch("ahriman.application.application.packages.Packages._process_dependencies")
|
||||
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
|
||||
|
||||
application_packages._add_local(package_ahriman.base, set(), False)
|
||||
copytree_mock.assert_called_once_with(
|
||||
Path(package_ahriman.base), application_packages.repository.paths.cache_for(package_ahriman.base))
|
||||
init_mock.assert_called_once_with(application_packages.repository.paths.cache_for(package_ahriman.base))
|
||||
insert_mock.assert_called_once_with(package_ahriman)
|
||||
dependencies_mock.assert_called_once_with(pytest.helpers.anyvar(int), set(), False)
|
||||
build_queue_mock.assert_called_once_with(package_ahriman)
|
||||
|
||||
|
||||
def test_add_remote(application_packages: Packages, package_description_ahriman: PackageDescription,
|
||||
|
@ -41,7 +41,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, aur_package
|
||||
|
||||
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
must raise ExitCode exception on empty result list
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.exit_code = True
|
||||
|
@ -62,7 +62,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
def test_run_verbose(args: argparse.Namespace, configuration: Configuration, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
must run command with detailed info
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.info = True
|
||||
|
@ -59,7 +59,7 @@ def test_check_unsafe() -> None:
|
||||
|
||||
def test_check_unsafe_safe() -> None:
|
||||
"""
|
||||
must check if command is unsafe
|
||||
must check if command is safe
|
||||
"""
|
||||
UnsafeCommands.check_unsafe("package-status", ["repo-clean"], _parser())
|
||||
|
||||
|
@ -34,7 +34,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
|
||||
def test_disallow_auto_architecture_run() -> None:
|
||||
"""
|
||||
must not allow multi architecture run
|
||||
must not allow auto architecture run
|
||||
"""
|
||||
assert not Web.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||
|
||||
|
@ -264,9 +264,7 @@ def repository_paths(configuration: Configuration) -> RepositoryPaths:
|
||||
:param configuration: configuration fixture
|
||||
:return: repository paths test instance
|
||||
"""
|
||||
return RepositoryPaths(
|
||||
architecture="x86_64",
|
||||
root=configuration.getpath("repository", "root"))
|
||||
return configuration.repository_paths
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -13,10 +13,12 @@ def test_migrate_data_initial(connection: Connection, configuration: Configurati
|
||||
must perform initial migration
|
||||
"""
|
||||
packages = mocker.patch("ahriman.core.database.data.migrate_package_statuses")
|
||||
patches = mocker.patch("ahriman.core.database.data.migrate_patches")
|
||||
users = mocker.patch("ahriman.core.database.data.migrate_users_data")
|
||||
|
||||
migrate_data(MigrationResult(old_version=0, new_version=900), connection, configuration, repository_paths)
|
||||
packages.assert_called_once_with(connection, repository_paths)
|
||||
patches.assert_called_once_with(connection, repository_paths)
|
||||
users.assert_called_once_with(connection, configuration)
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ def test_sign_ascii(package_ahriman: Package) -> None:
|
||||
|
||||
def test_sign_utf8(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must correctly generate sign in ascii
|
||||
must correctly generate sign in utf8
|
||||
"""
|
||||
with pytest.raises(UnicodeEncodeError):
|
||||
BuildPrinter(package_ahriman, is_success=True, use_utf=True).title().encode("ascii")
|
||||
@ -31,6 +31,6 @@ def test_sign_utf8(package_ahriman: Package) -> None:
|
||||
|
||||
def test_title(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return non empty title
|
||||
must return non-empty title
|
||||
"""
|
||||
assert BuildPrinter(package_ahriman, is_success=True, use_utf=False).title() is not None
|
||||
|
@ -115,7 +115,7 @@ def test_generate_with_built_and_full_path(
|
||||
result: Result,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate report with built packages
|
||||
must generate report with built packages and full packages lists
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
|
||||
|
@ -64,6 +64,8 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke
|
||||
mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman])
|
||||
tree_clear_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_clear")
|
||||
repo_remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove")
|
||||
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear")
|
||||
patches_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_remove")
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.remove")
|
||||
|
||||
executor.process_remove([package_ahriman.base])
|
||||
@ -72,6 +74,8 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke
|
||||
package_ahriman.base, package_ahriman.packages[package_ahriman.base].filepath)
|
||||
# must update status and remove package files
|
||||
tree_clear_mock.assert_called_once_with(package_ahriman.base)
|
||||
build_queue_mock.assert_called_once_with(package_ahriman.base)
|
||||
patches_mock.assert_called_once_with(package_ahriman.base)
|
||||
status_client_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ def test_load_full_client(configuration: Configuration) -> None:
|
||||
|
||||
def test_load_full_client_from_address(configuration: Configuration) -> None:
|
||||
"""
|
||||
must load full client if settings set
|
||||
must load full client by using address
|
||||
"""
|
||||
configuration.set_option("web", "address", "http://localhost:8080")
|
||||
assert isinstance(Client.load(configuration), WebClient)
|
||||
|
@ -23,7 +23,7 @@ def test_ahriman_url(web_client: WebClient) -> None:
|
||||
|
||||
def test_status_url(web_client: WebClient) -> None:
|
||||
"""
|
||||
must generate service status url correctly
|
||||
must generate package status url correctly
|
||||
"""
|
||||
assert web_client._status_url.startswith(web_client.address)
|
||||
assert web_client._status_url.endswith("/status-api/v1/status")
|
||||
@ -67,7 +67,7 @@ def test_login_failed(web_client: WebClient, user: User, mocker: MockerFixture)
|
||||
|
||||
def test_login_failed_http_error(web_client: WebClient, user: User, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during login
|
||||
must suppress HTTP exception happened during login
|
||||
"""
|
||||
web_client.user = user
|
||||
mocker.patch("requests.Session.post", side_effect=requests.exceptions.HTTPError())
|
||||
@ -112,7 +112,7 @@ def test_add_failed(web_client: WebClient, package_ahriman: Package, mocker: Moc
|
||||
|
||||
def test_add_failed_http_error(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during addition
|
||||
must suppress HTTP exception happened during addition
|
||||
"""
|
||||
mocker.patch("requests.Session.post", side_effect=requests.exceptions.HTTPError())
|
||||
web_client.add(package_ahriman, BuildStatusEnum.Unknown)
|
||||
@ -145,7 +145,7 @@ def test_get_failed(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
|
||||
def test_get_failed_http_error(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during status getting
|
||||
must suppress HTTP exception happened during status getting
|
||||
"""
|
||||
mocker.patch("requests.Session.get", side_effect=requests.exceptions.HTTPError())
|
||||
assert web_client.get(None) == []
|
||||
@ -193,7 +193,7 @@ def test_get_internal_failed(web_client: WebClient, mocker: MockerFixture) -> No
|
||||
|
||||
def test_get_internal_failed_http_error(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during web service status getting
|
||||
must suppress HTTP exception happened during web service status getting
|
||||
"""
|
||||
mocker.patch("requests.Session.get", side_effect=requests.exceptions.HTTPError())
|
||||
assert web_client.get_internal() == InternalStatus()
|
||||
@ -224,7 +224,7 @@ def test_get_self_failed(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
|
||||
def test_get_self_failed_http_error(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during service status getting
|
||||
must suppress HTTP exception happened during service status getting
|
||||
"""
|
||||
mocker.patch("requests.Session.get", side_effect=requests.exceptions.HTTPError())
|
||||
assert web_client.get_self().status == BuildStatusEnum.Unknown
|
||||
@ -250,7 +250,7 @@ def test_remove_failed(web_client: WebClient, package_ahriman: Package, mocker:
|
||||
|
||||
def test_remove_failed_http_error(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during removal
|
||||
must suppress HTTP exception happened during removal
|
||||
"""
|
||||
mocker.patch("requests.Session.delete", side_effect=requests.exceptions.HTTPError())
|
||||
web_client.remove(package_ahriman.base)
|
||||
@ -277,7 +277,7 @@ def test_update_failed(web_client: WebClient, package_ahriman: Package, mocker:
|
||||
|
||||
def test_update_failed_http_error(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during update
|
||||
must suppress HTTP exception happened during update
|
||||
"""
|
||||
mocker.patch("requests.Session.post", side_effect=requests.exceptions.HTTPError())
|
||||
web_client.update(package_ahriman.base, BuildStatusEnum.Unknown)
|
||||
@ -304,7 +304,7 @@ def test_update_self_failed(web_client: WebClient, mocker: MockerFixture) -> Non
|
||||
|
||||
def test_update_self_failed_http_error(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during service update
|
||||
must suppress HTTP exception happened during service update
|
||||
"""
|
||||
mocker.patch("requests.Session.post", side_effect=requests.exceptions.HTTPError())
|
||||
web_client.update_self(BuildStatusEnum.Unknown)
|
||||
|
@ -231,7 +231,7 @@ def test_gettype_from_section_with_architecture(configuration: Configuration) ->
|
||||
|
||||
def test_gettype_from_section_no_section(configuration: Configuration) -> None:
|
||||
"""
|
||||
must extract type from section name with architecture
|
||||
must raise NoSectionError during type extraction from section name with architecture
|
||||
"""
|
||||
# technically rsync:x86_64 is valid section
|
||||
# but in current configuration it must be considered as missing section
|
||||
|
@ -19,7 +19,7 @@ def test_build_status_enum_badges_color() -> None:
|
||||
|
||||
def test_build_status_enum_bootstrap_color() -> None:
|
||||
"""
|
||||
status color must be one of shields.io supported
|
||||
status color must be one of bootstrap supported
|
||||
"""
|
||||
SUPPORTED_COLORS = [
|
||||
"primary", "secondary", "success", "danger", "warning", "info", "light", "dark"
|
||||
|
@ -281,7 +281,7 @@ def test_actual_version_srcinfo_failed(package_tpacpi_bat_git: Package, reposito
|
||||
def test_actual_version_vcs_failed(package_tpacpi_bat_git: Package, repository_paths: RepositoryPaths,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return same version in case if exception occurred
|
||||
must return same version in case if there are errors during parse
|
||||
"""
|
||||
mocker.patch("pathlib.Path.read_text", return_value="")
|
||||
mocker.patch("ahriman.models.package.parse_srcinfo", return_value=({"packages": {}}, ["an error"]))
|
||||
@ -292,7 +292,7 @@ def test_actual_version_vcs_failed(package_tpacpi_bat_git: Package, repository_p
|
||||
|
||||
|
||||
def test_full_depends(package_ahriman: Package, package_python_schedule: Package, pyalpm_package_ahriman: MagicMock,
|
||||
pyalpm_handle: MagicMock, mocker: MockerFixture) -> None:
|
||||
pyalpm_handle: MagicMock) -> None:
|
||||
"""
|
||||
must extract all dependencies from the package
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user