From 6f1225445a9bb988274424e8d7420af5afc392fe Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 19 Apr 2026 17:50:54 +0200 Subject: fix: mock aiohttp instead of requests in external play test --- tests/cogs/test_music_external_play.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/cogs/test_music_external_play.py b/tests/cogs/test_music_external_play.py index 76debc9..25c14e0 100644 --- a/tests/cogs/test_music_external_play.py +++ b/tests/cogs/test_music_external_play.py @@ -96,13 +96,16 @@ async def test_play_command_calls_local_handler(play_commands_cog, mock_channel, @pytest.mark.asyncio async def test_upload_to_copyparty_async(play_commands_cog, temp_mp3_file, monkeypatch): - mock_response = MagicMock() - mock_response.status_code = 200 - mock_response.json.return_value = {"fileurl": "https://example.com/file.mp3"} - monkeypatch.setenv("COPYPARTY_URL_UPLOAD", "https://catbox.2137697.xyz/sperma/") monkeypatch.setenv("COPYPARTY_PASSWORD", "testpassword") - with patch('cogs.music.play_commands.requests.post', return_value=mock_response) as mock_post: + mock_post = AsyncMock() + mock_response = AsyncMock() + mock_response.status = 200 + mock_response.json = AsyncMock(return_value={"fileurl": "https://example.com/file.mp3"}) + mock_post.return_value.__aenter__ = AsyncMock(return_value=mock_response) + mock_post.return_value.__aexit__ = AsyncMock() + + with patch('aiohttp.ClientSession.post', mock_post): await play_commands_cog._upload_to_copyparty_async(temp_mp3_file) mock_post.assert_called_once() -- cgit v1.2.3