Skip to content

Commit a2f0c14

Browse files
committed
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 >>> ```
1 parent e9837c1 commit a2f0c14

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

redis/commands.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ def lastsave(self):
504504
"""
505505
return self.execute_command('LASTSAVE')
506506

507+
def lolwut(self, *version_numbers):
508+
"Get the Redis version and a piece of generative computer art"
509+
if version_numbers:
510+
return self.execute_command('LOLWUT VERSION', *version_numbers)
511+
else:
512+
return self.execute_command('LOLWUT')
513+
507514
def migrate(self, host, port, keys, destination_db, timeout,
508515
copy=False, replace=False, auth=None):
509516
"""

tests/test_commands.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,13 @@ def test_info(self, r):
518518
def test_lastsave(self, r):
519519
assert isinstance(r.lastsave(), datetime.datetime)
520520

521+
def test_lolwut(self, r):
522+
lolwut = r.lolwut().decode('utf-8')
523+
assert 'Redis ver.' in lolwut
524+
525+
lolwut = r.lolwut(5, 6, 7, 8).decode('utf-8')
526+
assert 'Redis ver.' in lolwut
527+
521528
def test_object(self, r):
522529
r['a'] = 'foo'
523530
assert isinstance(r.object('refcount', 'a'), int)

0 commit comments

Comments
 (0)