diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-29 14:22:03 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-29 14:22:03 +0200 |
| commit | dba3388567818cb5c60be9d406d3e1cccc84b3ea (patch) | |
| tree | 53a0903f7a4c381c7ad12e3e632ef8dd8ebba39f /tests/cogs/test_music_integration.py | |
| parent | multitude of changes. (diff) | |
| download | senator-sperma-dba3388567818cb5c60be9d406d3e1cccc84b3ea.tar.gz senator-sperma-dba3388567818cb5c60be9d406d3e1cccc84b3ea.zip | |
Refactor database connections and add integration tests
- Use context managers for sqlite3 connections in cron, vclogs, and database utils
- Add URL helper utility for yt-dlp with clean_url_for_ytdlp function
- Add slow integration test markers and new integration test files
- Fix test imports to use conftest directly instead of tests.conftest
- Improve downloader error handling and use COPYPARTY_URL_UPLOAD env var
- Update pytest.ini with slow test markers and warning filters
- Document slow test usage in AGENTS.md
Diffstat (limited to '')
| -rw-r--r-- | tests/cogs/test_music_integration.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/cogs/test_music_integration.py b/tests/cogs/test_music_integration.py new file mode 100644 index 0000000..1c0260a --- /dev/null +++ b/tests/cogs/test_music_integration.py | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | import pytest | ||
| 2 | from unittest.mock import MagicMock, AsyncMock, patch, PropertyMock | ||
| 3 | import sys | ||
| 4 | sys.path.insert(0, '/home/salmon/Documents/botcode/senator-sperma/tests') | ||
| 5 | from conftest import MockApplicationContext | ||
| 6 | |||
| 7 | |||
| 8 | @pytest.fixture | ||
| 9 | def music_cog(bot): | ||
| 10 | from cogs.music.play_commands import PlayCommands | ||
| 11 | cog = PlayCommands(bot) | ||
| 12 | return cog | ||
| 13 | |||
| 14 | |||
| 15 | @pytest.mark.slow | ||
| 16 | @pytest.mark.asyncio | ||
| 17 | async def test_music_join_stop(music_cog, bot): | ||
| 18 | """Test music join and stop commands.""" | ||
| 19 | from cogs.music.join import Join | ||
| 20 | from cogs.music.stop import Stop | ||
| 21 | |||
| 22 | join_cog = Join(bot) | ||
| 23 | stop_cog = Stop(bot) | ||
| 24 | |||
| 25 | ctx = MockApplicationContext(bot=bot) | ||
| 26 | ctx.author.voice = MagicMock() | ||
| 27 | ctx.author.voice.channel = MagicMock() | ||
| 28 | ctx.guild = MagicMock() | ||
| 29 | |||
| 30 | voice_client = AsyncMock() | ||
| 31 | ctx.voice_client = voice_client | ||
| 32 | |||
| 33 | # Test join | ||
| 34 | ctx.author.voice.channel.connect = AsyncMock(return_value=voice_client) | ||
| 35 | with patch.object(ctx, 'respond', new_callable=AsyncMock): | ||
| 36 | with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock): | ||
| 37 | await join_cog.join.callback(join_cog, ctx) | ||
| 38 | ctx.author.voice.channel.connect.assert_called_once() | ||
| 39 | |||
| 40 | # Test stop | ||
| 41 | with patch.object(ctx, 'respond', new_callable=AsyncMock): | ||
| 42 | with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock): | ||
| 43 | await stop_cog.stop.callback(stop_cog, ctx) | ||
| 44 | voice_client.disconnect.assert_called_once() | ||
