diff options
Diffstat (limited to 'tests/cogs/test_music_external_play.py')
| -rw-r--r-- | tests/cogs/test_music_external_play.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/tests/cogs/test_music_external_play.py b/tests/cogs/test_music_external_play.py index 2e9c5b1..8e19423 100644 --- a/tests/cogs/test_music_external_play.py +++ b/tests/cogs/test_music_external_play.py | |||
| @@ -99,18 +99,11 @@ async def test_upload_to_copyparty_async(play_commands_cog, temp_mp3_file, monke | |||
| 99 | monkeypatch.setenv("COPYPARTY_URL_UPLOAD", "https://catbox.2137697.xyz/sperma/") | 99 | monkeypatch.setenv("COPYPARTY_URL_UPLOAD", "https://catbox.2137697.xyz/sperma/") |
| 100 | monkeypatch.setenv("COPYPARTY_PASSWORD", "testpassword") | 100 | monkeypatch.setenv("COPYPARTY_PASSWORD", "testpassword") |
| 101 | 101 | ||
| 102 | mock_response = AsyncMock() | 102 | mock_response = MagicMock() |
| 103 | mock_response.status = 200 | 103 | mock_response.status_code = 200 |
| 104 | mock_response.text = AsyncMock(return_value="") | 104 | mock_response.text = '{"fileurl": "https://example.com/file.mp3"}' |
| 105 | mock_response.json = AsyncMock(return_value={"fileurl": "https://example.com/file.mp3"}) | 105 | mock_response.json = MagicMock(return_value={"fileurl": "https://example.com/file.mp3"}) |
| 106 | mock_response.__aenter__ = AsyncMock(return_value=mock_response) | 106 | |
| 107 | mock_response.__aexit__ = AsyncMock() | 107 | with patch('cogs.music.play_commands.requests.post', return_value=mock_response) as mock_post: |
| 108 | |||
| 109 | mock_session_context = AsyncMock() | ||
| 110 | mock_session_context.__aenter__ = AsyncMock(return_value=mock_session_context) | ||
| 111 | mock_session_context.__aexit__ = AsyncMock() | ||
| 112 | mock_session_context.post = MagicMock(return_value=mock_response) | ||
| 113 | |||
| 114 | with patch('aiohttp.ClientSession', return_value=mock_session_context): | ||
| 115 | await play_commands_cog._upload_to_copyparty_async(temp_mp3_file) | 108 | await play_commands_cog._upload_to_copyparty_async(temp_mp3_file) |
| 116 | mock_session_context.post.assert_called_once() | 109 | mock_post.assert_called_once() |
