mirror of
https://github.com/d3vyce/taskiq-deduplication.git
synced 2026-08-04 19:14:07 +00:00
6d8f17eb2b
* ⬆ bump pytest from 9.0.3 to 9.1.1 Bumps [pytest](https://github.com/pytest-dev/pytest) from 9.0.3 to 9.1.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/9.0.3...9.1.1) --- updated-dependencies: - dependency-name: pytest dependency-version: 9.1.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: fake_redis pytest fixture --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: d3vyce <nicolas.sudres@proton.me>
60 lines
1.2 KiB
Python
60 lines
1.2 KiB
Python
import fakeredis.aioredis
|
|
import pytest
|
|
from redis.asyncio import Redis
|
|
from taskiq import TaskiqMessage, TaskiqResult
|
|
|
|
|
|
@pytest.fixture
|
|
def anyio_backend():
|
|
return "asyncio"
|
|
|
|
|
|
@pytest.fixture
|
|
def fake_redis():
|
|
return fakeredis.aioredis.FakeRedis()
|
|
|
|
|
|
@pytest.fixture
|
|
async def real_redis():
|
|
client = Redis.from_url("redis://localhost:6379/15")
|
|
try:
|
|
await client.ping()
|
|
except Exception:
|
|
await client.aclose()
|
|
pytest.skip("Redis not available at localhost:6379")
|
|
return
|
|
await client.flushdb()
|
|
yield client
|
|
await client.flushdb()
|
|
await client.aclose()
|
|
|
|
|
|
@pytest.fixture
|
|
def make_message():
|
|
def _make(
|
|
task_name="my_task", task_id="task-1", labels=None, kwargs=None, args=None
|
|
):
|
|
return TaskiqMessage(
|
|
task_id=task_id,
|
|
task_name=task_name,
|
|
labels=labels or {},
|
|
labels_types={},
|
|
args=args or [],
|
|
kwargs=kwargs or {},
|
|
)
|
|
|
|
return _make
|
|
|
|
|
|
@pytest.fixture
|
|
def make_result():
|
|
def _make(is_err=False):
|
|
return TaskiqResult(
|
|
is_err=is_err,
|
|
log="",
|
|
return_value=None,
|
|
execution_time=0.0,
|
|
)
|
|
|
|
return _make
|