diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-03-21 10:28:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:16:53 +0000 |
commit | 06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch) | |
tree | e82f1bc439997ae296f2e74f8a64d84c5d95f140 /tests/unittests/command_parse/test_list_parse.py | |
parent | Initial commit. (diff) | |
download | iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip |
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/unittests/command_parse/test_list_parse.py | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/unittests/command_parse/test_list_parse.py b/tests/unittests/command_parse/test_list_parse.py new file mode 100644 index 0000000..e60d7a2 --- /dev/null +++ b/tests/unittests/command_parse/test_list_parse.py @@ -0,0 +1,108 @@ +def test_rpush(judge_command): + judge_command( + "RPUSH list1 foo bar hello world", + {"command": "RPUSH", "key": "list1", "values": "foo bar hello world"}, + ) + judge_command( + "LPUSH list1 foo", {"command": "LPUSH", "key": "list1", "values": "foo"} + ) + + +def test_lindex(judge_command): + judge_command( + "LINDEX list1 10", {"command": "LINDEX", "key": "list1", "position": "10"} + ) + judge_command( + "LINDEX list1 -10", {"command": "LINDEX", "key": "list1", "position": "-10"} + ) + judge_command("LINDEX list1 1.1", None) + + +def test_lset(judge_command): + judge_command( + "LSET list1 10 newbie", + {"command": "LSET", "key": "list1", "position": "10", "value": "newbie"}, + ) + judge_command( + "LSET list1 -1 newbie", + {"command": "LSET", "key": "list1", "position": "-1", "value": "newbie"}, + ) + + +def test_brpoplpush(judge_command): + judge_command( + "BRPOPLPUSH list1 list2 10", + {"command": "BRPOPLPUSH", "key": "list1", "newkey": "list2", "timeout": "10"}, + ) + judge_command( + "BRPOPLPUSH list1 list2 0", + {"command": "BRPOPLPUSH", "key": "list1", "newkey": "list2", "timeout": "0"}, + ) + judge_command("BRPOPLPUSH list1 list2 -1", None) + + +def test_linsert(judge_command): + judge_command( + 'LINSERT mylist BEFORE "World" "There"', + { + "command": "LINSERT", + "key": "mylist", + "position_choice": "BEFORE", + "value": ['"World"', '"There"'], + }, + ) + judge_command( + 'LINSERT mylist after "World" "There"', + { + "command": "LINSERT", + "key": "mylist", + "position_choice": "after", + "value": ['"World"', '"There"'], + }, + ) + + +def test_lpos(judge_command): + judge_command("LPOS mylist c", {"command": "LPOS", "key": "mylist", "element": "c"}) + judge_command( + "LPOS mylist c RANK 2", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "rank_const": "RANK", + "rank": "2", + }, + ) + judge_command( + "LPOS mylist c RANK -1", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "rank_const": "RANK", + "rank": "-1", + }, + ) + judge_command( + "LPOS mylist c COUNT 2", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "count_const": "COUNT", + "count": "2", + }, + ) + judge_command( + "LPOS mylist c RANK -1 COUNT 2", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "count_const": "COUNT", + "count": "2", + "rank_const": "RANK", + "rank": "-1", + }, + ) |