)
self._converters = BandcampConverters(self.domain, self.instance_id)
+ # The provider can function without login (search-only),
+ # but if credentials were explicitly configured, validate them now.
+ # A bad login fails hard so the user can fix it immediately;
+ # transient errors (rate limits, network) are logged and the provider
+ # continues since the login may still be valid.
+ if identity:
+ try:
+ await self._client.get_collection_summary()
+ except BandcampMustBeLoggedInError as error:
+ raise LoginFailed("Bandcamp login is invalid or expired.") from error
+ except BandcampAPIError as error:
+ self.logger.warning("Could not validate Bandcamp login: %s", error)
+
@property
def is_streaming_provider(self) -> bool:
"""Return True if the provider is a streaming provider."""
# Initialize the provider
with patch("music_assistant.providers.bandcamp.BandcampAPIClient") as mock_client_class:
- mock_client = Mock()
+ mock_client = AsyncMock()
mock_client_class.return_value = mock_client
await provider.handle_async_init()
# Test that initialization sets the correct values
with patch("music_assistant.providers.bandcamp.BandcampAPIClient") as mock_client_class:
- mock_client = Mock()
+ mock_client = AsyncMock()
mock_client_class.return_value = mock_client
await provider.handle_async_init()
async def test_handle_async_init_with_identity(provider: BandcampProvider) -> None:
"""Test successful async initialization with identity token."""
with patch("music_assistant.providers.bandcamp.BandcampAPIClient") as mock_client_class:
- mock_client = Mock()
+ mock_client = AsyncMock()
mock_client_class.return_value = mock_client
await provider.handle_async_init()
provider = BandcampProvider(mass_mock, manifest_mock, config)
with patch("music_assistant.providers.bandcamp.BandcampAPIClient") as mock_client_class:
- mock_client = Mock()
+ mock_client = AsyncMock()
mock_client_class.return_value = mock_client
await provider.handle_async_init()