diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-19 17:50:54 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-19 17:50:54 +0200 |
| commit | 6f1225445a9bb988274424e8d7420af5afc392fe (patch) | |
| tree | b279fdb7ec2b8ba0f4f6fea986df4514240a6d62 /tests | |
| parent | feat: add external URL playback support, fix vclogs audio handling (diff) | |
| download | senator-sperma-6f1225445a9bb988274424e8d7420af5afc392fe.tar.gz senator-sperma-6f1225445a9bb988274424e8d7420af5afc392fe.zip | |
fix: mock aiohttp instead of requests in external play test
Diffstat (limited to '')
| -rw-r--r-- | tests/cogs/test_music_external_play.py | 13 |
1 files changed, 8 insertions, 5 deletions
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, | |||
| 96 | 96 | ||
| 97 | @pytest.mark.asyncio | 97 | @pytest.mark.asyncio |
| 98 | async def test_upload_to_copyparty_async(play_commands_cog, temp_mp3_file, monkeypatch): | 98 | async def test_upload_to_copyparty_async(play_commands_cog, temp_mp3_file, monkeypatch): |
| 99 | mock_response = MagicMock() | ||
| 100 | mock_response.status_code = 200 | ||
| 101 | mock_response.json.return_value = {"fileurl": "https://example.com/file.mp3"} | ||
| 102 | |||
| 103 | monkeypatch.setenv("COPYPARTY_URL_UPLOAD", "https://catbox.2137697.xyz/sperma/") | 99 | monkeypatch.setenv("COPYPARTY_URL_UPLOAD", "https://catbox.2137697.xyz/sperma/") |
| 104 | monkeypatch.setenv("COPYPARTY_PASSWORD", "testpassword") | 100 | monkeypatch.setenv("COPYPARTY_PASSWORD", "testpassword") |
| 105 | 101 | ||
| 106 | with patch('cogs.music.play_commands.requests.post', return_value=mock_response) as mock_post: | 102 | mock_post = AsyncMock() |
| 103 | mock_response = AsyncMock() | ||
| 104 | mock_response.status = 200 | ||
| 105 | mock_response.json = AsyncMock(return_value={"fileurl": "https://example.com/file.mp3"}) | ||
| 106 | mock_post.return_value.__aenter__ = AsyncMock(return_value=mock_response) | ||
| 107 | mock_post.return_value.__aexit__ = AsyncMock() | ||
| 108 | |||
| 109 | with patch('aiohttp.ClientSession.post', mock_post): | ||
| 107 | await play_commands_cog._upload_to_copyparty_async(temp_mp3_file) | 110 | await play_commands_cog._upload_to_copyparty_async(temp_mp3_file) |
| 108 | mock_post.assert_called_once() | 111 | mock_post.assert_called_once() |
