summaryrefslogtreecommitdiff
path: root/tests/test_helpers.py
diff options
context:
space:
mode:
authorAvital Fine <79420960+AvitalFineRedis@users.noreply.github.com>2021-11-25 14:45:19 +0100
committerGitHub <noreply@github.com>2021-11-25 15:45:19 +0200
commit393cd6280c6fb5394cc512ae15617236ecddac2e (patch)
tree67b0e59c10fec5bd7db984a1e2ff5351e7140e3b /tests/test_helpers.py
parent3de2e6b6b1bc061d875d36a6f40598453ce85c58 (diff)
downloadredis-py-393cd6280c6fb5394cc512ae15617236ecddac2e.tar.gz
Support RediSearch FT.PROFILE command (#1727)
Diffstat (limited to 'tests/test_helpers.py')
-rw-r--r--tests/test_helpers.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 467e00c..402eccf 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -5,7 +5,8 @@ from redis.commands.helpers import (
nativestr,
parse_to_list,
quote_string,
- random_string
+ random_string,
+ parse_to_dict
)
@@ -19,11 +20,34 @@ def test_list_or_args():
def test_parse_to_list():
+ assert parse_to_list(None) == []
r = ["hello", b"my name", "45", "555.55", "is simon!", None]
assert parse_to_list(r) == \
["hello", "my name", 45, 555.55, "is simon!", None]
+def test_parse_to_dict():
+ assert parse_to_dict(None) == {}
+ r = [['Some number', '1.0345'],
+ ['Some string', 'hello'],
+ ['Child iterators',
+ ['Time', '0.2089', 'Counter', 3, 'Child iterators',
+ ['Type', 'bar', 'Time', '0.0729', 'Counter', 3],
+ ['Type', 'barbar', 'Time', '0.058', 'Counter', 3]]]]
+ assert parse_to_dict(r) == {
+ 'Child iterators': {
+ 'Child iterators': [
+ {'Counter': 3.0, 'Time': 0.0729, 'Type': 'bar'},
+ {'Counter': 3.0, 'Time': 0.058, 'Type': 'barbar'}
+ ],
+ 'Counter': 3.0,
+ 'Time': 0.2089
+ },
+ 'Some number': 1.0345,
+ 'Some string': 'hello'
+ }
+
+
def test_nativestr():
assert nativestr('teststr') == 'teststr'
assert nativestr(b'teststr') == 'teststr'