aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cogs/test_downloader_integration.py
blob: c7c979005971b5053fea5fd09558fd9b65667ea2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()