import pytest from unittest.mock import MagicMock, AsyncMock, patch, PropertyMock import sys sys.path.insert(0, '/home/salmon/Documents/botcode/senator-sperma/tests') from conftest import MockApplicationContext @pytest.fixture def music_cog(bot): from cogs.music.play_commands import PlayCommands cog = PlayCommands(bot) return cog @pytest.mark.slow @pytest.mark.asyncio async def test_music_join_stop(music_cog, bot): """Test music join and stop commands.""" from cogs.music.join import Join from cogs.music.stop import Stop join_cog = Join(bot) stop_cog = Stop(bot) ctx = MockApplicationContext(bot=bot) ctx.author.voice = MagicMock() ctx.author.voice.channel = MagicMock() ctx.guild = MagicMock() voice_client = AsyncMock() ctx.voice_client = voice_client # Test join ctx.author.voice.channel.connect = AsyncMock(return_value=voice_client) with patch.object(ctx, 'respond', new_callable=AsyncMock): with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock): await join_cog.join.callback(join_cog, ctx) ctx.author.voice.channel.connect.assert_called_once() # Test stop with patch.object(ctx, 'respond', new_callable=AsyncMock): with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock): await stop_cog.stop.callback(stop_cog, ctx) voice_client.disconnect.assert_called_once()