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: