Skip to content

Commit

Permalink
Ensure lamarzocco tests add config entry before updating it (#110423)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Feb 15, 2024
1 parent 3529eb6 commit d49bccf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
1 change: 0 additions & 1 deletion tests/components/lamarzocco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ async def async_init_integration(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> None:
"""Set up the La Marzocco integration for testing."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
8 changes: 6 additions & 2 deletions tests/components/lamarzocco/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@


@pytest.fixture
def mock_config_entry(mock_lamarzocco: MagicMock) -> MockConfigEntry:
def mock_config_entry(
hass: HomeAssistant, mock_lamarzocco: MagicMock
) -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
entry = MockConfigEntry(
title="My LaMarzocco",
domain=DOMAIN,
data=USER_INPUT
| {CONF_MACHINE: mock_lamarzocco.serial_number, CONF_HOST: "host"},
unique_id=mock_lamarzocco.serial_number,
)
entry.add_to_hass(hass)
return entry


@pytest.fixture
Expand Down
5 changes: 0 additions & 5 deletions tests/components/lamarzocco/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ async def test_form_abort_already_configured(
mock_config_entry: MockConfigEntry,
) -> None:
"""Test we abort if already configured."""
mock_config_entry.add_to_hass(hass)

result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
Expand Down Expand Up @@ -211,9 +209,6 @@ async def test_reauth_flow(
hass: HomeAssistant, mock_lamarzocco: MagicMock, mock_config_entry: MockConfigEntry
) -> None:
"""Test that the reauth flow."""

mock_config_entry.add_to_hass(hass)

result = await hass.config_entries.flow.async_init(
DOMAIN,
context={
Expand Down
3 changes: 0 additions & 3 deletions tests/components/lamarzocco/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ async def test_load_unload_config_entry(
mock_lamarzocco: MagicMock,
) -> None:
"""Test loading and unloading the integration."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()

Expand All @@ -36,7 +35,6 @@ async def test_config_entry_not_ready(
"""Test the La Marzocco configuration entry not ready."""
mock_lamarzocco.update_local_machine_status.side_effect = RequestNotSuccessful("")

mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()

Expand All @@ -51,7 +49,6 @@ async def test_invalid_auth(
) -> None:
"""Test auth error during setup."""
mock_lamarzocco.update_local_machine_status.side_effect = AuthFail("")
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()

Expand Down

0 comments on commit d49bccf

Please sign in to comment.