Skip to content
Snippets Groups Projects
Verified Commit ef2baad7 authored by Leonidas Spyropoulos's avatar Leonidas Spyropoulos
Browse files

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

parent 137ed04d
No related branches found
No related tags found
1 merge request!646feat: expand on update.py tests and show on Gitlab UI
Pipeline #49962 passed
......@@ -44,3 +44,8 @@ doc/rpc.html
# Ignore .python-version file from Pyenv
.python-version
# Ignore coverage report
coverage.xml
# Ignore pytest report
report.xml
......@@ -51,11 +51,12 @@ test:
# Run sharness.
- make -C test sh
# Run pytest.
- pytest
- pytest --junitxml="pytest-report.xml"
- make -C test coverage # Produce coverage reports.
coverage: '/TOTAL.*\s+(\d+\%)/'
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
junit: pytest-report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
......
......@@ -25,7 +25,7 @@ rm -rf $PROMETHEUS_MULTIPROC_DIR
mkdir -p $PROMETHEUS_MULTIPROC_DIR
# Run pytest with optional targets in front of it.
pytest
pytest --junitxml="/data/pytest-report.xml"
# By default, report coverage and move it into cache.
if [ $COVERAGE -eq 1 ]; then
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment