mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
added more tests to pymongo test, to check for all possible cases of using update_data method
This commit is contained in:
parent
1305318e1a
commit
44273e17ea
1 changed files with 41 additions and 0 deletions
|
|
@ -33,6 +33,47 @@ async def test_update_not_existing_data_with_empty_dictionary(
|
||||||
assert await pymongo_storage._collection.find_one({}) is None
|
assert await pymongo_storage._collection.find_one({}) is None
|
||||||
|
|
||||||
|
|
||||||
|
async def test_update_not_existing_data_with_non_empty_dictionary(
|
||||||
|
pymongo_storage: PyMongoStorage,
|
||||||
|
storage_key: StorageKey,
|
||||||
|
):
|
||||||
|
assert await pymongo_storage._collection.find_one({}) is None
|
||||||
|
assert await pymongo_storage.update_data(key=storage_key, data={"key": "value"}) == {
|
||||||
|
"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_empty_dictionary(
|
||||||
|
pymongo_storage: PyMongoStorage,
|
||||||
|
storage_key: StorageKey,
|
||||||
|
):
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
async def test_update_existing_data_with_non_empty_dictionary(
|
||||||
|
pymongo_storage: PyMongoStorage,
|
||||||
|
storage_key: StorageKey,
|
||||||
|
):
|
||||||
|
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={"key": "new_value"}) == {
|
||||||
|
"key": "new_value"
|
||||||
|
}
|
||||||
|
assert await pymongo_storage._collection.find_one({}) == {
|
||||||
|
"_id": f"{PREFIX}:{CHAT_ID}:{USER_ID}",
|
||||||
|
"data": {"key": "new_value"},
|
||||||
|
}
|
||||||
|
await pymongo_storage._collection.delete_one({})
|
||||||
|
|
||||||
|
|
||||||
async def test_document_life_cycle(
|
async def test_document_life_cycle(
|
||||||
pymongo_storage: PyMongoStorage,
|
pymongo_storage: PyMongoStorage,
|
||||||
storage_key: StorageKey,
|
storage_key: StorageKey,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue