Add documents and tests for substitution commands

This commit is contained in:
Yen Chi Hsuan 2017-10-11 01:50:44 +08:00
parent 3628505ea7
commit ffa6eb7b8f
2 changed files with 28 additions and 0 deletions

View File

@ -124,6 +124,17 @@ proxy
max_concurrent
Max number of concurrent jobs. Default: 20.
Global Options
--------------
The following options applies to all checkers.
prefix
Strip the prefix string if the version string starts with it.
from_pattern, to_pattern
Both are Python-compatible regular expressions. If ``from_pattern`` is found
in the version string, it will be replaced with ``to_pattern``
Search in a Webpage
-------------------
Search through a specific webpage for the version string. This type of version finding has these fields:

17
tests/test_substitute.py Normal file
View File

@ -0,0 +1,17 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = pytest.mark.asyncio
async def test_substitute_prefix(get_version):
assert await get_version("example", {"manual": "v1.0", "prefix": "v"}) == "1.0"
async def test_substitute_prefix_missing_ok(get_version):
assert await get_version("example", {"manual": "1.0", "prefix": "v"}) == "1.0"
async def test_substitute_regex(get_version):
assert await get_version("example", {"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", {"manual": "r15", "from_pattern": r"r(\d+)([a-z])", "to_pattern": r"r\1.\2"}) == "r15"