Skip to content

Commit

Permalink
Fix import used in GenericCommandsMixin.randomkey (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
mudetz committed Mar 31, 2023
1 parent 73b0c94 commit 54cb429
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fakeredis/commands_mixins/generic_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hashlib
import pickle
from random import random
import random

from fakeredis import _msgs as msgs
from fakeredis._command_args_parsing import extract_args
Expand Down
11 changes: 11 additions & 0 deletions test/test_mixins/test_generic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@ def test_pttl_should_return_minus_two_for_non_existent_key(r):
assert r.pttl('foo') == -2


def test_randomkey_returns_none_on_empty_db(r):
assert r.randomkey() is None


def test_randomkey_returns_existing_key(r):
r.set("foo", 1)
r.set("bar", 2)
r.set("baz", 3)
assert r.randomkey().decode() in ("foo", "bar", "baz")


def test_persist(r):
r.set('foo', 'bar', ex=20)
assert r.persist('foo') == 1
Expand Down

0 comments on commit 54cb429

Please sign in to comment.