diff --git a/tests/conftest.py b/tests/conftest.py index 4d1f38b4..9054ea00 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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() diff --git a/tests/test_fsm/storage/test_isolation.py b/tests/test_fsm/storage/test_isolation.py index c95a1cba..867362c1 100644 --- a/tests/test_fsm/storage/test_isolation.py +++ b/tests/test_fsm/storage/test_isolation.py @@ -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( diff --git a/tests/test_fsm/storage/test_mongo.py b/tests/test_fsm/storage/test_mongo.py index 48b95719..89b4105a 100644 --- a/tests/test_fsm/storage/test_mongo.py +++ b/tests/test_fsm/storage/test_mongo.py @@ -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( diff --git a/tests/test_fsm/storage/test_storages.py b/tests/test_fsm/storage/test_storages.py index b86a0588..690bc791 100644 --- a/tests/test_fsm/storage/test_storages.py +++ b/tests/test_fsm/storage/test_storages.py @@ -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(