summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajiv Bakulesh Shah <brainix@gmail.com>2021-09-30 21:14:31 -0700
committerGitHub <noreply@github.com>2021-10-01 07:14:31 +0300
commit9527ae88538735c10def3716cdae9388cdee2388 (patch)
tree6c6c39549042aa1c126e4e6d77e507a0fb5997b9
parent6c70fcdd10cca7de15175a77824009babfac4417 (diff)
downloadredis-py-9527ae88538735c10def3716cdae9388cdee2388.tar.gz
Implement/test LOLWUT command (#1568)
* Implement/test LOLWUT command https://redis.io/commands/lolwut This is a lot of fun to play with: ```python >>> from redis import Redis >>> redis = Redis() >>> print(redis.lolwut(5, 6, 7, 8).decode('utf-8')) ⣴⣶⣶⣶⣶⡆ ⣿⣿⣿⣿⣿⡇ ⠹⡿⠟⣿⡿⠃ ⠀⠀⠀⠀⠀⠀ Georg Nees - schotter, plotter on paper, 1968. Redis ver. 6.0.10 >>> print(redis.lolwut(5, 6, 7, 8).decode('utf-8')) ⢰⣶⣶⣶⣶⡆ ⢿⣿⣿⣿⣿⠁ ⠸⡿⢿⠿⡿⠃ ⠀⠀⠀⠀⠀⠀ Georg Nees - schotter, plotter on paper, 1968. Redis ver. 6.0.10 >>> print(redis.lolwut(5, 6, 7, 8).decode('utf-8')) ⢰⣶⣶⣶⣶⡆ ⣸⣿⣿⣻⣿⡅ ⠿⡿⠻⠿⠿⠁ ⠀⠀⠀⠀⠀⠀ Georg Nees - schotter, plotter on paper, 1968. Redis ver. 6.0.10 >>> ``` * Add link to LOLWUT command documentation Co-authored-by: Chayim <chayim@users.noreply.github.com> * Skip LOLWUT unit test for Redis < 5.0.0 The `LOLWUT` command was introduced in Redis 5.0.0: https://redis.io/commands/lolwut Co-authored-by: Chayim <chayim@users.noreply.github.com>
-rw-r--r--redis/commands.py9
-rw-r--r--tests/test_commands.py8
2 files changed, 17 insertions, 0 deletions
diff --git a/redis/commands.py b/redis/commands.py
index 4266f9c..48d234e 100644
--- a/redis/commands.py
+++ b/redis/commands.py
@@ -523,6 +523,15 @@ class Commands:
"""
return self.execute_command('LASTSAVE')
+ def lolwut(self, *version_numbers):
+ """Get the Redis version and a piece of generative computer art
+ See: https://redis.io/commands/lolwut
+ """
+ if version_numbers:
+ return self.execute_command('LOLWUT VERSION', *version_numbers)
+ else:
+ return self.execute_command('LOLWUT')
+
def migrate(self, host, port, keys, destination_db, timeout,
copy=False, replace=False, auth=None):
"""
diff --git a/tests/test_commands.py b/tests/test_commands.py
index a283afc..736ae45 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -531,6 +531,14 @@ class TestRedisCommands:
def test_lastsave(self, r):
assert isinstance(r.lastsave(), datetime.datetime)
+ @skip_if_server_version_lt('5.0.0')
+ def test_lolwut(self, r):
+ lolwut = r.lolwut().decode('utf-8')
+ assert 'Redis ver.' in lolwut
+
+ lolwut = r.lolwut(5, 6, 7, 8).decode('utf-8')
+ assert 'Redis ver.' in lolwut
+
def test_object(self, r):
r['a'] = 'foo'
assert isinstance(r.object('refcount', 'a'), int)