diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 952a599..597f0fd 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.10.2 +current_version = 1.10.3 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? diff --git a/nwastdlib/__init__.py b/nwastdlib/__init__.py index 557e8ba..367393c 100644 --- a/nwastdlib/__init__.py +++ b/nwastdlib/__init__.py @@ -13,7 +13,7 @@ # """The NWA-stdlib module.""" -__version__ = "1.10.2" +__version__ = "1.10.3" from nwastdlib.f import const, identity diff --git a/nwastdlib/vlans.py b/nwastdlib/vlans.py index 3481f75..5a0f3de 100644 --- a/nwastdlib/vlans.py +++ b/nwastdlib/vlans.py @@ -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]: diff --git a/tests/test_vlans.py b/tests/test_vlans.py index a63ae64..790f6e4 100644 --- a/tests/test_vlans.py +++ b/tests/test_vlans.py @@ -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):