You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2021/08/06 10:45:26 UTC
[ignite-python-thin-client] branch master updated: IGNITE-15266 Fix
nested object arrays deserialization - Fixes #48.
This is an automated email from the ASF dual-hosted git repository.
ivandasch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-python-thin-client.git
The following commit(s) were added to refs/heads/master by this push:
new be18440 IGNITE-15266 Fix nested object arrays deserialization - Fixes #48.
be18440 is described below
commit be18440ea2d81a053ad8a8d031bf1652f0b8e92a
Author: Bojidar Marinov <bo...@gmail.com>
AuthorDate: Fri Aug 6 13:43:52 2021 +0300
IGNITE-15266 Fix nested object arrays deserialization - Fixes #48.
Signed-off-by: Ivan Daschinsky <iv...@apache.org>
---
pyignite/utils.py | 3 ++-
tests/common/test_datatypes.py | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
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 @@ def is_hinted(value):
"""
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 @@ async def test_put_get_data_async(async_cache, value, value_hint):
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),