Esempio n. 1
0
def test_kwargs_invalid(value):
    """
    GIVEN value for x-kwargs that has an invalid format
    WHEN get_kwargs is called with the value
    THEN MalformedExtensionPropertyError is raised.
    """
    name = "x-kwargs"
    source = {name: value}

    with pytest.raises(exceptions.MalformedExtensionPropertyError):
        ext_prop.get_kwargs(source=source)
Esempio n. 2
0
def test_kwargs_valid_missing():
    """
    GIVEN empty value
    WHEN get_kwargs is called with the value
    THEN None is returned.
    """
    source = {}

    returned_value = ext_prop.get_kwargs(source=source)

    assert returned_value is None
Esempio n. 3
0
def test_kwargs_valid(prefix, value):
    """
    GIVEN prefix and value for x-kwargs that has a valid format
    WHEN get_kwargs is called with the value
    THEN the value is returned.
    """
    name = "kwargs"
    source = {f"{prefix}{name}": value}

    returned_value = ext_prop.get_kwargs(source=source)

    assert returned_value == value
Esempio n. 4
0
def test_kwargs_valid_name(prefix):
    """
    GIVEN prefix and value for kwargs that has a valid format and a property name
    WHEN get_kwargs is called with the value and the name
    THEN the value is returned.
    """
    name = "foreign-key-kwargs"
    value = {"key": "value"}
    source = {f"{prefix}{name}": value}

    returned_value = ext_prop.get_kwargs(
        source=source, name=f"{types.KeyPrefixes.SHORT}{name}")

    assert returned_value == value