From dba3388567818cb5c60be9d406d3e1cccc84b3ea Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 29 Apr 2026 14:22:03 +0200 Subject: Refactor database connections and add integration tests - Use context managers for sqlite3 connections in cron, vclogs, and database utils - Add URL helper utility for yt-dlp with clean_url_for_ytdlp function - Add slow integration test markers and new integration test files - Fix test imports to use conftest directly instead of tests.conftest - Improve downloader error handling and use COPYPARTY_URL_UPLOAD env var - Update pytest.ini with slow test markers and warning filters - Document slow test usage in AGENTS.md --- tests/cogs/test_downloader_integration.py | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/cogs/test_downloader_integration.py (limited to 'tests/cogs/test_downloader_integration.py') diff --git a/tests/cogs/test_downloader_integration.py b/tests/cogs/test_downloader_integration.py new file mode 100644 index 0000000..c7c9790 --- /dev/null +++ b/tests/cogs/test_downloader_integration.py @@ -0,0 +1,37 @@ +import pytest +from unittest.mock import MagicMock, AsyncMock, patch + + +@pytest.fixture +def downloader_cog(bot): + from cogs.downloader import Downloader + cog = Downloader(bot) + return cog + + +@pytest.mark.slow +@pytest.mark.asyncio +async def test_download_command_flow(downloader_cog, bot): + """Test download command with URL processing.""" + cog = downloader_cog + + ctx = MagicMock() + ctx.author = MagicMock() + ctx.guild = MagicMock() + ctx.channel = MagicMock() + ctx.respond = AsyncMock() + ctx.defer = AsyncMock() + ctx.followup = AsyncMock() + ctx.voice_client = None + + # Mock the download_standalone static method + mock_response = { + "status": "success", + "type": "url", + "content": "http://example.com/video.mp4" + } + + with patch.object(cog, 'download_standalone', new_callable=AsyncMock, return_value=mock_response): + await cog.download.callback(cog, ctx, url="http://youtube.com/test") + + ctx.respond.assert_called_once() -- cgit v1.2.3