mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-01 08:05:48 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
07b77be6b8 | |||
2b33510ada | |||
6d05389639 | |||
daf9841717 | |||
0d243a781a | |||
cf2e66a934 |
@ -3,7 +3,7 @@ version: 2
|
|||||||
build:
|
build:
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
tools:
|
tools:
|
||||||
python: "3.11"
|
python: "3.12"
|
||||||
|
|
||||||
python:
|
python:
|
||||||
install:
|
install:
|
||||||
|
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
12
docs/faq.rst
12
docs/faq.rst
@ -208,6 +208,18 @@ This command will prompt for new value of the PKGBUILD variable ``version``. You
|
|||||||
|
|
||||||
sudo -u ahriman ahriman patch-add ahriman version version.patch
|
sudo -u ahriman ahriman patch-add ahriman version version.patch
|
||||||
|
|
||||||
|
The command also supports arrays, but in this case you need to specify full array, e.g.
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
sudo -u ahriman ahriman patch-add ahriman depends
|
||||||
|
|
||||||
|
Post new function or variable value below. Press Ctrl-D to finish:
|
||||||
|
(python python-aiohttp)
|
||||||
|
^D
|
||||||
|
|
||||||
|
will set depends PKGBUILD variable (exactly) to array ``["python", "python-aiohttp"]``.
|
||||||
|
|
||||||
Alternatively you can create full-diff patches, which are calculated by using ``git diff`` from current PKGBUILD master branch:
|
Alternatively you can create full-diff patches, which are calculated by using ``git diff`` from current PKGBUILD master branch:
|
||||||
|
|
||||||
#.
|
#.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Evgeniy Alekseev
|
# Maintainer: Evgeniy Alekseev
|
||||||
|
|
||||||
pkgname='ahriman'
|
pkgname='ahriman'
|
||||||
pkgver=2.13.5
|
pkgver=2.13.7
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="ArcH linux ReposItory MANager"
|
pkgdesc="ArcH linux ReposItory MANager"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
@ -223,7 +223,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
table.bootstrapTable({});
|
|
||||||
statusBadge.popover();
|
statusBadge.popover();
|
||||||
selectRepository();
|
selectRepository();
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js" integrity="sha384-1H217gwSVyLSIfaLxHbE7dRb3v4mYCKbpQvzx0cegeju1MVsGrX5xXxAvs/HgeFs" crossorigin="anonymous" type="application/javascript"></script>
|
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js" integrity="sha384-1H217gwSVyLSIfaLxHbE7dRb3v4mYCKbpQvzx0cegeju1MVsGrX5xXxAvs/HgeFs" crossorigin="anonymous" type="application/javascript"></script>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.4/moment.min.js" integrity="sha384-8hHkOkbWN1TLWwet/jpbJ0zbx3FJDeYJgQ8dX1mRrv/vfCfHCqFSFZYCgaMML3z9" crossorigin="anonymous" type="application/javascript"></script>
|
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.4/moment.min.js" integrity="sha384-4ZTAzTbfB8H7hkWtXbyNDzDvxirmBT7EmURIvfOJ3Foympc+OD9p+bZNNENaJXgW" crossorigin="anonymous" type="application/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/daterangepicker@3.1.0/daterangepicker.min.js" integrity="sha384-u4eJN1VWrTf/FnYYQJo2kqJyVxEQf5UmWY4iUcNAoLenOEtEuCkfwc5bKvZOWBi5" crossorigin="anonymous" type="application/javascript"></script>
|
<script src="https://cdn.jsdelivr.net/npm/daterangepicker@3.1.0/daterangepicker.min.js" integrity="sha384-Gn1XZMJEKL3ycoWq97jYAl+FP3vXQYE2ObBgzgcPMKOZdUZdF6ZuyUxbGC2bAnUT" crossorigin="anonymous" type="application/javascript"></script>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.28.0/tableExport.min.js" integrity="sha384-1Rz4Kz/y1rSWw+ZsjTcxB684XgofbO8iizY+UFIzCwFeQ+QUyhBNWBMh/STOyomI" crossorigin="anonymous" type="application/javascript"></script>
|
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.28.0/tableExport.min.js" integrity="sha384-1Rz4Kz/y1rSWw+ZsjTcxB684XgofbO8iizY+UFIzCwFeQ+QUyhBNWBMh/STOyomI" crossorigin="anonymous" type="application/javascript"></script>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.TH AHRIMAN "1" "2024\-04\-04" "ahriman" "Generated Python Manual"
|
.TH AHRIMAN "1" "2024\-05\-09" "ahriman" "Generated Python Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ahriman
|
ahriman
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -81,6 +81,7 @@ web = [
|
|||||||
"aiohttp_security",
|
"aiohttp_security",
|
||||||
"cryptography",
|
"cryptography",
|
||||||
"requests-unixsocket", # required by unix socket support
|
"requests-unixsocket", # required by unix socket support
|
||||||
|
"setuptools", # required by aiohttp-apispec
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.flit.sdist]
|
[tool.flit.sdist]
|
||||||
|
@ -17,4 +17,4 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
__version__ = "2.13.5"
|
__version__ = "2.13.7"
|
||||||
|
@ -102,8 +102,9 @@ class Patch(Handler):
|
|||||||
patch = "".join(list(sys.stdin))
|
patch = "".join(list(sys.stdin))
|
||||||
else:
|
else:
|
||||||
patch = patch_path.read_text(encoding="utf8")
|
patch = patch_path.read_text(encoding="utf8")
|
||||||
patch = patch.strip() # remove spaces around the patch
|
# remove spaces around the patch and parse to correct type
|
||||||
return PkgbuildPatch(variable, patch)
|
parsed = PkgbuildPatch.parse(patch.strip())
|
||||||
|
return PkgbuildPatch(variable, parsed)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def patch_set_create(application: Application, package_base: str, patch: PkgbuildPatch) -> None:
|
def patch_set_create(application: Application, package_base: str, patch: PkgbuildPatch) -> None:
|
||||||
|
@ -69,7 +69,8 @@ class OAuth(Mapping):
|
|||||||
Returns:
|
Returns:
|
||||||
str: login control as html code to insert
|
str: login control as html code to insert
|
||||||
"""
|
"""
|
||||||
return f"""<a class="nav-link" href="/api/v1/login" title="login via OAuth2"><i class="bi bi-{self.icon}"></i> login</a>"""
|
return f"""<a class="nav-link" href="/api/v1/login" title="login via OAuth2"><i class="bi bi-{
|
||||||
|
self.icon}"></i> login</a>"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_provider(name: str) -> type[aioauth_client.OAuth2Client]:
|
def get_provider(name: str) -> type[aioauth_client.OAuth2Client]:
|
||||||
|
@ -117,7 +117,8 @@ class Executor(PackageInfo, Cleaner):
|
|||||||
|
|
||||||
# build package list based on user input
|
# build package list based on user input
|
||||||
result = Result()
|
result = Result()
|
||||||
requested = set(packages)
|
packages = set(packages) # remove duplicates
|
||||||
|
requested = packages | {f"{package}-debug" for package in packages} # append debug packages
|
||||||
for local in self.packages():
|
for local in self.packages():
|
||||||
if local.base in packages or all(package in requested for package in local.packages):
|
if local.base in packages or all(package in requested for package in local.packages):
|
||||||
packages_to_remove.update({
|
packages_to_remove.update({
|
||||||
@ -136,7 +137,7 @@ class Executor(PackageInfo, Cleaner):
|
|||||||
|
|
||||||
# check for packages which were requested to remove, but weren't found locally
|
# check for packages which were requested to remove, but weren't found locally
|
||||||
# it might happen for example, if there were no success build before
|
# it might happen for example, if there were no success build before
|
||||||
for unknown in requested:
|
for unknown in packages:
|
||||||
if unknown in packages_to_remove or unknown in bases_to_remove:
|
if unknown in packages_to_remove or unknown in bases_to_remove:
|
||||||
continue
|
continue
|
||||||
bases_to_remove.append(unknown)
|
bases_to_remove.append(unknown)
|
||||||
|
@ -183,11 +183,12 @@ post_install() {{
|
|||||||
Returns:
|
Returns:
|
||||||
str: package() function for PKGBUILD
|
str: package() function for PKGBUILD
|
||||||
"""
|
"""
|
||||||
|
# somehow autopep thinks that construction inside contains valid python code and reformats it
|
||||||
return f"""{{
|
return f"""{{
|
||||||
install -Dm644 "{Path("$srcdir") / f"{self.name}.gpg"}" "{Path("$pkgdir") / "usr" / "share" / "pacman" / "keyrings" / f"{self.name}.gpg"}"
|
install -Dm644 "{Path("$srcdir") / f"{self.name}.gpg"}" "{Path("$pkgdir") / "usr" / "share" / "pacman" / "keyrings" / f"{self.name}.gpg"}"
|
||||||
install -Dm644 "{Path("$srcdir") / f"{self.name}-revoked"}" "{Path("$pkgdir") / "usr" / "share" / "pacman" / "keyrings" / f"{self.name}-revoked"}"
|
install -Dm644 "{Path("$srcdir") / f"{self.name}-revoked"}" "{Path("$pkgdir") / "usr" / "share" / "pacman" / "keyrings" / f"{self.name}-revoked"}"
|
||||||
install -Dm644 "{Path("$srcdir") / f"{self.name}-trusted"}" "{Path("$pkgdir") / "usr" / "share" / "pacman" / "keyrings" / f"{self.name}-trusted"}"
|
install -Dm644 "{Path("$srcdir") / f"{self.name}-trusted"}" "{Path("$pkgdir") / "usr" / "share" / "pacman" / "keyrings" / f"{self.name}-trusted"}"
|
||||||
}}"""
|
}}""" # nopep8
|
||||||
|
|
||||||
def sources(self) -> dict[str, Callable[[Path], None]]:
|
def sources(self) -> dict[str, Callable[[Path], None]]:
|
||||||
"""
|
"""
|
||||||
|
@ -162,7 +162,8 @@ class GitHub(Upload, HttpUpload):
|
|||||||
Returns:
|
Returns:
|
||||||
dict[str, Any] | None: GitHub API release object if release found and None otherwise
|
dict[str, Any] | None: GitHub API release object if release found and None otherwise
|
||||||
"""
|
"""
|
||||||
url = f"https://api.github.com/repos/{self.github_owner}/{self.github_repository}/releases/tags/{self.github_release_tag}"
|
url = f"https://api.github.com/repos/{self.github_owner}/{
|
||||||
|
self.github_repository}/releases/tags/{self.github_release_tag}"
|
||||||
try:
|
try:
|
||||||
response = self.make_request("GET", url)
|
response = self.make_request("GET", url)
|
||||||
release: dict[str, Any] = response.json()
|
release: dict[str, Any] = response.json()
|
||||||
|
@ -56,7 +56,6 @@ __all__ = [
|
|||||||
"srcinfo_property",
|
"srcinfo_property",
|
||||||
"srcinfo_property_list",
|
"srcinfo_property_list",
|
||||||
"trim_package",
|
"trim_package",
|
||||||
"unquote",
|
|
||||||
"utcnow",
|
"utcnow",
|
||||||
"walk",
|
"walk",
|
||||||
]
|
]
|
||||||
@ -349,7 +348,7 @@ def pretty_datetime(timestamp: datetime.datetime | float | int | None) -> str:
|
|||||||
if timestamp is None:
|
if timestamp is None:
|
||||||
return ""
|
return ""
|
||||||
if isinstance(timestamp, (int, float)):
|
if isinstance(timestamp, (int, float)):
|
||||||
timestamp = datetime.datetime.utcfromtimestamp(timestamp)
|
timestamp = datetime.datetime.fromtimestamp(timestamp, datetime.UTC)
|
||||||
return timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
return timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
@ -466,38 +465,6 @@ def trim_package(package_name: str) -> str:
|
|||||||
return package_name
|
return package_name
|
||||||
|
|
||||||
|
|
||||||
def unquote(source: str) -> str:
|
|
||||||
"""
|
|
||||||
like :func:`shlex.quote()`, but opposite
|
|
||||||
|
|
||||||
Args:
|
|
||||||
source(str): source string to remove quotes
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: string with quotes removed
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
ValueError: if no closing quotation
|
|
||||||
"""
|
|
||||||
def generator() -> Generator[str, None, None]:
|
|
||||||
token = None
|
|
||||||
for char in source:
|
|
||||||
if token is not None:
|
|
||||||
if char == token:
|
|
||||||
token = None # closed quote
|
|
||||||
else:
|
|
||||||
yield char # character inside quotes
|
|
||||||
elif char in ("'", "\""):
|
|
||||||
token = char # first quote found
|
|
||||||
else:
|
|
||||||
yield char # normal character
|
|
||||||
|
|
||||||
if token is not None:
|
|
||||||
raise ValueError("No closing quotation")
|
|
||||||
|
|
||||||
return "".join(generator())
|
|
||||||
|
|
||||||
|
|
||||||
def utcnow() -> datetime.datetime:
|
def utcnow() -> datetime.datetime:
|
||||||
"""
|
"""
|
||||||
get current time
|
get current time
|
||||||
@ -505,7 +472,7 @@ def utcnow() -> datetime.datetime:
|
|||||||
Returns:
|
Returns:
|
||||||
datetime.datetime: current time in UTC
|
datetime.datetime: current time in UTC
|
||||||
"""
|
"""
|
||||||
return datetime.datetime.utcnow()
|
return datetime.datetime.now(datetime.UTC)
|
||||||
|
|
||||||
|
|
||||||
def walk(directory_path: Path) -> Generator[Path, None, None]:
|
def walk(directory_path: Path) -> Generator[Path, None, None]:
|
||||||
|
@ -137,8 +137,8 @@ class AURPackage:
|
|||||||
description=package.desc,
|
description=package.desc,
|
||||||
num_votes=0,
|
num_votes=0,
|
||||||
popularity=0.0,
|
popularity=0.0,
|
||||||
first_submitted=datetime.datetime.utcfromtimestamp(0),
|
first_submitted=datetime.datetime.fromtimestamp(0, datetime.UTC),
|
||||||
last_modified=datetime.datetime.utcfromtimestamp(package.builddate),
|
last_modified=datetime.datetime.fromtimestamp(package.builddate, datetime.UTC),
|
||||||
url_path="",
|
url_path="",
|
||||||
url=package.url,
|
url=package.url,
|
||||||
out_of_date=None,
|
out_of_date=None,
|
||||||
@ -175,13 +175,11 @@ class AURPackage:
|
|||||||
description=dump["pkgdesc"],
|
description=dump["pkgdesc"],
|
||||||
num_votes=0,
|
num_votes=0,
|
||||||
popularity=0.0,
|
popularity=0.0,
|
||||||
first_submitted=datetime.datetime.utcfromtimestamp(0),
|
first_submitted=datetime.datetime.fromtimestamp(0, datetime.UTC),
|
||||||
last_modified=datetime.datetime.strptime(dump["last_update"], "%Y-%m-%dT%H:%M:%S.%fZ"),
|
last_modified=datetime.datetime.fromisoformat(dump["last_update"]),
|
||||||
url_path="",
|
url_path="",
|
||||||
url=dump["url"],
|
url=dump["url"],
|
||||||
out_of_date=datetime.datetime.strptime(
|
out_of_date=datetime.datetime.fromisoformat(dump["flag_date"]) if dump.get("flag_date") else None,
|
||||||
dump["flag_date"],
|
|
||||||
"%Y-%m-%dT%H:%M:%S.%fZ") if dump["flag_date"] is not None else None,
|
|
||||||
maintainer=next(iter(dump["maintainers"]), None),
|
maintainer=next(iter(dump["maintainers"]), None),
|
||||||
submitter=None,
|
submitter=None,
|
||||||
repository=dump["repo"],
|
repository=dump["repo"],
|
||||||
@ -208,9 +206,9 @@ class AURPackage:
|
|||||||
"""
|
"""
|
||||||
identity_mapper: Callable[[Any], Any] = lambda value: value
|
identity_mapper: Callable[[Any], Any] = lambda value: value
|
||||||
value_mapper: dict[str, Callable[[Any], Any]] = {
|
value_mapper: dict[str, Callable[[Any], Any]] = {
|
||||||
"out_of_date": lambda value: datetime.datetime.utcfromtimestamp(value) if value is not None else None,
|
"out_of_date": lambda value: datetime.datetime.fromtimestamp(value, datetime.UTC) if value is not None else None,
|
||||||
"first_submitted": datetime.datetime.utcfromtimestamp,
|
"first_submitted": lambda value: datetime.datetime.fromtimestamp(value, datetime.UTC),
|
||||||
"last_modified": datetime.datetime.utcfromtimestamp,
|
"last_modified": lambda value: datetime.datetime.fromtimestamp(value, datetime.UTC),
|
||||||
}
|
}
|
||||||
|
|
||||||
result: dict[str, Any] = {}
|
result: dict[str, Any] = {}
|
||||||
|
@ -21,9 +21,9 @@ import shlex
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Self
|
from typing import Any, Generator, Self
|
||||||
|
|
||||||
from ahriman.core.util import dataclass_view, unquote
|
from ahriman.core.util import dataclass_view
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@ -81,14 +81,57 @@ class PkgbuildPatch:
|
|||||||
Self: package properties
|
Self: package properties
|
||||||
"""
|
"""
|
||||||
key, *value_parts = variable.split("=", maxsplit=1)
|
key, *value_parts = variable.split("=", maxsplit=1)
|
||||||
|
|
||||||
raw_value = next(iter(value_parts), "") # extract raw value
|
raw_value = next(iter(value_parts), "") # extract raw value
|
||||||
if raw_value.startswith("(") and raw_value.endswith(")"):
|
return cls(key, cls.parse(raw_value))
|
||||||
value: str | list[str] = shlex.split(raw_value[1:-1]) # arrays for poor
|
|
||||||
else:
|
|
||||||
value = unquote(raw_value)
|
|
||||||
|
|
||||||
return cls(key, value)
|
@staticmethod
|
||||||
|
def parse(source: str) -> str | list[str]:
|
||||||
|
"""
|
||||||
|
parse string value to the PKGBUILD patch value. This method simply takes string, tries to identify it as array
|
||||||
|
or just string and return the respective value. Functions should be processed correctly, however, not guaranteed
|
||||||
|
|
||||||
|
Args:
|
||||||
|
source(str): source string to parse
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str | list[str]: parsed value either string or list of strings
|
||||||
|
"""
|
||||||
|
if source.startswith("(") and source.endswith(")"):
|
||||||
|
return shlex.split(source[1:-1]) # arrays for poor
|
||||||
|
return PkgbuildPatch.unquote(source)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def unquote(source: str) -> str:
|
||||||
|
"""
|
||||||
|
like :func:`shlex.quote()`, but opposite
|
||||||
|
|
||||||
|
Args:
|
||||||
|
source(str): source string to remove quotes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: string with quotes removed
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: if no closing quotation
|
||||||
|
"""
|
||||||
|
|
||||||
|
def generator() -> Generator[str, None, None]:
|
||||||
|
token = None
|
||||||
|
for char in source:
|
||||||
|
if token is not None:
|
||||||
|
if char == token:
|
||||||
|
token = None # closed quote
|
||||||
|
else:
|
||||||
|
yield char # character inside quotes
|
||||||
|
elif char in ("'", "\""):
|
||||||
|
token = char # first quote found
|
||||||
|
else:
|
||||||
|
yield char # normal character
|
||||||
|
|
||||||
|
if token is not None:
|
||||||
|
raise ValueError("No closing quotation")
|
||||||
|
|
||||||
|
return "".join(generator())
|
||||||
|
|
||||||
def serialize(self) -> str:
|
def serialize(self) -> str:
|
||||||
"""
|
"""
|
||||||
|
@ -122,11 +122,10 @@ def test_patch_create_from_function(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
must create function patch from file
|
must create function patch from file
|
||||||
"""
|
"""
|
||||||
path = Path("local")
|
|
||||||
patch = PkgbuildPatch("version", "patch")
|
patch = PkgbuildPatch("version", "patch")
|
||||||
read_mock = mocker.patch("pathlib.Path.read_text", return_value=patch.value)
|
read_mock = mocker.patch("pathlib.Path.read_text", return_value=patch.value)
|
||||||
|
|
||||||
assert Patch.patch_create_from_function(patch.key, path) == patch
|
assert Patch.patch_create_from_function(patch.key, Path("local")) == patch
|
||||||
read_mock.assert_called_once_with(encoding="utf8")
|
read_mock.assert_called_once_with(encoding="utf8")
|
||||||
|
|
||||||
|
|
||||||
@ -148,6 +147,15 @@ def test_patch_create_from_function_strip(mocker: MockerFixture) -> None:
|
|||||||
assert Patch.patch_create_from_function(patch.key, None) == patch
|
assert Patch.patch_create_from_function(patch.key, None) == patch
|
||||||
|
|
||||||
|
|
||||||
|
def test_patch_create_from_function_array(mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must correctly read array variable
|
||||||
|
"""
|
||||||
|
patch = PkgbuildPatch("version", ["array", "patch"])
|
||||||
|
mocker.patch("pathlib.Path.read_text", return_value=f"({" ".join(patch.value)})")
|
||||||
|
assert Patch.patch_create_from_function(patch.key, Path("local")) == patch
|
||||||
|
|
||||||
|
|
||||||
def test_patch_set_list(application: Application, mocker: MockerFixture) -> None:
|
def test_patch_set_list(application: Application, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must list available patches for the command
|
must list available patches for the command
|
||||||
|
@ -133,8 +133,8 @@ def aur_package_ahriman() -> AURPackage:
|
|||||||
description="ArcH linux ReposItory MANager",
|
description="ArcH linux ReposItory MANager",
|
||||||
num_votes=0,
|
num_votes=0,
|
||||||
popularity=0,
|
popularity=0,
|
||||||
first_submitted=datetime.datetime.utcfromtimestamp(1618008285),
|
first_submitted=datetime.datetime.fromtimestamp(1618008285, datetime.UTC),
|
||||||
last_modified=datetime.datetime.utcfromtimestamp(1673826351),
|
last_modified=datetime.datetime.fromtimestamp(1673826351, datetime.UTC),
|
||||||
url_path="/cgit/aur.git/snapshot/ahriman.tar.gz",
|
url_path="/cgit/aur.git/snapshot/ahriman.tar.gz",
|
||||||
url="https://github.com/arcan1s/ahriman",
|
url="https://github.com/arcan1s/ahriman",
|
||||||
out_of_date=None,
|
out_of_date=None,
|
||||||
@ -200,8 +200,8 @@ def aur_package_akonadi() -> AURPackage:
|
|||||||
description="PIM layer, which provides an asynchronous API to access all kind of PIM data",
|
description="PIM layer, which provides an asynchronous API to access all kind of PIM data",
|
||||||
num_votes=0,
|
num_votes=0,
|
||||||
popularity=0.0,
|
popularity=0.0,
|
||||||
first_submitted=datetime.datetime.utcfromtimestamp(0),
|
first_submitted=datetime.datetime.fromtimestamp(0, datetime.UTC),
|
||||||
last_modified=datetime.datetime.utcfromtimestamp(1646555990.610),
|
last_modified=datetime.datetime.fromtimestamp(1646555990.610, datetime.UTC),
|
||||||
url_path="",
|
url_path="",
|
||||||
url="https://kontact.kde.org",
|
url="https://kontact.kde.org",
|
||||||
out_of_date=None,
|
out_of_date=None,
|
||||||
|
@ -89,6 +89,28 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke
|
|||||||
commit_sha_mock.assert_called_once_with(package_ahriman.base)
|
commit_sha_mock.assert_called_once_with(package_ahriman.base)
|
||||||
|
|
||||||
|
|
||||||
|
def test_process_remove_with_debug(executor: Executor, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must run remove debug packages too
|
||||||
|
"""
|
||||||
|
package_ahriman.packages = {
|
||||||
|
package_ahriman.base: package_ahriman.packages[package_ahriman.base],
|
||||||
|
f"{package_ahriman.base}-debug": package_ahriman.packages[package_ahriman.base],
|
||||||
|
}
|
||||||
|
mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman])
|
||||||
|
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_clear")
|
||||||
|
mocker.patch("ahriman.core.database.SQLite.package_clear")
|
||||||
|
mocker.patch("ahriman.core.status.client.Client.package_remove")
|
||||||
|
repo_remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove")
|
||||||
|
|
||||||
|
executor.process_remove([package_ahriman.base])
|
||||||
|
# must remove via alpm wrapper
|
||||||
|
repo_remove_mock.assert_has_calls([
|
||||||
|
MockCall(package_ahriman.base, package_ahriman.packages[package_ahriman.base].filepath),
|
||||||
|
MockCall(f"{package_ahriman.base}-debug", package_ahriman.packages[package_ahriman.base].filepath),
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def test_process_remove_base_multiple(executor: Executor, package_python_schedule: Package,
|
def test_process_remove_base_multiple(executor: Executor, package_python_schedule: Package,
|
||||||
mocker: MockerFixture) -> None:
|
mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -6,7 +6,6 @@ from pytest_mock import MockerFixture
|
|||||||
from unittest.mock import MagicMock, call as MockCall
|
from unittest.mock import MagicMock, call as MockCall
|
||||||
|
|
||||||
from ahriman.core.support.pkgbuild.pkgbuild_generator import PkgbuildGenerator
|
from ahriman.core.support.pkgbuild.pkgbuild_generator import PkgbuildGenerator
|
||||||
from ahriman.core.util import utcnow
|
|
||||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ def test_pkgver(pkgbuild_generator: PkgbuildGenerator, mocker: MockerFixture) ->
|
|||||||
must implement default version as current date
|
must implement default version as current date
|
||||||
"""
|
"""
|
||||||
mocker.patch("ahriman.core.support.pkgbuild.pkgbuild_generator.utcnow", return_value=datetime.datetime(2002, 3, 11))
|
mocker.patch("ahriman.core.support.pkgbuild.pkgbuild_generator.utcnow", return_value=datetime.datetime(2002, 3, 11))
|
||||||
assert pkgbuild_generator.pkgver == utcnow().strftime("20020311")
|
assert pkgbuild_generator.pkgver == "20020311"
|
||||||
|
|
||||||
|
|
||||||
def test_url(pkgbuild_generator: PkgbuildGenerator) -> None:
|
def test_url(pkgbuild_generator: PkgbuildGenerator) -> None:
|
||||||
|
@ -12,7 +12,7 @@ from unittest.mock import call as MockCall
|
|||||||
from ahriman.core.exceptions import BuildError, CalledProcessError, OptionError, UnsafeRunError
|
from ahriman.core.exceptions import BuildError, CalledProcessError, OptionError, UnsafeRunError
|
||||||
from ahriman.core.util import check_output, check_user, dataclass_view, enum_values, extract_user, filter_json, \
|
from ahriman.core.util import check_output, check_user, dataclass_view, enum_values, extract_user, filter_json, \
|
||||||
full_version, minmax, package_like, parse_version, partition, pretty_datetime, pretty_size, safe_filename, \
|
full_version, minmax, package_like, parse_version, partition, pretty_datetime, pretty_size, safe_filename, \
|
||||||
srcinfo_property, srcinfo_property_list, trim_package, unquote, utcnow, walk
|
srcinfo_property, srcinfo_property_list, trim_package, utcnow, walk
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
from ahriman.models.package_source import PackageSource
|
from ahriman.models.package_source import PackageSource
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -445,26 +445,6 @@ def test_trim_package() -> None:
|
|||||||
assert trim_package("package: a description") == "package"
|
assert trim_package("package: a description") == "package"
|
||||||
|
|
||||||
|
|
||||||
def test_unquote() -> None:
|
|
||||||
"""
|
|
||||||
must remove quotation marks
|
|
||||||
"""
|
|
||||||
for source in (
|
|
||||||
"abc",
|
|
||||||
"ab'c",
|
|
||||||
"ab\"c",
|
|
||||||
):
|
|
||||||
assert unquote(shlex.quote(source)) == source
|
|
||||||
|
|
||||||
|
|
||||||
def test_unquote_error() -> None:
|
|
||||||
"""
|
|
||||||
must raise value error on invalid quotation
|
|
||||||
"""
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
unquote("ab'c")
|
|
||||||
|
|
||||||
|
|
||||||
def test_utcnow() -> None:
|
def test_utcnow() -> None:
|
||||||
"""
|
"""
|
||||||
must generate correct timestamp
|
must generate correct timestamp
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import pytest
|
||||||
|
import shlex
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import MagicMock, call
|
from unittest.mock import MagicMock, call
|
||||||
@ -48,6 +51,35 @@ def test_from_env() -> None:
|
|||||||
assert PkgbuildPatch.from_env("KEY") == PkgbuildPatch("KEY", "")
|
assert PkgbuildPatch.from_env("KEY") == PkgbuildPatch("KEY", "")
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse() -> None:
|
||||||
|
"""
|
||||||
|
must parse string correctly
|
||||||
|
"""
|
||||||
|
assert PkgbuildPatch.parse("VALUE") == "VALUE"
|
||||||
|
assert PkgbuildPatch.parse("(ARRAY VALUE)") == ["ARRAY", "VALUE"]
|
||||||
|
assert PkgbuildPatch.parse("""("QU'OUTED" ARRAY VALUE)""") == ["QU'OUTED", "ARRAY", "VALUE"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_unquote() -> None:
|
||||||
|
"""
|
||||||
|
must remove quotation marks
|
||||||
|
"""
|
||||||
|
for source in (
|
||||||
|
"abc",
|
||||||
|
"ab'c",
|
||||||
|
"ab\"c",
|
||||||
|
):
|
||||||
|
assert PkgbuildPatch.unquote(shlex.quote(source)) == source
|
||||||
|
|
||||||
|
|
||||||
|
def test_unquote_error() -> None:
|
||||||
|
"""
|
||||||
|
must raise value error on invalid quotation
|
||||||
|
"""
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
PkgbuildPatch.unquote("ab'c")
|
||||||
|
|
||||||
|
|
||||||
def test_serialize() -> None:
|
def test_serialize() -> None:
|
||||||
"""
|
"""
|
||||||
must correctly serialize string values
|
must correctly serialize string values
|
||||||
|
Reference in New Issue
Block a user