Define create_storage_key fixture in conftest.py

This commit is contained in:
Rishat Fayzullin 2024-06-13 14:02:44 +03:00
parent bbba6ce840
commit 369efee342
4 changed files with 10 additions and 20 deletions

View file

@ -8,6 +8,7 @@ from redis.asyncio.connection import parse_url as parse_redis_url
from redis.exceptions import ConnectionError
from aiogram import Dispatcher
from aiogram.fsm.storage.base import StorageKey
from aiogram.fsm.storage.memory import (
DisabledEventIsolation,
MemoryStorage,
@ -19,6 +20,9 @@ from tests.mocked_bot import MockedBot
DATA_DIR = Path(__file__).parent / "data"
CHAT_ID = -42
USER_ID = 42
skip_message_pattern = "Need \"--{db}\" option with {db} URI to run"
invalid_uri_pattern = "Invalid {db} URI {uri!r}: {err}"
@ -132,6 +136,11 @@ def bot():
return MockedBot()
@pytest.fixture(name="storage_key")
def create_storage_key(bot: MockedBot):
return StorageKey(chat_id=CHAT_ID, user_id=USER_ID, bot_id=bot.id)
@pytest.fixture()
async def dispatcher():
dp = Dispatcher()

View file

@ -5,12 +5,6 @@ import pytest
from aiogram.fsm.storage.base import BaseEventIsolation, StorageKey
from aiogram.fsm.storage.redis import RedisEventIsolation, RedisStorage
from tests.mocked_bot import MockedBot
@pytest.fixture(name="storage_key")
def create_storage_key(bot: MockedBot):
return StorageKey(chat_id=-42, user_id=42, bot_id=bot.id)
@pytest.mark.parametrize(

View file

@ -2,16 +2,9 @@ import pytest
from aiogram.fsm.state import State
from aiogram.fsm.storage.mongo import MongoStorage, StorageKey
from tests.mocked_bot import MockedBot
from tests.conftest import CHAT_ID, USER_ID
PREFIX = "fsm"
CHAT_ID = -42
USER_ID = 42
@pytest.fixture(name="storage_key")
def create_storage_key(bot: MockedBot):
return StorageKey(chat_id=CHAT_ID, user_id=USER_ID, bot_id=bot.id)
async def test_update_not_existing_data_with_empty_dictionary(

View file

@ -1,12 +1,6 @@
import pytest
from aiogram.fsm.storage.base import BaseStorage, StorageKey
from tests.mocked_bot import MockedBot
@pytest.fixture(name="storage_key")
def create_storage_key(bot: MockedBot):
return StorageKey(chat_id=-42, user_id=42, bot_id=bot.id)
@pytest.mark.parametrize(