Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.10.2
current_version = 1.10.3
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion nwastdlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
"""The NWA-stdlib module."""

__version__ = "1.10.2"
__version__ = "1.10.3"

from nwastdlib.f import const, identity

Expand Down
2 changes: 1 addition & 1 deletion nwastdlib/vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pydantic.json_schema import JsonSchemaValue
from pydantic_core import CoreSchema, SchemaSerializer, core_schema

VLAN_RANGE_JSON_SCHEMA_REGEX = r"^(?:([1-9]|[1-9]\d{1,2}|[1-4]\d{3})(?:-(?:[1-9]|[1-9]\d{1,2}|[1-4]\d{3}))?)$"
VLAN_RANGE_JSON_SCHEMA_REGEX = r"^(?:[1-9]\d{0,2}|[1-4]\d{3})(?:-(?:[1-9]\d{0,2}|[1-4]\d{3}))?(?:\s*,\s*(?:[1-9]\d{0,2}|[1-4]\d{3})(?:-(?:[1-9]\d{0,2}|[1-4]\d{3}))?)*$"


def to_ranges(i: Iterable[int]) -> Iterable[range]:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,17 @@ def test_vlan_rejected_by_schema(vlan, vr_schema):
jsonschema.validate({"vr": str(vlan)}, vr_schema)


@pytest.mark.parametrize("vlanrange", ["1-1", "9-9", "49-59", "99-300", "999-1001", "3999-4999"])
@pytest.mark.parametrize(
"vlanrange", ["1-1", "9-9", "49-59", "99-300", "999-1001", "3999-4999", "10,20,50-100", "10, 20, 50-100"]
)
def test_vlan_ranges_allowed_by_schema(vlanrange, vr_schema):
"""Test vlan ranges which should be allowed by the JSON Schema."""
assert jsonschema.validate({"vr": vlanrange}, vr_schema) is None


@pytest.mark.parametrize("vlanrange", ["-1", "-10-0", "0-1", "4999-5000", "5000-5002"])
@pytest.mark.parametrize(
"vlanrange", ["-1", "-10-0", "0-1", "4999-5000", "5000-5002", "10,20,5000-5002", "10, 20, 5000-5002"]
)
def test_vlan_ranges_rejected_by_schema(vlanrange, vr_schema):
"""Test vlan ranges which should be rejected by the JSON Schema."""
with pytest.raises(jsonschema.ValidationError):
Expand Down