SMA code quality improvement and bugfix (#49346)
* Minor code quality improvements Thanks to @MartinHjelmare * Convert legacy dict config to list * Improved test * Typo * Test improvements * Create fixtures in conftest.py
This commit is contained in:
parent
a278ebd37b
commit
12853438c5
5 changed files with 142 additions and 100 deletions
33
tests/components/sma/conftest.py
Normal file
33
tests/components/sma/conftest.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""Fixtures for sma tests."""
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.sma.const import DOMAIN
|
||||
|
||||
from . import MOCK_CUSTOM_SETUP_DATA, MOCK_DEVICE
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry():
|
||||
"""Return the default mocked config entry."""
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
title=MOCK_DEVICE["name"],
|
||||
unique_id=MOCK_DEVICE["serial"],
|
||||
data=MOCK_CUSTOM_SETUP_DATA,
|
||||
source="import",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def init_integration(hass, mock_config_entry):
|
||||
"""Create a fake SMA Config Entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
with patch("pysma.SMA.read"):
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
return mock_config_entry
|
Loading…
Add table
Add a link
Reference in a new issue