forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Jellyfin init (home-assistant#79968)
- Loading branch information
1 parent
84acb41
commit 7fae85e
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Tests for the Jellyfin integration.""" | ||
from unittest.mock import MagicMock | ||
|
||
from homeassistant.components.jellyfin.const import DOMAIN | ||
from homeassistant.config_entries import ConfigEntryState | ||
from homeassistant.core import HomeAssistant | ||
|
||
from . import async_load_json_fixture | ||
|
||
from tests.common import MockConfigEntry | ||
|
||
|
||
async def test_config_entry_not_ready( | ||
hass: HomeAssistant, | ||
mock_config_entry: MockConfigEntry, | ||
mock_jellyfin: MagicMock, | ||
mock_client: MagicMock, | ||
) -> None: | ||
"""Test the Jellyfin configuration entry not ready.""" | ||
mock_client.auth.connect_to_address.return_value = await async_load_json_fixture( | ||
hass, | ||
"auth-connect-address-failure.json", | ||
) | ||
|
||
mock_config_entry.add_to_hass(hass) | ||
await hass.config_entries.async_setup(mock_config_entry.entry_id) | ||
await hass.async_block_till_done() | ||
|
||
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY | ||
|
||
|
||
async def test_load_unload_config_entry( | ||
hass: HomeAssistant, | ||
mock_config_entry: MockConfigEntry, | ||
mock_jellyfin: MagicMock, | ||
) -> None: | ||
"""Test the Jellyfin configuration entry loading/unloading.""" | ||
mock_config_entry.add_to_hass(hass) | ||
await hass.config_entries.async_setup(mock_config_entry.entry_id) | ||
await hass.async_block_till_done() | ||
|
||
assert mock_config_entry.entry_id in hass.data[DOMAIN] | ||
assert mock_config_entry.state is ConfigEntryState.LOADED | ||
|
||
await hass.config_entries.async_unload(mock_config_entry.entry_id) | ||
await hass.async_block_till_done() | ||
assert mock_config_entry.entry_id not in hass.data[DOMAIN] | ||
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED |