-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7607ce9
commit 9d7c1df
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
from aiogram.enums import ContentType | ||
|
||
from aiogram_dialog.context.media_storage import MediaIdStorage | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_media_id(): | ||
manager = MediaIdStorage() | ||
with tempfile.NamedTemporaryFile() as file: | ||
os.fsync(file) | ||
media_id = await manager.get_media_id( | ||
file.name, | ||
None, | ||
ContentType.DOCUMENT, | ||
) | ||
assert media_id is None | ||
|
||
await manager.save_media_id( | ||
file.name, | ||
None, | ||
ContentType.DOCUMENT, | ||
"test1", | ||
) | ||
|
||
media_id = await manager.get_media_id( | ||
file.name, | ||
None, | ||
ContentType.DOCUMENT, | ||
) | ||
assert media_id == "test1" | ||
|
||
file.write(b"new info") | ||
file.flush() | ||
|
||
media_id = await manager.get_media_id( | ||
file.name, | ||
None, | ||
ContentType.DOCUMENT, | ||
) | ||
assert media_id is None |