discordBot/tests/test_help_console.py
deadzilla 2188a7d3fd feat: упростить вывод команды !hp, добавить тесты
- Убран discord.Embed в пользу простого текста без timestamp ошибки
- Добавлены разделители = вокруг заголовка
- Создан tests/test_help_discord.py с 2 тестами для Discord команды
- Создан tests/test_help_console.py с 2 тестами для консольной команды
- Закрыто: AttributeError 'Message' object has no attribute 'timestamp'
2026-06-02 23:14:37 +05:00

55 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Тесты для консольной команды help."""
import io
from contextlib import redirect_stdout
from unittest.mock import MagicMock
class TestHelpCommandConsole:
"""Тесты для консольной команды help."""
def test_stop_event_check(self):
"""Проверка работы с остановленным ботом."""
from console_commands.help import help
stop_event = MagicMock()
stop_event.is_set.return_value = True
f = io.StringIO()
with redirect_stdout(f):
result = help(stop_event, MagicMock())
assert result is None
def test_output_contains_all_commands(self):
"""Проверка наличия всех команд в выводе."""
from console_commands.help import help
stop_event = MagicMock()
stop_event.is_set.return_value = False
f = io.StringIO()
with redirect_stdout(f):
help(stop_event, MagicMock())
output = f.getvalue()
# Discord команды
assert "!pg" in output
assert "!nw" in output
assert "!morning" in output
assert "!cat" in output
assert "!msg" in output
# Консольные команды
assert "help" in output
assert "pogoda" in output
assert "news" in output
assert "morning" in output
assert "cat" in output
assert "stop" in output
if __name__ == "__main__":
pytest.main([__file__, "-v"])