Files
derpibooru-telegram-bot/tests/test_post.py
2025-08-23 10:11:53 +03:00

23 lines
673 B
Python

# tests/test_post.py
import pytest
from unittest.mock import AsyncMock, patch
import app
@pytest.mark.asyncio
async def test_post_image_success():
# Мокаем fetch_image
with patch("app.fetch_image", new_callable=AsyncMock) as mock_fetch:
mock_fetch.return_value = (
"http://example.com/img.jpg",
"tester",
"http://derpibooru.org/img/1",
["gay", "pony"]
)
# Заменяем весь объект bot на мок
mock_bot = AsyncMock()
with patch.object(app, "bot", new=mock_bot):
await app.post_image()
mock_bot.send_photo.assert_awaited_once()