aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cogs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cogs')
-rw-r--r--tests/cogs/test_music_external_play.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/cogs/test_music_external_play.py b/tests/cogs/test_music_external_play.py
index 25c14e0..fd4b625 100644
--- a/tests/cogs/test_music_external_play.py
+++ b/tests/cogs/test_music_external_play.py
@@ -99,13 +99,18 @@ 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_post = AsyncMock()
103 mock_response = AsyncMock() 102 mock_response = AsyncMock()
104 mock_response.status = 200 103 mock_response.status = 200
104 mock_response.text = AsyncMock(return_value="")
105 mock_response.json = AsyncMock(return_value={"fileurl": "https://example.com/file.mp3"}) 105 mock_response.json = AsyncMock(return_value={"fileurl": "https://example.com/file.mp3"})
106 mock_post.return_value.__aenter__ = AsyncMock(return_value=mock_response) 106 mock_response.__aenter__ = AsyncMock(return_value=mock_response)
107 mock_post.return_value.__aexit__ = AsyncMock() 107 mock_response.__aexit__ = AsyncMock()
108 108
109 with patch('aiohttp.ClientSession.post', mock_post): 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):
110 await play_commands_cog._upload_to_copyparty_async(temp_mp3_file) 115 await play_commands_cog._upload_to_copyparty_async(temp_mp3_file)
111 mock_post.assert_called_once() 116 mock_session_context.post.assert_called_once()