refactor: track background tasks in application lifecycle and clean up codebase
This commit is contained in:
19 files changed
+71
-55
No files matched your search
@@ -76,6 +76,7 @@ class ApiSurfaceTest(unittest.TestCase):
|
||||
def test_restart_endpoint_calls_restart_state(self):
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from zyrarbot.ui.api.routers.status_router import restart_bot
|
||||
|
||||
mock_request = MagicMock()
|
||||
@@ -88,6 +89,7 @@ class ApiSurfaceTest(unittest.TestCase):
|
||||
|
||||
def test_voice_channels_payload_filters_unconnectable_channels(self):
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from zyrarbot.ui.api.status_service import StatusService
|
||||
|
||||
mock_guild = MagicMock()
|
||||
|
||||
@@ -60,11 +60,10 @@ class TestAudioEffects(unittest.TestCase):
|
||||
fx = ToasterEffect(bit_depth=5, downsample=6)
|
||||
pcm = struct.pack("<hh", 12345, -23456)
|
||||
out = fx.process(pcm)
|
||||
l, r = struct.unpack("<hh", out)
|
||||
left, right = struct.unpack("<hh", out)
|
||||
# Low 11 bits are zeroed due to 5-bit quantization
|
||||
self.assertEqual(l & 0x07FF, 0)
|
||||
self.assertEqual(r & 0x07FF, 0)
|
||||
|
||||
self.assertEqual(left & 0x07FF, 0)
|
||||
self.assertEqual(right & 0x07FF, 0)
|
||||
|
||||
def test_pipeline_chains_multiple_effects_and_applies_volume(self):
|
||||
pipeline = AudioEffectsPipeline(create_default_effects())
|
||||
|
||||
@@ -40,8 +40,9 @@ class ShutdownVoiceCleanupTests(unittest.IsolatedAsyncioTestCase):
|
||||
mock_guild.me.voice.channel = MagicMock()
|
||||
mock_guild.change_voice_state = AsyncMock()
|
||||
|
||||
with patch.object(type(self.bot), "voice_clients", [mock_vc]), patch.object(
|
||||
type(self.bot), "guilds", [mock_guild]
|
||||
with (
|
||||
patch.object(type(self.bot), "voice_clients", [mock_vc]),
|
||||
patch.object(type(self.bot), "guilds", [mock_guild]),
|
||||
):
|
||||
await self.bot.disconnect_all_voice()
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
import struct
|
||||
import unittest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import discord
|
||||
|
||||
@@ -62,6 +61,5 @@ class TestYTDLSource(unittest.TestCase):
|
||||
self.assertEqual(right, -32768)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user