core/tests/components/zwave/conftest.py

27 lines
708 B
Python
Raw Normal View History

2019-02-07 21:50:59 +00:00
"""Fixtures for Z-Wave tests."""
import pytest
from tests.async_mock import MagicMock, patch
2019-02-07 21:50:59 +00:00
from tests.mock.zwave import MockNetwork, MockOption
@pytest.fixture
def mock_openzwave():
"""Mock out Open Z-Wave."""
base_mock = MagicMock()
libopenzwave = base_mock.libopenzwave
2019-07-31 19:25:30 +00:00
libopenzwave.__file__ = "test"
2019-02-07 21:50:59 +00:00
base_mock.network.ZWaveNetwork = MockNetwork
base_mock.option.ZWaveOption = MockOption
2019-07-31 19:25:30 +00:00
with patch.dict(
"sys.modules",
{
"libopenzwave": libopenzwave,
"openzwave.option": base_mock.option,
"openzwave.network": base_mock.network,
"openzwave.group": base_mock.group,
},
):
2019-02-07 21:50:59 +00:00
yield base_mock