diff --git a/aiogram/dispatcher/storage/exceptions.py b/aiogram/dispatcher/storage/exceptions.py deleted file mode 100644 index 6f9ffc59..00000000 --- a/aiogram/dispatcher/storage/exceptions.py +++ /dev/null @@ -1,3 +0,0 @@ -# todo -class FSMStorageBaseError(Exception): - pass diff --git a/tests/test_dispatcher/test_storage/__init__.py b/tests/test_dispatcher/test_storage/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_dispatcher/test_storage/test_dummy.py b/tests/test_dispatcher/test_storage/test_dummy.py new file mode 100644 index 00000000..f8baadd2 --- /dev/null +++ b/tests/test_dispatcher/test_storage/test_dummy.py @@ -0,0 +1,50 @@ +import pytest + +from aiogram.dispatcher.storage.dummy import DummyStorage + +KFULL_DUMMY_METHODS = { + "finish", + "get_data", + "get_state", + "reset_data", + "reset_state", + "set_data", + "set_state", + "update_data", + # close and wait_closed do not require key +} + + +WARNING_MESSAGE = ( + "You haven’t set any storage yet so no states and no data will be saved. \n" + "You can connect MemoryStorage for debug purposes or non-essential data." +) + + +@pytest.fixture() +def dummy_store(): + return DummyStorage() + + +@pytest.mark.asyncio +@pytest.mark.parametrize("dummy_method", KFULL_DUMMY_METHODS) +async def test_dummy_storage_warnings(dummy_method: str, dummy_store: DummyStorage): + with pytest.warns( + Warning, match=WARNING_MESSAGE, + ): + if dummy_method.startswith("get_") or dummy_method in {"finish", "reset_data"}: + assert await getattr(dummy_store, dummy_method)("42:20") is None + else: + assert await getattr(dummy_store, dummy_method)("42:20", None) is None + + +@pytest.mark.asyncio +async def test_dummy_storage_warnings_for_close(dummy_store: DummyStorage): + with pytest.warns(Warning, match=WARNING_MESSAGE): + await dummy_store.close() + + +@pytest.mark.asyncio +async def test_dummy_storage_warnings_for_wait_closed(dummy_store: DummyStorage): + with pytest.warns(Warning, match=WARNING_MESSAGE): + await dummy_store.wait_closed()