From c301d0b09b7e3f287c8070961bbccda95d69f316 Mon Sep 17 00:00:00 2001 From: DarkShyMW Date: Sat, 23 Aug 2025 07:44:45 +0300 Subject: [PATCH] Changes to be committed: new file: Docker/.dockerfile new file: Docker/.env.example new file: Docker/.gitignore new file: Docker/requirements.txt# deleted: test_app.py --- Docker/.dockerfile | 18 ++++++++++++++++++ Docker/.env.example | 4 ++++ Docker/.gitignore | 5 +++++ Docker/requirements.txt | 2 ++ test_app.py | 42 ----------------------------------------- 5 files changed, 29 insertions(+), 42 deletions(-) create mode 100644 Docker/.dockerfile create mode 100644 Docker/.env.example create mode 100644 Docker/.gitignore create mode 100644 Docker/requirements.txt delete mode 100644 test_app.py diff --git a/Docker/.dockerfile b/Docker/.dockerfile new file mode 100644 index 0000000..29a9f32 --- /dev/null +++ b/Docker/.dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Установка зависимостей +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Копируем код +COPY . . + +# Переменные окружения (можно переопределить при запуске) +ENV TELEGRAM_TOKEN="" +ENV DERPIBOORU_TOKEN="" +ENV CHANNEL_ID="" +ENV FILTER_ID=56027 + +CMD ["python", "app.py"] diff --git a/Docker/.env.example b/Docker/.env.example new file mode 100644 index 0000000..64d3b65 --- /dev/null +++ b/Docker/.env.example @@ -0,0 +1,4 @@ +TELEGRAM_TOKEN=your-telegram-token-here +DERPIBOORU_TOKEN=your-derpibooru-token-here +CHANNEL_ID=-1002010407572 +FILTER_ID=56027 diff --git a/Docker/.gitignore b/Docker/.gitignore new file mode 100644 index 0000000..6752682 --- /dev/null +++ b/Docker/.gitignore @@ -0,0 +1,5 @@ +venv/ +__pycache__/ +*.pyc +sent_images.json +bot.log diff --git a/Docker/requirements.txt b/Docker/requirements.txt new file mode 100644 index 0000000..3b18281 --- /dev/null +++ b/Docker/requirements.txt @@ -0,0 +1,2 @@ +python-telegram-bot==20.5 +aiohttp==3.9.5 diff --git a/test_app.py b/test_app.py deleted file mode 100644 index 683d39a..0000000 --- a/test_app.py +++ /dev/null @@ -1,42 +0,0 @@ -import pytest -import asyncio -from aioresponses import aioresponses -from app import fetch_image, DERPYBOORU_API_SEARCH, DERPIBOORU_TOKEN - -@pytest.mark.asyncio -async def test_fetch_image_found(): - # Мокаем API-ответ с одним изображением - tags = ["safe", "pony"] - with aioresponses() as m: - m.get( - f"{DERPYBOORU_API_SEARCH}", - payload={ - "images": [ - { - "representations": {"full": "https://test.img/full.png"}, - "uploader": "tester", - "view_url": "https://derpibooru.org/images/1", - "tags": ["pony", "cute"] - } - ] - } - ) - async with asyncio.get_event_loop().run_until_complete: - result = await fetch_image(tags) - assert result is not None - url, author, source, img_tags = result - assert url == "https://test.img/full.png" - assert author == "tester" - assert source == "https://derpibooru.org/images/1" - assert "pony" in img_tags - -@pytest.mark.asyncio -async def test_fetch_image_not_found(): - tags = ["nonexistenttag123"] - with aioresponses() as m: - m.get( - f"{DERPYBOORU_API_SEARCH}", - payload={"images": []} - ) - result = await fetch_image(tags) - assert result is None