core/tests/components/bmw_connected_drive/conftest.py

38 lines
1.0 KiB
Python

"""Fixtures for BMW tests."""
from collections.abc import Generator
from bimmer_connected.tests import ALL_CHARGING_SETTINGS, ALL_PROFILES, ALL_STATES
from bimmer_connected.tests.common import MyBMWMockRouter
from bimmer_connected.vehicle import remote_services
import pytest
import respx
@pytest.fixture
def bmw_fixture(monkeypatch: pytest.MonkeyPatch) -> Generator[respx.MockRouter]:
"""Patch MyBMW login API calls."""
# we use the library's mock router to mock the API calls, but only with a subset of vehicles
router = MyBMWMockRouter(
vehicles_to_load=[
"WBA00000000DEMO01",
"WBA00000000DEMO02",
"WBA00000000DEMO03",
"WBY00000000REXI01",
],
profiles=ALL_PROFILES,
states=ALL_STATES,
charging_settings=ALL_CHARGING_SETTINGS,
)
# we don't want to wait when triggering a remote service
monkeypatch.setattr(
remote_services,
"_POLLING_CYCLE",
0,
)
with router:
yield router