From dbf6b535f880fbd1fd61078bf2c8b8d6bcbd60cb Mon Sep 17 00:00:00 2001 From: kievzenit Date: Mon, 11 Aug 2025 18:33:14 +0300 Subject: [PATCH] fixed pymongo tests, update_data method should not delete document when {} was passed --- tests/test_fsm/storage/test_pymongo.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_fsm/storage/test_pymongo.py b/tests/test_fsm/storage/test_pymongo.py index 81ef1cdf..574e7357 100644 --- a/tests/test_fsm/storage/test_pymongo.py +++ b/tests/test_fsm/storage/test_pymongo.py @@ -54,8 +54,12 @@ async def test_update_existing_data_with_empty_dictionary( ): assert await pymongo_storage._collection.find_one({}) is None await pymongo_storage.set_data(key=storage_key, data={"key": "value"}) - assert await pymongo_storage.update_data(key=storage_key, data={}) == {} - assert await pymongo_storage._collection.find_one({}) is None + assert await pymongo_storage.update_data(key=storage_key, data={}) == {"key": "value"} + assert await pymongo_storage._collection.find_one({}) == { + "_id": f"{PREFIX}:{CHAT_ID}:{USER_ID}", + "data": {"key": "value"}, + } + await pymongo_storage._collection.delete_one({}) async def test_update_existing_data_with_non_empty_dictionary( @@ -170,9 +174,10 @@ class TestStateAndDataDoNotAffectEachOther: "state": "test", "data": {"key": "value"}, } - assert await pymongo_storage.update_data(key=storage_key, data={}) == {} + assert await pymongo_storage.update_data(key=storage_key, data={}) == {"key": "value"} assert await pymongo_storage._collection.find_one({}, projection={"_id": 0}) == { "state": "test", + "data": {"key": "value"}, } async def test_state_do_not_affect_to_updating_existing_data_with_non_empty_dictionary(