Skip to content

Commit 9527ae8

Browse files
brainixchayim
andauthored
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 <[email protected]> * 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 <[email protected]>
1 parent 6c70fcd commit 9527ae8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

redis/commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,15 @@ def lastsave(self):
523523
"""
524524
return self.execute_command('LASTSAVE')
525525

526+
def lolwut(self, *version_numbers):
527+
"""Get the Redis version and a piece of generative computer art
528+
See: https://redis.io/commands/lolwut
529+
"""
530+
if version_numbers:
531+
return self.execute_command('LOLWUT VERSION', *version_numbers)
532+
else:
533+
return self.execute_command('LOLWUT')
534+
526535
def migrate(self, host, port, keys, destination_db, timeout,
527536
copy=False, replace=False, auth=None):
528537
"""

tests/test_commands.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ def test_info(self, r):
531531
def test_lastsave(self, r):
532532
assert isinstance(r.lastsave(), datetime.datetime)
533533

534+
@skip_if_server_version_lt('5.0.0')
535+
def test_lolwut(self, r):
536+
lolwut = r.lolwut().decode('utf-8')
537+
assert 'Redis ver.' in lolwut
538+
539+
lolwut = r.lolwut(5, 6, 7, 8).decode('utf-8')
540+
assert 'Redis ver.' in lolwut
541+
534542
def test_object(self, r):
535543
r['a'] = 'foo'
536544
assert isinstance(r.object('refcount', 'a'), int)

0 commit comments

Comments
 (0)