Ejemplo n.º 1
0
def test_vlanid_parameter_error(raw, config):
    with pytest.raises(InterfaceTypeError):
        assert VLANIDParameter(**config).clean(raw)
Ejemplo n.º 2
0
ServicePointer = DictParameter(attrs={"service": Pointer})
RequestFrom = ObjectPointer | InterfacePointer | ServicePointer
# to: section
RequestTo = ObjectPointer | LevelPointer | InterfacePointer | ServicePointer
# config: section
RequestConfig = DictParameter(
    attrs={
        "max_depth": IntParameter(default=MAX_DEPTH_DEFAULT),
        "n_shortest": IntParameter(default=N_SHORTEST_DEFAULT),
    },
    required=False,
)
# constraints: section
RequestVLANConstraint = DictParameter(
    attrs={
        "vlan": VLANIDParameter(required=False),
        "interface_untagged": BooleanParameter(required=False),
        "strict": BooleanParameter(default=False),
    },
    required=False,
)
RequestConstraints = DictParameter(
    attrs={
        "vlan": RequestVLANConstraint,
        "upwards": BooleanParameter(default=False)
    },
    required=False,
)
Request = DictParameter(
    attrs={
        "from": RequestFrom,
Ejemplo n.º 3
0
def test_vlanid_parameter(raw, config, expected):
    assert VLANIDParameter(**config).clean(raw) == expected
Ejemplo n.º 4
0
def test_vlanid_parameter():
    assert VLANIDParameter().clean(10) == 10
    with pytest.raises(InterfaceTypeError):
        VLANIDParameter().clean(5000)
    with pytest.raises(InterfaceTypeError):
        VLANIDParameter().clean(0)