mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: expand on update.py tests and show on Gitlab UI
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
137ed04d34
commit
ef2baad7b3
4 changed files with 80 additions and 4 deletions
|
@ -1,8 +1,9 @@
|
|||
import json
|
||||
|
||||
import pytest
|
||||
from srcinfo import parse
|
||||
|
||||
from aurweb.git.update import extract_arch_fields
|
||||
from aurweb.git.update import extract_arch_fields, parse_dep, size_humanize
|
||||
|
||||
SRCINFO = """
|
||||
pkgbase = ponies
|
||||
|
@ -131,3 +132,72 @@ def test_git_update_extract_arch_fields():
|
|||
assert sources[0]["value"] == "ponies.service"
|
||||
|
||||
# add more...
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"size, expected",
|
||||
[
|
||||
(1024, "1024B"),
|
||||
(1024.5, "1024.50B"),
|
||||
(256000, "250.00KiB"),
|
||||
(25600000, "24.41MiB"),
|
||||
(2560000000, "2.38GiB"),
|
||||
(2560000000000, "2.33TiB"),
|
||||
(2560000000000000, "2.27PiB"),
|
||||
(2560000000000000000, "2.22EiB"),
|
||||
(2560000000000000000000, "2.17ZiB"),
|
||||
(2560000000000000000000000, "2.12YiB"),
|
||||
],
|
||||
)
|
||||
def test_size_humanize(size: any, expected: str):
|
||||
assert size_humanize(size) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"depstring, exp_depname, exp_depdesc, exp_depcond",
|
||||
[
|
||||
(
|
||||
"my-little-pony: optional kids support",
|
||||
"my-little-pony",
|
||||
"optional kids support",
|
||||
"",
|
||||
),
|
||||
(
|
||||
"my-little-pony>7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
">7",
|
||||
),
|
||||
(
|
||||
"my-little-pony=7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
"=7",
|
||||
),
|
||||
(
|
||||
"my-little-pony<7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
"<7",
|
||||
),
|
||||
(
|
||||
"my-little-pony=<7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
"=<7",
|
||||
),
|
||||
(
|
||||
"my-little-pony>=7.1: optional kids support",
|
||||
"my-little-pony",
|
||||
"optional kids support",
|
||||
">=7.1",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parse_dep(
|
||||
depstring: str, exp_depname: str, exp_depdesc: str, exp_depcond: str
|
||||
):
|
||||
depname, depdesc, depcond = parse_dep(depstring)
|
||||
assert depname == exp_depname
|
||||
assert depdesc == exp_depdesc
|
||||
assert depcond == exp_depcond
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue