Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scan_iter() with type filter asserts when there is a stream key #233

Closed
mjessome opened this issue Sep 8, 2023 · 0 comments · Fixed by #234
Closed

scan_iter() with type filter asserts when there is a stream key #233

mjessome opened this issue Sep 8, 2023 · 0 comments · Fixed by #234
Labels
bug Something isn't working

Comments

@mjessome
Copy link

mjessome commented Sep 8, 2023

Describe the bug
I'm on fakeredis-py 2.18.0

When a stream exists, and using scan_iter(_type='XXX'), we hit the following assert:

key = <fakeredis._commands.Item object at 0x10feaad40>

    def key_value_type(key):
        if key.value is None:
            return SimpleString(b'none')
        elif isinstance(key.value, bytes):
            return SimpleString(b'string')
        elif isinstance(key.value, list):
            return SimpleString(b'list')
        elif isinstance(key.value, set):
            return SimpleString(b'set')
        elif isinstance(key.value, ZSet):
            return SimpleString(b'zset')
        elif isinstance(key.value, dict):
            return SimpleString(b'hash')
        else:
>           assert False  # pragma: nocover
E           AssertionError

To Reproduce

from fakeredis import FakeRedis

r = FakeRedis()

r.xadd("mystream", { "test": "value" })
for s in r.scan_iter(_type="STRING"):
    print(s)

Expected behavior

Doesn't assert, Stream keys are enumerated (or filtered out) just like any other key.

Desktop (please complete the following information):

  • OS: MacOS 13.4.1
  • python version: 3.10.8
  • redis-py version: 4.3.6

Additional context

Thank you!

@mjessome mjessome added the bug Something isn't working label Sep 8, 2023
@cunla cunla closed this as completed in #234 Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant