Пример #1
0
def test_id_property():
    idprop = IDProperty('my-type')

    assert idprop.validate('my-type--90aaca8a-1110-5d32-956d-ac2f34a1bd8c')
    with pytest.raises(ValueError):
        idprop.validate('not-my-type--90aaca8a-1110-5d32-956d-ac2f34a1bd8c')
    assert idprop.validate(idprop.default())
Пример #2
0
def test_id_property():
    idprop = IDProperty('my-type')

    assert idprop.clean('my-type--90aaca8a-1110-5d32-956d-ac2f34a1bd8c')
    with pytest.raises(ValueError) as excinfo:
        idprop.clean('not-my-type--90aaca8a-1110-5d32-956d-ac2f34a1bd8c')
    assert str(excinfo.value) == "must start with 'my-type--'."
    with pytest.raises(ValueError) as excinfo:
        idprop.clean('my-type--foo')
    assert str(excinfo.value) == "must have a valid UUID after the prefix."

    assert idprop.clean(idprop.default())