mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-30 21:39:56 +00:00
Extended package status page (#76)
* 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
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from ahriman.core.database.migrations.m002_user_access import steps
|
||||
|
||||
|
||||
def test_migration_package_source() -> None:
|
||||
def test_migration_user_access() -> None:
|
||||
"""
|
||||
migration must not be empty
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
from ahriman.core.database.migrations.m003_patch_variables import steps
|
||||
|
||||
|
||||
def test_migration_package_source() -> None:
|
||||
def test_migration_patches() -> None:
|
||||
"""
|
||||
migration must not be empty
|
||||
"""
|
||||
|
8
tests/ahriman/core/database/migrations/test_m004_logs.py
Normal file
8
tests/ahriman/core/database/migrations/test_m004_logs.py
Normal file
@ -0,0 +1,8 @@
|
||||
from ahriman.core.database.migrations.m004_logs import steps
|
||||
|
||||
|
||||
def test_migration_logs() -> None:
|
||||
"""
|
||||
migration must not be empty
|
||||
"""
|
||||
assert steps
|
@ -35,7 +35,7 @@ def test_build_queue_insert_get(database: SQLite, package_ahriman: Package) -> N
|
||||
|
||||
def test_build_queue_insert(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must update user in the database
|
||||
must update build queue in the database
|
||||
"""
|
||||
database.build_queue_insert(package_ahriman)
|
||||
assert database.build_queue_get() == [package_ahriman]
|
||||
|
@ -0,0 +1,39 @@
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.log_record_id import LogRecordId
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def test_logs_insert_remove_process(database: SQLite, package_ahriman: Package,
|
||||
package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must clear process specific package logs
|
||||
"""
|
||||
database.logs_insert(LogRecordId(package_ahriman.base, 1), 42.0, "message 1")
|
||||
database.logs_insert(LogRecordId(package_ahriman.base, 2), 43.0, "message 2")
|
||||
database.logs_insert(LogRecordId(package_python_schedule.base, 1), 42.0, "message 3")
|
||||
|
||||
database.logs_remove(package_ahriman.base, 1)
|
||||
assert database.logs_get(package_ahriman.base) == "[1970-01-01 00:00:42] message 1"
|
||||
assert database.logs_get(package_python_schedule.base) == "[1970-01-01 00:00:42] message 3"
|
||||
|
||||
|
||||
def test_logs_insert_remove_full(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must clear full package logs
|
||||
"""
|
||||
database.logs_insert(LogRecordId(package_ahriman.base, 1), 42.0, "message 1")
|
||||
database.logs_insert(LogRecordId(package_ahriman.base, 2), 43.0, "message 2")
|
||||
database.logs_insert(LogRecordId(package_python_schedule.base, 1), 42.0, "message 3")
|
||||
|
||||
database.logs_remove(package_ahriman.base, None)
|
||||
assert not database.logs_get(package_ahriman.base)
|
||||
assert database.logs_get(package_python_schedule.base) == "[1970-01-01 00:00:42] message 3"
|
||||
|
||||
|
||||
def test_logs_insert_get(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must insert and get package logs
|
||||
"""
|
||||
database.logs_insert(LogRecordId(package_ahriman.base, 1), 43.0, "message 2")
|
||||
database.logs_insert(LogRecordId(package_ahriman.base, 1), 42.0, "message 1")
|
||||
assert database.logs_get(package_ahriman.base) == "[1970-01-01 00:00:42] message 1\n[1970-01-01 00:00:43] message 2"
|
Reference in New Issue
Block a user