diff --git a/deker/tools/array.py b/deker/tools/array.py index 3fd9c43..9ef340b 100644 --- a/deker/tools/array.py +++ b/deker/tools/array.py @@ -93,9 +93,11 @@ def generate_uid(array_type: ArrayType) -> str: :param array_type: Either array or varray """ - assert isinstance(array_type, ArrayType), "Invalid argument type. Array type is required" + if not isinstance(array_type, ArrayType): + raise TypeError("Invalid argument type. Array type is required") + namespace = uuid.NAMESPACE_X500 if array_type == ArrayType.array else uuid.NAMESPACE_OID - return str(uuid.uuid5(namespace, array_type + get_utc().isoformat())) + return str(uuid.uuid5(namespace, array_type.value + get_utc().isoformat())) def get_id(array: Any) -> str: diff --git a/tests/test_cases/test_tools/test_tools.py b/tests/test_cases/test_tools/test_tools.py index 0a5a7a0..0df3848 100644 --- a/tests/test_cases/test_tools/test_tools.py +++ b/tests/test_cases/test_tools/test_tools.py @@ -6,6 +6,7 @@ from deker_local_adapters import LocalCollectionAdapter +from deker.tools.array import generate_uid from tests.parameters.collection_params import CollectionParams from deker.collection import Collection @@ -220,5 +221,11 @@ def test_convert_isoformat_attrs_raises(attrs): assert convert_iso_attrs_to_datetime(attrs) +@pytest.mark.parametrize("array_type_arg", (list(), set(), tuple(), dict(), 1, "2", 3.4)) +def test_generate_id_raises(array_type_arg): + with pytest.raises(TypeError): + generate_uid(array_type_arg) + + if __name__ == "__main__": pytest.main()