/
/
/
1"""Fixtures for Tidal provider tests."""
2
3from collections.abc import Generator
4from unittest.mock import AsyncMock, Mock, patch
5
6import pytest
7
8from music_assistant.providers.tidal.media import TidalMediaManager
9
10
11@pytest.fixture
12def media_manager(provider_mock: Mock) -> TidalMediaManager:
13 """Return a TidalMediaManager instance."""
14 # provider_mock is defined per test module and differs between them, so a module
15 # requesting this fixture must bring its own
16 return TidalMediaManager(provider_mock)
17
18
19@pytest.fixture(autouse=True)
20def no_throttling() -> Generator[None]:
21 """
22 Disable rate limiting and retry backoff during tests.
23
24 The API client's throttler is class-level shared state: its real-time
25 rate window would otherwise carry over between tests and make every
26 test wait it out.
27
28 Note: the sleep patch targets the attribute on the shared asyncio
29 module, so asyncio.sleep is mocked process-wide while each test in
30 this directory runs. Keep that in mind for timing-dependent tests.
31 """
32 with (
33 patch(
34 "music_assistant.helpers.throttle_retry.Throttler.acquire",
35 new=AsyncMock(return_value=0.0),
36 ),
37 patch(
38 "music_assistant.helpers.throttle_retry.asyncio.sleep",
39 new_callable=AsyncMock,
40 ),
41 ):
42 yield
43