From cd8ed8bc5793985df2c1692072a932ceee517b95 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 8 Jul 2026 02:13:35 +0200 Subject: OPEN THE RUST GATES Signed-off-by: salmonik --- tests/cogs/test_search.py | 83 ----------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 tests/cogs/test_search.py (limited to 'tests/cogs/test_search.py') diff --git a/tests/cogs/test_search.py b/tests/cogs/test_search.py deleted file mode 100644 index c9c7d0e..0000000 --- a/tests/cogs/test_search.py +++ /dev/null @@ -1,83 +0,0 @@ -import pytest -from unittest.mock import AsyncMock, patch, MagicMock -import discord -from conftest import MockApplicationContext - - -@pytest.fixture -def search_cog(bot): - from cogs.search import Search - cog = Search(bot) - return cog - - -@pytest.mark.asyncio -async def test_search_command_success(search_cog, mock_channel, mock_guild, bot, mock_user): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - ctx.user = mock_user - ctx.author = mock_user - - search_cog._cached_results[mock_user.id] = { - "testfile.mp4": "https://example.com/files/testfile.mp4" - } - - with patch.object(ctx, 'send_followup', new_callable=AsyncMock) as mock_followup: - await search_cog.search.callback(search_cog, ctx, filename="testfile.mp4") - mock_followup.assert_called_once_with("https://example.com/files/testfile.mp4") - assert mock_user.id not in search_cog._cached_results - - -@pytest.mark.asyncio -async def test_search_command_no_cache(search_cog, mock_channel, mock_guild, bot, mock_user): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - ctx.user = mock_user - ctx.author = mock_user - - with patch.object(ctx, 'send_followup', new_callable=AsyncMock) as mock_followup: - await search_cog.search.callback(search_cog, ctx, filename="testfile.mp4") - mock_followup.assert_called_once_with("Search results expired. Please search again.") - - -@pytest.mark.asyncio -async def test_search_command_file_not_found(search_cog, mock_channel, mock_guild, bot, mock_user): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - ctx.user = mock_user - ctx.author = mock_user - - search_cog._cached_results[mock_user.id] = { - "testfile.mp4": "https://example.com/files/testfile.mp4" - } - - with patch.object(ctx, 'send_followup', new_callable=AsyncMock) as mock_followup: - await search_cog.search.callback(search_cog, ctx, filename="nonexistent.mp4") - mock_followup.assert_called_once_with("File 'nonexistent.mp4' not found.") - - -@pytest.mark.asyncio -async def test_search_command_empty_filename(search_cog, mock_channel, mock_guild, bot, mock_user): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - ctx.user = mock_user - ctx.author = mock_user - - with patch.object(ctx, 'reply', new_callable=AsyncMock) as mock_reply: - await search_cog.search.callback(search_cog, ctx, filename="") - mock_reply.assert_called_once_with("Please select a file from the autocomplete options.") - - -@pytest.mark.asyncio -async def test_file_autocomplete(search_cog, mock_channel, mock_guild, bot, mock_user): - mock_autocomplete_ctx = MagicMock() - mock_autocomplete_ctx.value = "test" - mock_autocomplete_ctx.interaction = MagicMock() - mock_autocomplete_ctx.interaction.user = mock_user - - with patch('cogs.utils.file_search.UniversalSearcher.search_copyparty_autocomplete', new_callable=AsyncMock) as mock_search: - mock_search.return_value = [ - "https://example.com/files/test1.mp4", - "https://example.com/files/test2.mp4" - ] - - choices = await search_cog.file_autocomplete(mock_autocomplete_ctx) - - assert len(choices) == 2 - assert mock_user.id in search_cog._cached_results -- cgit v1.2.3