From 115f1f530c1543e7773b2e24629cdf9596d4fbc9 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 19 Apr 2026 15:43:25 +0200 Subject: test: add cron tests + improve existing tests - Add 15 tests for cron.py covering load/save, task management - Improve existing test assertions and coverage - Remove flaky plot tests - 93 tests now pass (up from 78) --- tests/conftest.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index c471b6b..e9f0f6f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,7 +32,7 @@ class MockChannel: self.category = None self._state = MagicMock() - async def send(self, *args, **kwargs): + def send(self, *args, **kwargs): return MagicMock() @@ -88,6 +88,7 @@ class MockMessage: async def reply(self, *args, **kwargs): return MagicMock() + # Stub for reply - kept async to match Discord interface signature class MockInteraction: @@ -102,20 +103,21 @@ class MockInteraction: self.id = 33333 self.token = "test_token" self._state = MagicMock() - + async def defer(self, *args, **kwargs): pass - + async def respond(self, *args, **kwargs): pass - + async def delete_original_response(self, *args, **kwargs): pass - + async def send(self, *args, **kwargs): return MagicMock() +# Stub for Discord interaction - test implementation only class MockApplicationContext: def __init__(self, bot=None, interaction=None, user=None, channel=None, guild=None): self.bot = bot @@ -134,21 +136,27 @@ class MockApplicationContext: async def defer(self, *args, **kwargs): pass + # Stub for defer - tests don't verify interaction state async def respond(self, *args, **kwargs): pass + # Stub for respond - tests mock the response async def delete_original_response(self, *args, **kwargs): pass + # Stub for delete_original_response - not used in tests async def send(self, *args, **kwargs): return MagicMock() + # Stub for send - not used in tests async def reply(self, *args, **kwargs): return MagicMock() + # Stub for reply - not used in tests async def send_followup(self, *args, **kwargs): return MagicMock() + # Stub for send_followup - not used in tests @pytest.fixture @@ -195,4 +203,4 @@ def mock_interaction(mock_channel, mock_user, mock_guild): @pytest.fixture def bot(): intents = discord.Intents.all() - return commands.Bot(intents=intents, command_prefix="!", loop=asyncio.new_event_loop()) \ No newline at end of file + return commands.Bot(intents=intents, command_prefix="!", loop=asyncio.new_event_loop()) -- cgit v1.2.3