From 0d5d8dbe7b24bc02c76e98c1c740b57547f510f4 Mon Sep 17 00:00:00 2001 From: deadzilla Date: Tue, 14 Jul 2026 22:23:38 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B8=D0=B9=20=5F=5Finit=5F=5F=20=D0=B2=20Pg?= =?UTF-8?q?;=20API=5FURL=5FWEATHER=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D1=83=D0=B5=D1=82=D1=81=D1=8F=20=D0=BD=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D1=8F=D0=BC=D1=83=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/pg.py | 5 +---- tests/test_commands_pg.py | 10 +++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/commands/pg.py b/commands/pg.py index 8137dd2..a25752a 100644 --- a/commands/pg.py +++ b/commands/pg.py @@ -8,13 +8,10 @@ logger = logging.getLogger(__name__) class Pg(commands.Cog): """Команда !pg — прогноз погоды для Магнитогорска""" - def __init__(self): - self.api_url = API_URL_WEATHER - @commands.command(name="pg") async def pg(self, ctx: commands.Context) -> None: """Прогноз погоды в Магнитогорске""" - data = await fetch_weather(self.api_url) + data = await fetch_weather(API_URL_WEATHER) if data is None: logger.warning( "%s: !pg — не удалось получить погоду (API вернул None)", ctx.author diff --git a/tests/test_commands_pg.py b/tests/test_commands_pg.py index 5423998..add64f6 100644 --- a/tests/test_commands_pg.py +++ b/tests/test_commands_pg.py @@ -7,10 +7,14 @@ from commands.pg import Pg class TestPgInit: """Тесты инициализации Cog Pg.""" - def test_init_sets_api_url(self) -> None: - """__init__ должен устанавливать api_url.""" + def test_uses_api_url_constant(self) -> None: + """Pg использует API_URL_WEATHER напрямую (без инстанс-переменной).""" + from utils.pogoda import API_URL_WEATHER + cog = Pg() - assert cog.api_url == "https://wttr.in/Magnitogorsk?format=j1&lang=ru" + # Pg не хранит api_url как инстанс-переменную — использует константу напрямую + assert not hasattr(cog, "api_url") + assert API_URL_WEATHER == "https://wttr.in/Magnitogorsk?format=j1&lang=ru" class TestPgCommand: