diff --git a/src/jobflow/utils/uuid.py b/src/jobflow/utils/uuid.py index e6051af2..42f0b7ce 100644 --- a/src/jobflow/utils/uuid.py +++ b/src/jobflow/utils/uuid.py @@ -48,8 +48,6 @@ def get_timestamp_from_uuid(uuid: str) -> float: funcs = { "uuid1": _get_uuid_time_v1, } - if id_type not in funcs: - raise ValueError(f"UUID type {id_type} not supported.") return funcs[id_type](uuid) diff --git a/tests/test_uuid.py b/tests/test_uuid.py index 90a34e02..2c506437 100644 --- a/tests/test_uuid.py +++ b/tests/test_uuid.py @@ -1,3 +1,6 @@ +import pytest + + def test_uuid1(): from uuid import UUID @@ -5,5 +8,10 @@ def test_uuid1(): uuid = suuid("uuid1") assert UUID(uuid).version == 1 - assert isinstance(get_timestamp_from_uuid(uuid), float) + + with pytest.raises(ValueError, match="UUID type uuid2 not supported."): + suuid("uuid2") + + with pytest.raises(ValueError, match="ID type for FAKEUUID not recognized."): + get_timestamp_from_uuid("FAKEUUID")