IGNITE-15266 Fix nested object arrays deserialization - Fixes #48.
Signed-off-by: Ivan Daschinsky <ivandasch@apache.org>
diff --git a/pyignite/utils.py b/pyignite/utils.py
index 427cceb..5fcbd38 100644
--- a/pyignite/utils.py
+++ b/pyignite/utils.py
@@ -66,7 +66,8 @@
"""
Check if a value is a tuple of data item and its type hint.
"""
- return isinstance(value, tuple) and len(value) == 2 and issubclass(value[1], IgniteDataType)
+ return isinstance(value, tuple) and len(value) == 2 and inspect.isclass(value[1]) and \
+ issubclass(value[1], IgniteDataType)
def int_overflow(value: int) -> int:
diff --git a/tests/common/test_datatypes.py b/tests/common/test_datatypes.py
index ebbafb6..3a0ee51 100644
--- a/tests/common/test_datatypes.py
+++ b/tests/common/test_datatypes.py
@@ -166,6 +166,41 @@
assert await async_cache.get('my_key') == value
+nested_array_objects_params = [
+ [
+ (ObjectArrayObject.OBJECT, [
+ ((ObjectArrayObject.OBJECT, [
+ 'test', 1, Value(1, 'test'),
+ ((ObjectArrayObject.OBJECT, ['test', 1, Value(1, 'test')]), ObjectArrayObject)
+ ]), ObjectArrayObject)
+ ]),
+ (ObjectArrayObject.OBJECT, [
+ (ObjectArrayObject.OBJECT, ['test', 1, Value(1, 'test'),
+ (ObjectArrayObject.OBJECT, ['test', 1, Value(1, 'test')])])
+ ])
+ ],
+]
+
+
+@pytest.mark.parametrize(
+ 'hinted_value, value',
+ nested_array_objects_params
+)
+def test_put_get_nested_array_objects(cache, hinted_value, value):
+ cache.put('my_key', hinted_value, value_hint=ObjectArrayObject)
+ assert cache.get('my_key') == value
+
+
+@pytest.mark.parametrize(
+ 'hinted_value, value',
+ nested_array_objects_params
+)
+@pytest.mark.asyncio
+async def test_put_get_nested_array_objects_async(async_cache, hinted_value, value):
+ await async_cache.put('my_key', hinted_value, value_hint=ObjectArrayObject)
+ assert await async_cache.get('my_key') == value
+
+
bytearray_params = [
([1, 2, 3, 5], ByteArrayObject),
((7, 8, 13, 18), ByteArrayObject),