mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
* implement log storage at backend * handle process id during removal. During one process we can write logs from different packages in different times (e.g. check and update later) and we would like to store all logs belong to the same process * set package context in main functions * implement logs support in interface * filter out logs posting http logs * add timestamp to log records * hide getting logs under reporter permission List of breaking changes: * `ahriman.core.lazy_logging.LazyLogging` has been renamed to `ahriman.core.log.LazyLogging` * `ahriman.core.configuration.Configuration.from_path` does not have `quiet` attribute now * `ahriman.core.configuration.Configuration` class does not have `load_logging` method now * `ahriman.core.status.client.Client.load` requires `report` argument now
80 lines
2.0 KiB
Python
80 lines
2.0 KiB
Python
import logging
|
|
import pytest
|
|
|
|
from ahriman.core.alpm.repo import Repo
|
|
from ahriman.core.build_tools.task import Task
|
|
from ahriman.core.configuration import Configuration
|
|
from ahriman.core.tree import Leaf
|
|
from ahriman.models.package import Package
|
|
from ahriman.models.repository_paths import RepositoryPaths
|
|
|
|
|
|
@pytest.fixture
|
|
def leaf_ahriman(package_ahriman: Package) -> Leaf:
|
|
"""
|
|
fixture for tree leaf with package
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
|
|
Returns:
|
|
Leaf: tree leaf test instance
|
|
"""
|
|
return Leaf(package_ahriman, set())
|
|
|
|
|
|
@pytest.fixture
|
|
def leaf_python_schedule(package_python_schedule: Package) -> Leaf:
|
|
"""
|
|
fixture for tree leaf with package
|
|
|
|
Args:
|
|
package_python_schedule(Package): package fixture
|
|
|
|
Returns:
|
|
Leaf: tree leaf test instance
|
|
"""
|
|
return Leaf(package_python_schedule, set())
|
|
|
|
|
|
@pytest.fixture
|
|
def log_record() -> logging.LogRecord:
|
|
"""
|
|
fixture for log record object
|
|
|
|
Returns:
|
|
logging.LogRecord: log record test instance
|
|
"""
|
|
return logging.LogRecord("record", logging.INFO, "path", 42, "log message", args=(), exc_info=None)
|
|
|
|
|
|
@pytest.fixture
|
|
def repo(configuration: Configuration, repository_paths: RepositoryPaths) -> Repo:
|
|
"""
|
|
fixture for repository wrapper
|
|
|
|
Args:
|
|
configuration(Configuration): configuration fixture
|
|
repository_paths(RepositoryPaths): repository paths fixture
|
|
|
|
Returns:
|
|
Repo: repository wrapper test instance
|
|
"""
|
|
return Repo(configuration.get("repository", "name"), repository_paths, [])
|
|
|
|
|
|
@pytest.fixture
|
|
def task_ahriman(package_ahriman: Package, configuration: Configuration, repository_paths: RepositoryPaths) -> Task:
|
|
"""
|
|
fixture for built task
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
configuration(Configuration): configuration fixture
|
|
repository_paths(RepositoryPaths): repository paths fixture
|
|
|
|
Returns:
|
|
Task: built task test instance
|
|
"""
|
|
return Task(package_ahriman, configuration, repository_paths)
|