forked from home-assistant/core
Remove reuse of exception object from bang_olufsen tests
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
"""Constants used for testing the bang_olufsen integration."""
|
"""Constants used for testing the bang_olufsen integration."""
|
||||||
|
|
||||||
from ipaddress import IPv4Address, IPv6Address
|
from ipaddress import IPv4Address, IPv6Address
|
||||||
from unittest.mock import Mock
|
|
||||||
|
|
||||||
from mozart_api.exceptions import ApiException
|
|
||||||
from mozart_api.models import (
|
from mozart_api.models import (
|
||||||
Action,
|
Action,
|
||||||
ListeningModeRef,
|
ListeningModeRef,
|
||||||
@@ -200,16 +198,6 @@ TEST_DEEZER_TRACK = PlayQueueItem(
|
|||||||
uri="1234567890",
|
uri="1234567890",
|
||||||
)
|
)
|
||||||
|
|
||||||
# codespell can't see the escaped ', so it thinks the word is misspelled
|
|
||||||
TEST_DEEZER_INVALID_FLOW = ApiException(
|
|
||||||
status=400,
|
|
||||||
reason="Bad Request",
|
|
||||||
http_resp=Mock(
|
|
||||||
status=400,
|
|
||||||
reason="Bad Request",
|
|
||||||
data='{"message": "Couldn\'t start user flow for me"}', # codespell:ignore
|
|
||||||
),
|
|
||||||
)
|
|
||||||
TEST_SOUND_MODE = 123
|
TEST_SOUND_MODE = 123
|
||||||
TEST_SOUND_MODE_2 = 234
|
TEST_SOUND_MODE_2 = 234
|
||||||
TEST_SOUND_MODE_NAME = "Test Listening Mode"
|
TEST_SOUND_MODE_NAME = "Test Listening Mode"
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
from contextlib import AbstractContextManager, nullcontext as does_not_raise
|
from contextlib import AbstractContextManager, nullcontext as does_not_raise
|
||||||
import logging
|
import logging
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from mozart_api.exceptions import NotFoundException
|
from mozart_api.exceptions import ApiException, NotFoundException
|
||||||
from mozart_api.models import (
|
from mozart_api.models import (
|
||||||
BeolinkLeader,
|
BeolinkLeader,
|
||||||
BeolinkSelf,
|
BeolinkSelf,
|
||||||
@@ -81,7 +81,6 @@ from .const import (
|
|||||||
TEST_ACTIVE_SOUND_MODE_NAME_2,
|
TEST_ACTIVE_SOUND_MODE_NAME_2,
|
||||||
TEST_AUDIO_SOURCES,
|
TEST_AUDIO_SOURCES,
|
||||||
TEST_DEEZER_FLOW,
|
TEST_DEEZER_FLOW,
|
||||||
TEST_DEEZER_INVALID_FLOW,
|
|
||||||
TEST_DEEZER_PLAYLIST,
|
TEST_DEEZER_PLAYLIST,
|
||||||
TEST_DEEZER_TRACK,
|
TEST_DEEZER_TRACK,
|
||||||
TEST_FALLBACK_SOURCES,
|
TEST_FALLBACK_SOURCES,
|
||||||
@@ -1249,7 +1248,16 @@ async def test_async_play_media_invalid_deezer(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test async_play_media with an invalid/no Deezer login."""
|
"""Test async_play_media with an invalid/no Deezer login."""
|
||||||
|
|
||||||
mock_mozart_client.start_deezer_flow.side_effect = TEST_DEEZER_INVALID_FLOW
|
# codespell can't see the escaped ', so it thinks the word is misspelled
|
||||||
|
mock_mozart_client.start_deezer_flow.side_effect = ApiException(
|
||||||
|
status=400,
|
||||||
|
reason="Bad Request",
|
||||||
|
http_resp=Mock(
|
||||||
|
status=400,
|
||||||
|
reason="Bad Request",
|
||||||
|
data='{"message": "Couldn\'t start user flow for me"}', # codespell:ignore
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||||
|
Reference in New Issue
Block a user