hass-core/tests/components/netatmo/common.py
Tobias Sauerwein 6b98583bc1
Add tests for Netatmo climate (#46392)
* Add tests for Netatmo climate

* Add comments and fake webhook events

* Split tests

* Split tests

* Clean up

* Fix coveragerc

* Fix requirements

* Remove freezegun dependency

* Move async_block_till_done to

* Call async_handle_webhook directly

* Use async_handle_webhook directly p2

* Exclude helper.py from

* Remove assertion of implementation details

* Use the webhook integration handler

* Extract function
2021-03-15 12:45:36 +01:00

44 lines
953 B
Python

"""Common methods used across tests for Netatmo."""
import json
from tests.common import load_fixture
CLIENT_ID = "1234"
CLIENT_SECRET = "5678"
ALL_SCOPES = [
"read_station",
"read_camera",
"access_camera",
"write_camera",
"read_presence",
"access_presence",
"write_presence",
"read_homecoach",
"read_smokedetector",
"read_thermostat",
"write_thermostat",
]
def fake_post_request(**args):
"""Return fake data."""
if "url" not in args:
return "{}"
endpoint = args["url"].split("/")[-1]
if endpoint in [
"setpersonsaway",
"setpersonshome",
"setstate",
"setroomthermpoint",
"setthermmode",
"switchhomeschedule",
]:
return f'{{"{endpoint}": true}}'
return json.loads(load_fixture(f"netatmo/{endpoint}.json"))
def fake_post_request_no_data(**args):
"""Fake error during requesting backend data."""
return "{}"