hass-core/tests/components/ecobee/conftest.py
Jan Bouwhuis 8d2813fb8b
Migrate legacy Ecobee notify service ()
* Migrate legacy Ecobee notify service

* Correct comment

* Update homeassistant/components/ecobee/notify.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Use version to check latest entry being used

* Use 6 months of deprecation

* Add repair flow tests

* Only allow migrate_notify fix flow

* Simplify repair flow

* Use ecobee data to refrence entry

* Make entry attrubute puiblic

* Use hass.data ro retrieve entry.

* Only register issue when legacy service when it is use

* Remove backslash

* Use ws_client.send_json_auto_id

* Cleanup

* Import domain from notify integration

* Apply suggestions from code review

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Update dependencies

* Use Issue_registry fixture

* remove `update_before_add` flag

* Update homeassistant/components/ecobee/notify.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Update homeassistant/components/ecobee/notify.py

* Update tests/components/ecobee/conftest.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Fix typo and import

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-04-23 22:53:13 +02:00

39 lines
1.2 KiB
Python

"""Fixtures for tests."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch
import pytest
from homeassistant.components.ecobee import ECOBEE_API_KEY, ECOBEE_REFRESH_TOKEN
from tests.common import load_fixture, load_json_object_fixture
@pytest.fixture(autouse=True)
def requests_mock_fixture(requests_mock):
"""Fixture to provide a requests mocker."""
requests_mock.get(
"https://api.ecobee.com/1/thermostat",
text=load_fixture("ecobee/ecobee-data.json"),
)
requests_mock.post(
"https://api.ecobee.com/token",
text=load_fixture("ecobee/ecobee-token.json"),
)
@pytest.fixture
def mock_ecobee() -> Generator[None, MagicMock]:
"""Mock an Ecobee object."""
ecobee = MagicMock()
ecobee.request_pin.return_value = True
ecobee.refresh_tokens.return_value = True
ecobee.thermostats = load_json_object_fixture("ecobee-data.json", "ecobee")[
"thermostatList"
]
ecobee.get_thermostat = lambda index: ecobee.thermostats[index]
ecobee.config = {ECOBEE_API_KEY: "mocked_key", ECOBEE_REFRESH_TOKEN: "mocked_token"}
with patch("homeassistant.components.ecobee.Ecobee", return_value=ecobee):
yield ecobee