import pytest from unittest.mock import AsyncMock, patch from app import post_image @pytest.mark.asyncio @patch("app.bot.send_photo", new_callable=AsyncMock) @patch("app.fetch_image", return_value=( "https://example.com/full.png", "tester", "https://derpibooru.org/images/123", ["gay", "cute"] )) async def test_post_image_success(mock_fetch, mock_send_photo, tmp_path, monkeypatch): """Тестируем успешную публикацию картинки""" # временный файл для sent_images monkeypatch.setattr("app.SENT_IMAGES_FILE", tmp_path / "sent.json") monkeypatch.setattr("app.sent_images", set()) await post_image(tags=["gay"]) mock_fetch.assert_called_once() mock_send_photo.assert_awaited_once()