cunla / fakeredis-py

Implementation of Redis API in python without having a server running. Fully compatible with using redis-py.
https://fakeredis.moransoftware.ca/
BSD 3-Clause "New" or "Revised" License
300 stars 49 forks source link

EXAT option does not work #279

Closed Beduir closed 10 months ago

Beduir commented 10 months ago

Describe the bug EXAT option in set-method does not work, raises an exception.

To Reproduce

import asyncio

import redis.asyncio as aioredis
from fakeredis import FakeAsyncRedis

async def test(redis):
    await redis.set('test', '1', exat=1706632494)

async def test_pipeline(redis):
    async with redis.pipeline() as pipe:
        await pipe.set('test', '1', exat=1706632494)
        await pipe.execute()

async def run_test():
    fake_redis = FakeAsyncRedis()
    redis = aioredis.Redis()
    await test(redis)   # <--- This will OK
    await test_pipeline(redis)   # <--- This will OK
    await test(fake_redis)   # <--- This will fail
    await test_pipeline(fake_redis)   # <--- This will fail

if __name__ == '__main__':
    asyncio.run(run_test())
Exception has occurred: ResponseError
syntax error
  File "/home/beduir/dev/python/test/test.py", line 8, in test
    await redis.set('test', '1', exat=1706632494)
  File "/home/beduir/dev/python/test/test.py", line 22, in run_test
    await test(fake_redis)
  File "/home/beduir/dev/python/test/test.py", line 27, in <module>
    asyncio.run(run_test())
redis.exceptions.ResponseError: syntax error
Exception has occurred: ResponseError
Command # 1 (SET test 1 EXAT 1706632494) of pipeline caused error: ('syntax error',)
  File "/home/beduir/dev/python/test/test.py", line 14, in test_pipeline
    await pipe.execute()
  File "/home/beduir/dev/python/test/test.py", line 23, in run_test
    await test_pipeline(fake_redis)
  File "/home/beduir/dev/python/test/test.py", line 27, in <module>
    asyncio.run(run_test())
redis.exceptions.ResponseError: Command # 1 (SET test 1 EXAT 1706632494) of pipeline caused error: ('syntax error',)

Expected behavior Doesn't raise an exception.

Desktop (please complete the following information):

cunla commented 10 months ago

Thanks for bringing this up. EXAT/PXAT were added in 6.2/7.2. It is easy to add support for them, I should do it today/tomorrow. I am planning to release a new ver this weekend.