mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
Add documents and tests for substitution commands
This commit is contained in:
parent
3628505ea7
commit
ffa6eb7b8f
2 changed files with 28 additions and 0 deletions
11
README.rst
11
README.rst
|
@ -124,6 +124,17 @@ proxy
|
||||||
max_concurrent
|
max_concurrent
|
||||||
Max number of concurrent jobs. Default: 20.
|
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 in a Webpage
|
||||||
-------------------
|
-------------------
|
||||||
Search through a specific webpage for the version string. This type of version finding has these fields:
|
Search through a specific webpage for the version string. This type of version finding has these fields:
|
||||||
|
|
17
tests/test_substitute.py
Normal file
17
tests/test_substitute.py
Normal 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"
|
Loading…
Add table
Reference in a new issue