feat: expand on update.py tests and show on Gitlab UI

Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
Leonidas Spyropoulos 2023-01-27 16:41:37 +00:00
parent 137ed04d34
commit ef2baad7b3
No known key found for this signature in database
GPG key ID: 59E43E106B247368
4 changed files with 80 additions and 4 deletions

View file

@ -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