mirror of
https://github.com/d3vyce/taskiq-deduplication.git
synced 2026-08-05 03:14:08 +00:00
feat: add RedisDeduplicationScheduleSource for scheduled task deduplication
This commit is contained in:
+31
-1
@@ -1,7 +1,9 @@
|
||||
import pytest
|
||||
import fakeredis.aioredis
|
||||
from redis.asyncio import Redis
|
||||
from taskiq import TaskiqMessage, TaskiqResult
|
||||
from taskiq import ScheduledTask, TaskiqMessage, TaskiqResult
|
||||
|
||||
from taskiq_deduplication import RedisDeduplicationMiddleware
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -16,6 +18,13 @@ async def fake_redis():
|
||||
await client.aclose()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def middleware(fake_redis):
|
||||
mw = RedisDeduplicationMiddleware(redis_url="redis://localhost")
|
||||
mw._redis = fake_redis
|
||||
return mw
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def real_redis():
|
||||
client = Redis.from_url("redis://localhost:6379/15")
|
||||
@@ -57,3 +66,24 @@ def make_result():
|
||||
)
|
||||
|
||||
return _make
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def make_scheduled_task():
|
||||
def _make(
|
||||
task_name="my_task",
|
||||
schedule_id="schedule-1",
|
||||
labels=None,
|
||||
kwargs=None,
|
||||
cron="* * * * *",
|
||||
):
|
||||
return ScheduledTask(
|
||||
task_name=task_name,
|
||||
schedule_id=schedule_id,
|
||||
labels=labels or {},
|
||||
args=[],
|
||||
kwargs=kwargs or {},
|
||||
cron=cron,
|
||||
)
|
||||
|
||||
return _make
|
||||
|
||||
Reference in New Issue
Block a user