Skip to content
Permalink
Browse files
IGNITE-15266 Fix nested object arrays deserialization - Fixes #48.
Signed-off-by: Ivan Daschinsky <ivandasch@apache.org>
  • Loading branch information
bojidar-bg authored and ivandasch committed Aug 6, 2021
1 parent 05dc38e commit be18440ea2d81a053ad8a8d031bf1652f0b8e92a
Showing 2 changed files with 37 additions and 1 deletion.
@@ -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:
@@ -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),

0 comments on commit be18440

Please sign in to comment.