mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
migration of jinja tempaltes to bootstrap (#30)
This commit is contained in:
@ -13,7 +13,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
:return: generated arguments for these test cases
|
||||
"""
|
||||
args.key = "0xE989490C"
|
||||
args.key_server = "keys.gnupg.net"
|
||||
args.key_server = "pgp.mit.edu"
|
||||
return args
|
||||
|
||||
|
||||
|
@ -105,6 +105,21 @@ def test_generate_with_built(configuration: Configuration, package_ahriman: Pack
|
||||
send_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_generate_with_built_and_full_path(
|
||||
configuration: Configuration,
|
||||
package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate report with built packages
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration)
|
||||
report.full_template_path = report.template_path
|
||||
report.generate([package_ahriman], [package_ahriman])
|
||||
send_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_generate_no_empty(configuration: Configuration, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must not generate report with built packages if no_empty_report is set
|
||||
|
@ -7,13 +7,6 @@ def test_generate(configuration: Configuration, package_ahriman: Package) -> Non
|
||||
"""
|
||||
must generate html report
|
||||
"""
|
||||
path = configuration.getpath("html", "template_path")
|
||||
report = JinjaTemplate("html", configuration)
|
||||
assert report.make_html([package_ahriman], extended_report=False)
|
||||
|
||||
|
||||
def test_generate_extended(configuration: Configuration, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must generate extended html report
|
||||
"""
|
||||
report = JinjaTemplate("html", configuration)
|
||||
assert report.make_html([package_ahriman], extended_report=True)
|
||||
assert report.make_html([package_ahriman], path)
|
||||
|
@ -69,7 +69,7 @@ def test_download_key(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
must download the key from public server
|
||||
"""
|
||||
requests_mock = mocker.patch("requests.get")
|
||||
gpg.download_key("keys.gnupg.net", "0xE989490C")
|
||||
gpg.download_key("pgp.mit.edu", "0xE989490C")
|
||||
requests_mock.assert_called_once()
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ def test_download_key_failure(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
mocker.patch("requests.get", side_effect=requests.exceptions.HTTPError())
|
||||
with pytest.raises(requests.exceptions.HTTPError):
|
||||
gpg.download_key("keys.gnupg.net", "0xE989490C")
|
||||
gpg.download_key("pgp.mit.edu", "0xE989490C")
|
||||
|
||||
|
||||
def test_import_key(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
@ -89,7 +89,7 @@ def test_import_key(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
mocker.patch("ahriman.core.sign.gpg.GPG.download_key", return_value="key")
|
||||
check_output_mock = mocker.patch("ahriman.core.sign.gpg.GPG._check_output")
|
||||
|
||||
gpg.import_key("keys.gnupg.net", "0xE989490C")
|
||||
gpg.import_key("pgp.mit.edu", "0xE989490C")
|
||||
check_output_mock.assert_has_calls([
|
||||
mock.call("gpg", "--import", input_data="key", exception=None, logger=pytest.helpers.anyvar(int)),
|
||||
mock.call("gpg", "--quick-lsign-key", "0xE989490C", exception=None, logger=pytest.helpers.anyvar(int))
|
||||
|
@ -1,5 +1,7 @@
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
@ -49,6 +51,25 @@ def test_absolute_path_for_relative(configuration: Configuration) -> None:
|
||||
assert result.name == path.name
|
||||
|
||||
|
||||
def test_path_with_fallback(configuration: Configuration) -> None:
|
||||
"""
|
||||
must return fallback path
|
||||
"""
|
||||
path = Path("a")
|
||||
assert configuration.getpath("some", "option", fallback=path).name == str(path)
|
||||
assert configuration.getpath("some", "option", fallback=None) is None
|
||||
|
||||
|
||||
def test_path_without_fallback(configuration: Configuration) -> None:
|
||||
"""
|
||||
must raise exception without fallback
|
||||
"""
|
||||
with pytest.raises(configparser.NoSectionError):
|
||||
assert configuration.getpath("some", "option")
|
||||
with pytest.raises(configparser.NoOptionError):
|
||||
assert configuration.getpath("build", "option")
|
||||
|
||||
|
||||
def test_dump(configuration: Configuration) -> None:
|
||||
"""
|
||||
dump must not be empty
|
||||
|
@ -59,14 +59,10 @@ def test_get_local_files(s3: S3, resource_path_root: Path) -> None:
|
||||
Path("models/package_ahriman_srcinfo"),
|
||||
Path("models/package_tpacpi-bat-git_srcinfo"),
|
||||
Path("models/package_yay_srcinfo"),
|
||||
Path("web/templates/search-line.jinja2"),
|
||||
Path("web/templates/build-status.jinja2"),
|
||||
Path("web/templates/login-form.jinja2"),
|
||||
Path("web/templates/login-form-hide.jinja2"),
|
||||
Path("web/templates/email-index.jinja2"),
|
||||
Path("web/templates/repo-index.jinja2"),
|
||||
Path("web/templates/sorttable.jinja2"),
|
||||
Path("web/templates/style.jinja2"),
|
||||
Path("web/templates/search.jinja2"),
|
||||
])
|
||||
|
||||
local_files = list(sorted(s3.get_local_files(resource_path_root).keys()))
|
||||
|
@ -16,6 +16,18 @@ def test_build_status_enum_badges_color() -> None:
|
||||
assert status.badges_color() in SUPPORTED_COLORS
|
||||
|
||||
|
||||
def test_build_status_enum_bootstrap_color() -> None:
|
||||
"""
|
||||
status color must be one of shields.io supported
|
||||
"""
|
||||
SUPPORTED_COLORS = [
|
||||
"primary", "secondary", "success", "danger", "warning", "info", "light", "dark"
|
||||
]
|
||||
|
||||
for status in BuildStatusEnum:
|
||||
assert status.bootstrap_color() in SUPPORTED_COLORS
|
||||
|
||||
|
||||
def test_build_status_init_1() -> None:
|
||||
"""
|
||||
must construct status object from None
|
||||
|
Reference in New Issue
Block a user