Skip to content

Commit

Permalink
fix comparing
Browse files Browse the repository at this point in the history
  • Loading branch information
matveyvarg committed Oct 27, 2023
1 parent 2617e19 commit ddde6d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deker/tools/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cases/test_tools/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit ddde6d9

Please sign in to comment.