mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-29 13:49:57 +00:00
Add ability to show more info in search and status subcommands
This feature also introduces the followiing changes * aur-search command now works as expected with multiterms * printer classes for managing of data print * --sort-by argument for aur-search subcommand instead of using package name * --quiet argument now has also --no-quite option * if --quite is supplied, the log level will be set to warn instead of critical to be able to see error messages * pretty_datetime function now also supports datetime objects * BuildStatus is now pure dataclass
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import configparser
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
@ -194,7 +195,7 @@ def test_load_logging_quiet(configuration: Configuration, mocker: MockerFixture)
|
||||
"""
|
||||
disable_mock = mocker.patch("logging.disable")
|
||||
configuration.load_logging(quiet=True)
|
||||
disable_mock.assert_called_once()
|
||||
disable_mock.assert_called_once_with(logging.WARNING)
|
||||
|
||||
|
||||
def test_merge_sections_missing(configuration: Configuration) -> None:
|
||||
|
@ -1,3 +1,4 @@
|
||||
import datetime
|
||||
import logging
|
||||
import pytest
|
||||
import subprocess
|
||||
@ -6,7 +7,7 @@ from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.exceptions import InvalidOption, UnsafeRun
|
||||
from ahriman.core.util import check_output, check_user, package_like, pretty_datetime, pretty_size, walk
|
||||
from ahriman.core.util import check_output, check_user, filter_json, package_like, pretty_datetime, pretty_size, walk
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
@ -79,6 +80,26 @@ def test_check_user_exception(mocker: MockerFixture) -> None:
|
||||
check_user(cwd)
|
||||
|
||||
|
||||
def test_filter_json(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must filter fields by known list
|
||||
"""
|
||||
expected = package_ahriman.view()
|
||||
probe = package_ahriman.view()
|
||||
probe["unknown_field"] = "value"
|
||||
|
||||
assert expected == filter_json(probe, expected.keys())
|
||||
|
||||
|
||||
def test_filter_json_empty_value(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return empty values from object
|
||||
"""
|
||||
probe = package_ahriman.view()
|
||||
probe["base"] = None
|
||||
assert "base" not in filter_json(probe, probe.keys())
|
||||
|
||||
|
||||
def test_package_like(package_ahriman: Package) -> None:
|
||||
"""
|
||||
package_like must return true for archives
|
||||
@ -102,6 +123,13 @@ def test_pretty_datetime() -> None:
|
||||
assert pretty_datetime(0) == "1970-01-01 00:00:00"
|
||||
|
||||
|
||||
def test_pretty_datetime_datetime() -> None:
|
||||
"""
|
||||
must generate string from datetime object
|
||||
"""
|
||||
assert pretty_datetime(datetime.datetime(1970, 1, 1, 0, 0, 0)) == "1970-01-01 00:00:00"
|
||||
|
||||
|
||||
def test_pretty_datetime_empty() -> None:
|
||||
"""
|
||||
must generate empty string from None timestamp
|
||||
|
Reference in New Issue
Block a user