Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yipin-chen committed Jun 24, 2024
1 parent b12d08e commit 75e6d43
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 60 deletions.
16 changes: 7 additions & 9 deletions python/python/glide/async_commands/cluster_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,21 +527,19 @@ async def lolwut(
See https://valkey.io/commands/lolwut for more details.
Args:
version (Optional(int)): Version of computer art to generate.
parameters (Optional[str]): Additional set of arguments in order to change the output:
For version <code>5</code>, those are length of the line, number of squares per row, and number of squares per column.
For version <code>6</code>, those are number of columns and number of lines.
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
version (Optional[int]): Version of computer art to generate.
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
For version `5`, those are length of the line, number of squares per row, and number of squares per column.
For version `6`, those are number of columns and number of lines.
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
in which case the client will route the command to the nodes defined by `route`.
Returns:
str: A piece of generative computer art along with the current Redis version.
Examples:
>>> client.lolwut(6, new int[] [ 40, 20 ], ALL_NODES);
"Redis ver. 7.2.3" # Indicate the current Redis version
Since: Redis version 5.0.0.
>>> await client.lolwut(6, [40, 20], ALL_NODES);
"Redis ver. 7.2.3" # Indicates the current Redis version
"""
args = []
if version is not None:
Expand Down
19 changes: 8 additions & 11 deletions python/python/glide/async_commands/standalone_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,26 +467,23 @@ async def lolwut(
) -> str:
"""
Displays a piece of generative computer art and the Redis version.
The command will be routed to a random node.
See https://valkey.io/commands/lolwut for more details.
Args:
version (Optional(int)): Version of computer art to generate.
parameters (Optional[str]): Additional set of arguments in order to change the output:
For version <code>5</code>, those are length of the line, number of squares per row, and number of squares per column.
For version <code>6</code>, those are number of columns and number of lines.
version (Optional[int]): Version of computer art to generate.
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
For version `5`, those are length of the line, number of squares per row, and number of squares per column.
For version `6`, those are number of columns and number of lines.
Returns:
str: A piece of generative computer art along with the current Redis version.
Examples:
>>> client.lolwut(6, new int[] [ 40, 20 ]);
"Redis ver. 7.2.3" # Indicate the current Redis version
>>> client.lolwut(5, new int[] [ 30, 5, 5 ]);
"Redis ver. 7.2.3" # Indicate the current Redis version
Since: Redis version 5.0.0.
>>> await client.lolwut(6, [40, 20]);
"Redis ver. 7.2.3" # Indicates the current Redis version
>>> await client.lolwut(5, [30, 5, 5]);
"Redis ver. 7.2.3" # Indicates the current Redis version
"""
args = []
if version is not None:
Expand Down
12 changes: 5 additions & 7 deletions python/python/glide/async_commands/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3449,18 +3449,16 @@ def lolwut(
) -> TTransaction:
"""
Displays a piece of generative computer art and the Redis version.
See https://valkey.io/commands/copy for more details.
See https://valkey.io/commands/lolwut for more details.
Args:
version (Optional(int)): Version of computer art to generate.
parameters (Optional[str]): Additional set of arguments in order to change the output:
For version <code>5</code>, those are length of the line, number of squares per row, and number of squares per column.
For version <code>6</code>, those are number of columns and number of lines.
version (Optional[int]): Version of computer art to generate.
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
For version `5`, those are length of the line, number of squares per row, and number of squares per column.
For version `6`, those are number of columns and number of lines.
Command Response:
str: A piece of generative computer art along with the current Redis version.
Since: Redis version 5.0.0.
"""
args = []
if version is not None:
Expand Down
32 changes: 11 additions & 21 deletions python/python/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5564,6 +5564,8 @@ async def test_getex(self, redis_client: TRedisClient):
async def test_lolwut(self, redis_client: TRedisClient):
result = await redis_client.lolwut()
assert "Redis ver. " in result
result = await redis_client.lolwut(parameters=[])
assert "Redis ver. " in result
result = await redis_client.lolwut(parameters=[50, 20])
assert "Redis ver. " in result
result = await redis_client.lolwut(6)
Expand All @@ -5574,33 +5576,21 @@ async def test_lolwut(self, redis_client: TRedisClient):
if isinstance(redis_client, RedisClusterClient):
# test with multi-node route
result = await redis_client.lolwut(route=AllNodes())
if isinstance(result, dict):
for node_result in result.values():
assert "Redis ver. " in node_result
else:
assert "Redis ver. " in result
assert isinstance(result, dict)
for node_result in result.values():
assert "Redis ver. " in node_result

result = await redis_client.lolwut(parameters=[10, 20], route=AllNodes())
if isinstance(result, dict):
for node_result in result.values():
assert "Redis ver. " in node_result
else:
assert "Redis ver. " in result
assert isinstance(result, dict)
for node_result in result.values():
assert "Redis ver. " in node_result

# # test with single-node route
# test with single-node route
result = await redis_client.lolwut(2, route=RandomNode())
if isinstance(result, dict):
for node_result in result.values():
assert "Redis ver. " in node_result
else:
assert "Redis ver. " in result
assert "Redis ver. " in node_result

result = await redis_client.lolwut(2, [10, 20], RandomNode())
if isinstance(result, dict):
for node_result in result.values():
assert "Redis ver. " in node_result
else:
assert "Redis ver. " in result
assert "Redis ver. " in node_result


class TestMultiKeyCommandCrossSlot:
Expand Down
15 changes: 3 additions & 12 deletions python/python/tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,6 @@ async def test_lolwut_transaction(self, redis_client: RedisClusterClient):
results = await redis_client.exec(transaction)
assert results is not None

if isinstance(results, dict):
for node_result in results.values():
if isinstance(node_result, str) and "Redis ver. " in node_result:
assert True
else:
assert False
else:
for element in results:
if isinstance(element, str) and "Redis ver. " in element:
assert True
else:
assert False
for element in results:
if isinstance(element, str):
assert "Redis ver. " in element

0 comments on commit 75e6d43

Please sign in to comment.