27 lines
680 B
Python
27 lines
680 B
Python
"""Tests for the Redis cursor."""
|
|
|
|
import fakeredis.aioredis
|
|
|
|
from services.kevin_signal_bridge.cursor import RedisCursor
|
|
|
|
|
|
async def _redis():
|
|
return fakeredis.aioredis.FakeRedis()
|
|
|
|
|
|
async def test_cursor_defaults_to_zero():
|
|
cursor = RedisCursor(await _redis())
|
|
assert await cursor.last_seen_id() == 0
|
|
|
|
|
|
async def test_cursor_advance_persists_value():
|
|
cursor = RedisCursor(await _redis())
|
|
await cursor.advance(42)
|
|
assert await cursor.last_seen_id() == 42
|
|
|
|
|
|
async def test_cursor_advance_never_goes_backwards():
|
|
cursor = RedisCursor(await _redis())
|
|
await cursor.advance(42)
|
|
await cursor.advance(10)
|
|
assert await cursor.last_seen_id() == 42
|