mirror of
https://github.com/home-assistant/core.git
synced 2025-12-22 20:09:35 +00:00
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:
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
|
||||
Reference in New Issue
Block a user