2020-08-17 08:21:02 +00:00
|
|
|
# MIT licensed
|
|
|
|
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
|
|
|
|
|
|
|
|
import pytest
|
2024-11-03 10:29:19 +00:00
|
|
|
pytestmark = pytest.mark.asyncio
|
2020-08-17 08:21:02 +00:00
|
|
|
|
|
|
|
async def test_substitute_prefix(get_version):
|
|
|
|
assert await get_version("example", {
|
|
|
|
"source": "manual",
|
|
|
|
"manual": "v1.0",
|
|
|
|
"prefix": "v",
|
|
|
|
}) == "1.0"
|
|
|
|
|
|
|
|
async def test_substitute_prefix_missing_ok(get_version):
|
|
|
|
assert await get_version("example", {
|
|
|
|
"source": "manual",
|
|
|
|
"manual": "1.0",
|
|
|
|
"prefix": "v",
|
|
|
|
}) == "1.0"
|
|
|
|
|
|
|
|
async def test_substitute_regex(get_version):
|
|
|
|
assert await get_version("example", {
|
|
|
|
"source": "manual",
|
|
|
|
"manual": "r15c",
|
|
|
|
"from_pattern": r"r(\d+)([a-z])",
|
|
|
|
"to_pattern": r"r\1.\2",
|
|
|
|
}) == "r15.c"
|
|
|
|
|
|
|
|
async def test_substitute_regex_missing_ok(get_version):
|
|
|
|
assert await get_version("example", {
|
|
|
|
"source": "manual",
|
|
|
|
"manual": "r15",
|
|
|
|
"from_pattern": r"r(\d+)([a-z])",
|
|
|
|
"to_pattern": r"r\1.\2",
|
|
|
|
}) == "r15"
|
|
|
|
|
2020-10-01 20:39:57 +00:00
|
|
|
async def test_substitute_regex_empty_to_pattern(get_version):
|
|
|
|
assert await get_version("example", {
|
|
|
|
"source": "manual",
|
|
|
|
"manual": "15-debian",
|
|
|
|
"from_pattern": r"-\w+$",
|
|
|
|
"to_pattern": r"",
|
|
|
|
}) == "15"
|
|
|
|
|
2020-08-17 08:21:02 +00:00
|
|
|
async def test_substitute_prefix_has_higher_priority(get_version):
|
|
|
|
assert await get_version("example", {
|
|
|
|
"source": "manual",
|
2024-02-27 05:50:53 +00:00
|
|
|
"manual": "Version 1.2 Beta 3",
|
|
|
|
"prefix": "Version ",
|
|
|
|
"from_pattern": r" Beta ",
|
|
|
|
"to_pattern": r"b",
|
|
|
|
}) == "1.2b3"
|