Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor test not loading bad backup platforms #132769

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions tests/components/backup/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,28 @@ async def test_loading_platforms(
assert "Loaded 1 platforms" in caplog.text


@pytest.mark.parametrize(
"platform_mock",
[
Mock(async_pre_backup=AsyncMock(), spec=["async_pre_backup"]),
Mock(async_post_backup=AsyncMock(), spec=["async_post_backup"]),
Mock(spec=[]),
],
)
async def test_not_loading_bad_platforms(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
platform_mock: Mock,
) -> None:
"""Test loading backup platforms."""
manager = BackupManager(hass, CoreBackupReaderWriter(hass))

assert not manager.platforms

await _setup_backup_platform(hass)
await manager.load_platforms()
"""Test not loading bad backup platforms."""
await _setup_backup_platform(
hass,
domain="test",
platform=platform_mock,
)
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()

assert len(manager.platforms) == 0

assert "Loaded 0 platforms" in caplog.text
assert platform_mock.mock_calls == []


async def test_exception_platform_pre(
Expand Down
Loading