From 7f6c8095e3d325b47f5539c5dcbc83a746e74b8d Mon Sep 17 00:00:00 2001 From: Leo <277007013+LeoR156@users.noreply.github.com> Date: Thu, 9 Jul 2026 09:44:57 +0500 Subject: [PATCH] Add test CI --- .github/workflows/bot.yml | 6 +++++- requirements.txt | 1 + test_bot.py | 14 ++++++++++++++ weather_utils.py | 10 ++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test_bot.py create mode 100644 weather_utils.py diff --git a/.github/workflows/bot.yml b/.github/workflows/bot.yml index 234389a..ce9c96c 100644 --- a/.github/workflows/bot.yml +++ b/.github/workflows/bot.yml @@ -25,9 +25,13 @@ jobs: - name: Проверяем код линтером (flake8) run: | - # Остановит пайплайн, если есть грубые синтаксические ошибки flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # ДОБАВЛЯЕМ СЮДА: + - name: Запуск тестов + run: | + pytest + # Джоба 2: Деплой (Запустится только если Джоба 1 прошла успешно) deploy: needs: test_and_lint diff --git a/requirements.txt b/requirements.txt index d38f26d..4a0de4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ requests==2.31.0 psycopg2-binary==2.9.9 Flask==3.0.3 gunicorn==22.0.0 +pytest diff --git a/test_bot.py b/test_bot.py new file mode 100644 index 0000000..2f6beb3 --- /dev/null +++ b/test_bot.py @@ -0,0 +1,14 @@ +# test_bot.py +from weather_utils import get_weather_comment + +def test_weather_comment_hot(): + # Проверяем, что при +30 будет "Жара! ☀️" + assert get_weather_comment(30) == "Жара!" + +def test_weather_comment_cold(): + # Проверяем, что при -10 будет "Дубак! ❄️" + assert get_weather_comment(-10) == "Дубак" + +def test_weather_comment_normal(): + # Проверяем промежуточное значение + assert get_weather_comment(15) == "Норма" diff --git a/weather_utils.py b/weather_utils.py new file mode 100644 index 0000000..f95b13a --- /dev/null +++ b/weather_utils.py @@ -0,0 +1,10 @@ +def get_weather_comment(temperature): + + if temperature >= 25: + return "Жара!" + + elif temperature <= 0: + return "Дубак" + + else: + return "Норма"