mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Implemented mongodb storage
This commit is contained in:
parent
76ae5c4415
commit
3e04d3365e
4 changed files with 121 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ from aioredis.connection import parse_url as parse_redis_url
|
|||
|
||||
from aiogram import Bot
|
||||
from aiogram.dispatcher.fsm.storage.memory import MemoryStorage
|
||||
from aiogram.dispatcher.fsm.storage.mongo import MongoStorage
|
||||
from aiogram.dispatcher.fsm.storage.redis import RedisStorage
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
|
@ -67,6 +68,19 @@ async def memory_storage():
|
|||
await storage.close()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.mark.mongo
|
||||
async def mongo_storage(redis_server):
|
||||
if not redis_server:
|
||||
pytest.skip("Mongo is not available here")
|
||||
storage = MongoStorage.from_url(redis_server)
|
||||
|
||||
try:
|
||||
yield storage
|
||||
finally:
|
||||
await storage.close()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def bot():
|
||||
bot = MockedBot()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def create_storate_key(bot: MockedBot):
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
"storage",
|
||||
[pytest.lazy_fixture("redis_storage"), pytest.lazy_fixture("memory_storage")],
|
||||
[pytest.lazy_fixture("redis_storage"), pytest.lazy_fixture("memory_storage"), pytest.lazy_fixture("mongo_storage")],
|
||||
)
|
||||
class TestStorages:
|
||||
async def test_lock(self, bot: MockedBot, storage: BaseStorage, storage_key: StorageKey):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue